Support » Plugin: Search & Filter » Compatibility fix with GTranslate

  • Hi,

    I’m the developer of GTranslate multilingual website solution.

    One of our customers is using your search-filter-pro plugin and was having issues translating JSON responses for search.

    By default we do not translate JSON objects. To translate we require the JSON object to include special key which defines which object keys should be translated.

    I have modified your plugin code: public/class-search-filter.php to define the keys.

    For get_results $sf_action the code looks like this:

    // gtranslate json translation
    if(isset($_SERVER['HTTP_X_GT_LANG'])) {
        $results['gt_translate_keys'] = array(array('key' => 'form', 'format' => 'html'), array('key' => 'results', 'format' => 'html'));
    }
    
    echo Search_Filter_Helper::json_encode($results);

    For get_form $sf_action the code looks like this:

    // gtranslate json translation
    if(isset($_SERVER['HTTP_X_GT_LANG'])) {
        $results['gt_translate_keys'] = array(array('key' => 'form', 'format' => 'html'));
    }
    
    echo Search_Filter_Helper::json_encode($results);

    I would be happy if you can include this changes into your code, so our customers who use your plugin will be able to translate JSON objects and also update your plugin to latest version without the need of hacking your code.

    If you have more JSON objects, you can check the documentation how to add the definition to translate the JSON objects: https://gtranslate.io/docs/58-gtranslate-tdn-documentation

    Thanks!

    https://wordpress.org/plugins/search-filter/

Viewing 1 replies (of 1 total)
  • Plugin Author DesignsAndCode

    (@designsandcode)

    Hey Edvard

    Many thanks fore this.

    I’m guessing this is to add compatibility with Pro?

    It is very rare I will add other plugin specific code in to the core code, however, I will setup a filter for the $results object, so any users’ wishing to use both plugins together will need to add some simply PHP to their functions.php for example.

    Sound good?

    I’ll let you know when its implemented.

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Compatibility fix with GTranslate’ is closed to new replies.