Weglot พร้อม WordPress และ Woocommerce

เรามีไซต์ WP พร้อม Woocommerce และแปลเนื้อหาด้วย Weglog ดูเหมือนว่าทุกอย่างทำงานได้ดียกเว้นคำอธิบายรูปแบบผลิตภัณฑ์

ฉันคิดว่าปัญหาคือรูปแบบต่างๆ จะถูกจัดเก็บเป็นค่าข้อมูลในรูปแบบ:

<form class="variations_form cart" action="XXXXX" method="post" enctype="multipart/form-data" data-product_id="64161" data-product_variations="[{&quot;attributes&quot;:{&quot;attribute_pa_color1&quot;:&quot;rose-gold-plattiert&quot;},&quot;availability_html&quot;:&quot;<p class=\&quot;stock available-on-backorder\&quot;>Dieser Artikel ist beim Hersteller verf\u00fcgbar. Lieferung innerhalb von 14 Tagen<\/p>\n&quot;,&quot;backorders_allowed&quot;:true,&quot;dimensions&quot;:{&quot;length&quot;:&quot;&quot;,&quot;width&quot;:&quot;&quot;,&quot;height&quot;:&quot;&quot;},&quot;dimensions_html&quot;:&quot;n.a.&quot;,&quot;display_price&quot;:25,&quot;display_regular_price&quot;:25,&quot;image&quot;:{&quot;title&quot;:&quot;MEL-VP04RG12000_gr&quot;,&quot;caption&quot;:&quot;&quot;,&quot;,&quot;variation_description&quot;:&quot;<p>Vivid Anh\u00e4nger f\u00fcr Halsketten | Drop,Ros\u00e9 Gold plattiert |Edelstahl<\/p>\n&quot;,&quot;variation_id&quot;:64163,&quot;variation_is_active&quot;:true,&quot;variation_is_visible&quot;:true,&quot;weight&quot;:&quot;&quot;,&quot;weight_html&quot;:&quot;n.a.&quot;,&quot;jck_additional_images&quot;" current-image="51586">

Weglog มีตะขอสำหรับการแปลที่ฉันควรใช้: https://developers.weglot.com/wordpress/filters/translations-filters

ฉันไม่สามารถทำมันได้เพราะฉันไม่มีประสบการณ์มากพอ ฉันอยากจะแปลองค์ประกอบข้อความต่างๆ ด้วยสิ่งนั้นได้

ขอบคุณมากล่วงหน้า


person sixtynine    schedule 24.10.2020    source แหล่งที่มา


คำตอบ (1)


สารละลาย:

add_filter( 'weglot_get_regex_checkers', 'custom_weglot_add_regex_checkers' );
function custom_weglot_add_regex_checkers( $regex_checkers ) {

// Text
$regex_checkers[] = new \Weglot\Parser\Check\Regex\RegexChecker( '#data-product_variations="([^"]*)"#', 'JSON', 1, array('attributes'), "html_entity_decode" , "htmlentities" );

return $regex_checkers;

}

person sixtynine    schedule 25.10.2020