Arabic words with characteristics

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Arabic words with characteristics

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
1 year, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #28769

    Participant

    Hello,

    i have some Arabic words with characteristics that cant be searched if i didn’t use the characteristics .

    Example :
    word with characteristics :يُوَضِّحُ
    word without : يوضح

    So the normal user should typed it without the characteristics to find it.

    how can i do it ?

    #28775

    Hi,

    By default, the WordPress database should be character case and accent insensitive. It is however possible that some of the accents may not be supported by the database collation.
    Depending on the situation, I recommend 2 possible solutions:

    Solution #1
    If there are only a few words or phrases that exist with and without the accents, you can use the synonyms feature with the index table engine.
    Entering the non-accented versions as synonyms will make it available for searches without accents.

    Solution #2
    This is a bit more complciated, but a far better solution, as it will probably work with all the characters in all keywords, and no need to define them one by one.

    Please follow the instructions below:

    1. Please add this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    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(
    		'ي', 'ض'
    	);
    	
    	// 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;
    }

    2. I added only two characters for the example. Edit the $original and the $replace variables, to add the original (non characteristic) and the characterstic version of each character.
    If you have a list of characteristic/non-characteristic characters, then I can help you with that.

    3. Make sure to configure the index table engine. Follow the tutorial.

    4. Once ready and the indexing is finished. Make sure the index table is enabled

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.