Modifying Main Widget language for Multilingual stores

Do you have a multilingual store and want to change the widget language based on your website language ? This article will help you to update the language of the main review widget dynamically based on the theme's language.

*This guide is only applicable for Shopify users*


In This Guide


Updating the Widget code

In order to change the widget language dynamically, we utilize a liquid variable in Shopify which is {{ shop.locale }} and add an extra attribute in the widget code to set the widget language as per the value returned by this liquid variable. The value returned from this variable is actually a two-letter ISO code from the theme. For E.g.- 'FR' for France and 'JP' for Japan.

Note: This attribute will only change the language of the widget's elements. The reviews will still appear in the language originally submitted, changing it would require integration with a translation app, such as Langify or Weglot.

Attribute to update: 

data-widget-language = {{ shop.locale }}

Final Main widget code:

<div id="stamped-main-widget" 
data-widget-style="standard"
data-product-id="{{ product.id }}" 
data-name="{{ product.title | escape }}" 
data-url="{{ shop.url }}{{ product.url }}" 
data-image-url="{{ product.featured_image | product_img_url: "large" |replace: '?', '%3F' | replace: '&','%26'}}" 
data-description="{{ product.description | escape }}" 
data-product-sku="{{product.handle}}"
data-product-type="{{product.type}}"
data-widget-language ="{{ shop.locale }}">
{{ product.metafields.stamped.reviews }} 
</div>