This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Turkish characters not found

#31364
Ernest MarcinkoErnest Marcinko
Keymaster

To add, even with those database collations, the turkish character “ı” is not going to match “i” or the capital version of it “I”. “ı” =/= “i”
The database will treat those as completely different characters, I don’t think there is a collation which can cross match those characters. I tried testing different collations, but it seems like that is not possible.

If “Sarı” didn’t match, that means the user details are still stored as “sari” or “SARI”, only the translation is changed. But again, I don’t know how that translation plugin works.

I think you have maybe two ways of resolving this:

1. To add a user meta field, witch the original/translated names and any other keywords and add that field to the search as well.
2. Or use a character removal replacment code based on this tutorial. There was a similar issue with a different character set, which we resolved by using a custom code to replace characters in the search query string:

add_filter('asp_indexing_string_pre_process', 'custom_chars_asp_indexing_string_pre_process', 10, 1);
add_filter('asp_search_phrase_before_cleaning', 'custom_chars_asp_indexing_string_pre_process', 10, 1);
add_filter('asp_query_args', 'custom_chars_asp_indexing_string_pre_process', 10, 1);
function custom_chars_asp_indexing_string_pre_process($s) {
	$original = array(
		'ı', 'ī', 'ʻ', 'ā', 'Ṭ', 'ṣ', 'ū'
	);
	$replace = array(
		'i', 'i', '', 'a', 't', 's', 'u'
	);
	
	// Replace them
	if ( is_array($s) ) {
		if ( isset($s['s']) && !$s['_ajax_search'] ) 
			$s['s'] = str_replace($original, $replace, $s['s']);      
	} else {
		$s = str_replace($original, $replace, $s);
	}
	
	return $s;
}

But of course, this only works if the language of the stored names is always the same.