How can I display images based on active language in Translation Lab?

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’ %}

{% elsif shop_locale.iso_code == ‘de’ %}

{% endif %}

also tried with lang==‘en’

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

Thanks in advance, Hansen

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!

1 Like

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

1 Like

Hi @hansen_san @Kyle_W

I’m using the Dawn 2.0 theme, and I was wondering where do you paste this code?

Assuming I want to display different images in my homepage, based on the current active language.

Thanks!

Hey Ben,

I inserted the code in the section liquids where I needed them. I also created some custom sections which I call in my page templates etc. So you need to find the respective section where you want to display your images.

Hope this helped you?

1 Like

Hi @hansen_san ,

Can you share parts of screenshots of how you succeedd solving it?

Thank you so much for this! This helped me with an issue I had, and it worked perfectly!