我们翻译了 woocommerce商店通过weglot,一切正常。不幸的是,主页上的某些单词没有被翻译。
它是主页上显示类别内部图像中的部分。类别的名称甚至实际上具有类别为类,但仍未被Weglot识别:
<div class="jgb_item-title">Kleider</div>
根据HTML源代码,标题的字符串未直接包含在代码中。
ScreenShot html html html源代码
所以我尝试了weglot的官方挂钩( https://develovelers.weglot..weglot.com/wordpress/wordpress/filters/translations-filters-filters-filters-filters-filters )帮助。那就是我在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 ;
}
不幸的是,我没有其他解决方案。这里有人可以帮我吗?
非常感谢。
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.
发布评论
评论(1)
感谢您的答复。
您的类别通过此URL加载: https://ayen-label.com/ean-label.com/en/wp-json/wp-json/wp-json/posts-buid-builder/posts-grid-builder/taxsonomy-tarax andsmandy /?分类法=任何&amp; incly = 68%2C78%2C46%2C49%2C166&amp; thumbnail_size = full&amp; tock_type = default = default
默认情况下,JSON的所有键均不能由Weglot翻译,但使用此过滤器,它可以工作:
希望这是帮助
问候
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 :
Hope it's help
Regards