Weglot不会翻译一些字符串

发布于 2025-01-24 17:33:39 字数 1596 浏览 0 评论 0 原文

我们翻译了 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅的被狗咬 2025-01-31 17:33:39

感谢您的答复。
您的类别通过此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翻译,但使用此过滤器,它可以工作:

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;
    }

希望这是帮助
问候

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文