Added snippet specific to language of user location

Added snippet specific to language of user location

nastic
Tourist
10 0 2

Hi,

 

I added a new snippet to my theme. I know have the problem, that the new content of the new snippet only appears in English or German (depening on what language I used in the title within the snippet).

 

How can I set up the snippet that it automatically chooses the language the user chose? Thus if the user browsers the site in Italian want it to be in Italian, in German I want it to be in German.

Alternatively I would be happy to know where in translations I can translate the new part. I have difficulties finding it (using Tlab and Translate & Adapt).

Thankful for every help.

Replies 3 (3)

Litos
Globetrotter
688 169 150

Hi @nastic,

You can use 'request.locale.iso_code' object to check it, refer: https://shopify.dev/api/liquid/objects/shop-locale

For example code:

{% if request.locale.iso_code == 'it' %}
<!--   show content for Italian -->
{% elsif request.locale.iso_code == 'de' %}
<!--   show content for German  -->
{% elsif request.locale.iso_code == 'en' %}
<!--   show content for English   -->
{% endif %}

Hope it helps!

 

Litos - Shopify Development Service Provider
Need to develop or customize your Shopify store, feel free to contact us here.
nastic
Tourist
10 0 2

Hey Litos,

 

thanks for the reply. Where exactly do I place the code you mentioned? 

 

Thank you so much for your help.

Litos
Globetrotter
688 169 150

Hi @nastic,

You add it where you want to add the condition for this: new snippet.

Hope it helps!

Litos - Shopify Development Service Provider
Need to develop or customize your Shopify store, feel free to contact us here.