我們翻譯了我們的WooCommerce 商店通過 Weglot不幸的是,主頁上的一些文字沒有翻譯。
它是主頁上在影像內顯示類別的部分。類別的名稱甚至實際上有一個帶類的 DIV,但 Weglot 仍然無法識別它:
<div class="jgb_item-title">Kleider</div>
根據 HTML 源代碼,標題的字串不直接包含在代碼中。
截圖html源代碼
所以我嘗試了 Weglot 的官方鉤子(https://developers.weglot.com/wordpress/filters/translations-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 ;
}
不幸的是,我沒有其他解決方案。這里有人可以幫助我嗎?
提前謝謝了。
uj5u.com熱心網友回復:
希望你沒事?我是 weglot 的 Edson。很抱歉您遇到的問題。你想翻譯 Kleider 這個詞。問題是屬性 v-if you try to translate 不包含單詞,而是包含可能通過 js 或 ajax 進行轉換的短??代碼。您必須找到單詞在源代碼中的存盤位置才能翻譯它們。
可以給你一個我可以看到的頁面的網址來幫助你嗎?
問候埃德森
uj5u.com熱心網友回復:
非常感謝您的回答!我已經在“Woocommerce Store”鏈接了上面的商店。這里又是鏈接:
https://ayen-label.com
我們不僅要翻譯“Kleider”這個詞,還要翻譯所有其他類別。您可以在標題“商店”下的標題后面找到 5 個類別。
問候, 阿尼爾
uj5u.com熱心網友回復:
感謝您的回復。您的類別通過以下網址加載:https ://ayen-label.com/en/wp-json/posts-grid-builder/v1/taxonomy-terms/?taxonomy=any&include=68,78,46,49,166&thumbnail_size =完整&items_type=默認
默認情況下,來自 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;
}
希望對您有所幫助
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/467666.html
標籤:WordPress woocommerce 翻译 元素
