Change Content based on language/locale

Solved
hansen_san
Tourist
5 1 1

Hi Folks,

I have a little problem and couldn't find a workaround yet.

I want to display different images, based on the current active language. Using Translation Lab for Text Translations.

I tried: 

{% if shop_locale.iso_code == 'en' %}
<img>
{% elsif shop_locale.iso_code == 'de' %}

<img>
{% endif %}

also tried with lang=='en'

But none of them worked. What would be the appropriate variable to check ? 

 

Thanks in advance, Hansen

0 Likes
Kyle_W
Shopify Expert
92 12 39

This is an accepted solution.

Hi @hansen_san!

If you are wanting to display content based on the user's selected language, then you might have better luck using the request object. For example, you could use something like the following to display content for English users:

{% if request.locale.iso_code == 'en' %}
English content
{% endif %}

 Hopefully this helps!

Kyle W | Helium Dev, LLC
Helium builds apps that merchants depend on:
- Customer Fields
- Meteor Mega Menu
0 Likes
hansen_san
Tourist
5 1 1

That works. Thanks a lot ! Very grateful for your help