WPGlobus Language Support

I understand that Algolia currently supports WPML language support, however our website is already manually translated using a plugin called WPGlobus.

Currently in the instant searches they are showing up as such:

My initial thoughts were to use some sort of jQuery regex and remove one of them depending on language selected from the link. However, it seems like jQuery is unable to actually grab any of those, I’m assuming because they’re dynamically generated on top of it?

If anyone would have insight on how I can use one of the languages only in the title I would really appreciate it!

Hey there, thanks for reaching out.

Making the plugin compatible with your localization plugin would require quite some work I think.
Also there are some choices to be made regarding wether to store all languages in every record, or to create separate records per language.
Then all the frontend code would also need to be adapted.

Trying to format data on the client side would result in bad relevancy because the search engine would search on both languages at the same time.

I don’t think there is an easy solution here.

If you have developer resources, the easiest way is probably to push your data directly with our PHP API Client and work on a custom frontend integration.

I hope that helps,

1 Like

Hey Ray,

Thanks for the response! I actually managed to get somewhere, but still have work to do. I applied a PHP filter but all this is giving me is the english format and no other languages, it also adds paragraph html tags to all the titles.

Here’s what I have so far:

add_filter('algolia_searchable_post_records', 'filter__algolia_searchable_post_records');
function filter__algolia_searchable_post_records( $records, $post ) {
	
	$_fields = array(
		'post_title',
		'post_excerpt'
	);
	foreach( $records as $key=>$record ) {
		foreach ( $_fields as $_field ) {
			if ( ! empty( $record[$_field] ) ) {
				echo "$record[$_field]";
				$records[$key][$_field] = apply_filters( 'the_content', $record[$_field] );
			}
		}
	}
	return $records;
}  

Would love to hear your thoughts / suggestions.

I would love to help you unfortunately my knowledge of your localization plugin is limited :confused:

If the plugin is to hard to reason about for your usage, maybe starting something based on the Algolia client directly could be a good fit for you.

Here is an example of plugin that leverages the client in a more straight forward way, maybe that could inspire you: https://github.com/rayrutjes/wc-order-search-admin