'Weglot does not translate some strings

We translated our WooCommerce store via Weglot and everything worked fine. Unfortunately, some words on the home page were not translated.

It is the section on the home page where the categories are displayed inside the image. The names of the categories even actually have a DIV with class and still it is not recognized by Weglot:

<div class="jgb_item-title">Kleider</div>

According to the HTML source code, the strings of the titles are not directly included in the code.

Screenshot html source code

So I tried an official hook from Weglot (https://developers.weglot.com/wordpress/filters/translations-filters), which didn't help. That's the code I inserted in the functions.php:

<?php
  add_filter( 'weglot_get_dom_checkers', 'custom_weglot_dom_check' );
  function custom_weglot_dom_check( $dom_checkers  ) { //$dom_checkers contains the 
   list of all the class we are checking by default

class Div_Slide_Title extends Weglot\Parser\Check\Dom\AbstractDomChecker {
    const DOM       = 'div'; //Type of tag you want to detect // CSS Selector
    const PROPERTY  = 'v-if'; //Name of the attribute in that tag uou want to detect
    const WORD_TYPE = Weglot\Client\Api\Enum\WordType::TEXT; //Do not change unless it's not text but a media URL like a .pdf file for example.
}
$dom_checkers[] = '\Div_Slide_Title'; //You add your class to the list because you want the parser to also detect it
return $dom_checkers ;

}

Unfortunately, I don't have any other solution. Can someone here maybe help me?

Many thanks in advance.



Solution 1:[1]

thanks for your reply. Your categories are load via this url : https://ayen-label.com/en/wp-json/posts-grid-builder/v1/taxonomy-terms/?taxonomy=any&include=68%2C78%2C46%2C49%2C166&thumbnail_size=full&items_type=default

By default all the key from a json are not translate by weglot but with this filter it should works :

add_filter( 'weglot_add_json_keys',  'custom_weglot_add_json_keys' );
    function custom_weglot_add_json_keys(  $keys  ){ //$keys already contains "name" and "description"
        $keys[]  =  'term_title';
        $keys[]  =  'term_slug';
        $keys[]  =  'message';
        $keys[]  =  'term_taxonomy';
        return $keys;
    }

Hope it's help Regards

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Edson Galina Fortes