Woocommerce script causing issues with Weglot translation plugin
-
I am using the Weglot plugin to translate our Woocommerce site Site Being Built. Weglot allows you to exclude areas that you don’t want translated, to save from your quota of words.
Weglot says:
Excluded Blocks By default, everything is translated on a page but you can exclude a section of a page by entering the CSS selector or HTML block you want to exclude.
We have successfully blocked everything containing the product name/product title EXCEPT one thing. There is a script running that contains the product name/product title and Weglot is translating the data in the script, even though it is not displayed. I have been working with Weglot support for about a week trying to figure out how to exclude it, but nothing has worked. ??
Based on what Weglot said about, about excluding page sections, can you figure out a way to make the script able to be excluded? What is that script for and, if it isn’t important, is there a way to remove it or the product name/product title that it is pulling?
Here is the script from the page. The translated words are: “Diamentowy wisiorek” (originally “Diamond Pendant“):
<script type="application/ld+json">{"@context":"https:\/\/schema.org\/","@graph":[{"@context":"https:\/\/schema.org\/","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"name":"Strona g\u0142\u00f3wna","@id":"https:\/\/store.dolina.org"}},{"@type":"ListItem","position":2,"item":{"name":"Christmas Ornaments (Bombki Choinkowe)","@id":"https:\/\/store.dolina.org\/product-category\/christmas-ornaments-bombki-choinkowe\/"}},{"@type":"ListItem","position":3,"item":{"name":"Diamentowy wisiorek","@id":"https:\/\/store.dolina.org\/product\/diamond-pendant\/"}}]},{"@context":"https:\/\/schema.org\/","@type":"Product","@id":"https:\/\/store.dolina.org\/product\/diamond-pendant\/#product","name":"Diamentowy wisiorek","url":"https:\/\/store.dolina.org\/product\/diamond-pendant\/","description":"Kr\u00f3tki opis","image":"https:\/\/store.dolina.org\/wp-content\/uploads\/2016\/02\/jewelry.jpg","sku":213,"offers":[{"@type":"Offer","price":"250.00","priceValidUntil":"2021-12-31","priceSpecification":{"price":"250.00","priceCurrency":"USD","valueAddedTaxIncluded":"false"},"priceCurrency":"USD","availability":"http:\/\/schema.org\/InStock","url":"https:\/\/store.dolina.org\/product\/diamond-pendant\/","seller":{"@type":"Organization","name":"Sklep wysy\u0142kowy Zespo\u0142u Pie\u015bni i Ta\u0144ca Dolina","url":"https:\/\/store.dolina.org"}}],"aggregateRating":{"@type":"AggregateRating","ratingValue":"4.00","reviewCount":1},"review":[{"@type":"Review","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"4","worstRating":"1"},"author":{"@type":"Person","name":"storesklep"},"reviewBody":"This is a test","datePublished":"2020-08-03T14:50:53-06:00"}]}]}</script>
I even tried adding around where I thought the scripts were being pulled in footer.php.
</div> <!-- Page end --> <div id="No-Translate-Scripts"> <?php wp_footer(); ?> </div> </body> </html>
Weglot support even had me add the following code snippet to try to exclude the script’s data from being translated.
add_filter( 'weglot_add_json_keys', 'custom_weglot_add_json_keys' ); function custom_weglot_add_json_keys( $keys ){ $keys = array('desc'); return $keys; }
For some reason, the only data being translated is the product name. A member of Stack Overflow said that the script is related to WC_Structured_Data Class.
Any thoughts on why that one item is being translated and how to exclude it (based on how Weglot allows you to exclude things from translation?
Thanks in advance! ??
The page I need help with: [log in to see the link]
- The topic ‘Woocommerce script causing issues with Weglot translation plugin’ is closed to new replies.