Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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
Solved! Go to the solution
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!
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!
That works. Thanks a lot ! Very grateful for your help 🙂
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?
Thank you so much for this! This helped me with an issue I had, and it worked perfectly!
This is Max from Tapita.
We just released the function which can solve your request without coding
https://www.youtube.com/watch?v=w7deZxC72vw
Please tell me, I will open a trial for you.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025