Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi!
Is there any way to get the {{ request.locale.iso_code }} tag (or any other tag) to show the full language code instead of just the first part ("en_GB" vs only "en")?
As an example. In our US site i would like the head html to show the lang as "en_US" instead of just "en". But for the life of it I can't figure out why I can't get this info when it's used in the URL and everywhere else.
<html class="no-js no-touch" lang="{{ request.locale.iso_code }}">
We're using Markets and everything works otherwise as it should.
Any help is greatly appreciated!
- Thomas
the value of {{request.locale.iso_code
}}may be determined by the theme's code and can be different from one theme to another. To show the full language code, you'll need to modify the code in the theme.
You can do this by creating a new Liquid variable that stores the full language code and then using that variable in the HTML. Here's an example:
{% capture full_locale_code %}{{ shop.locale }}{% endcapture %} <html class="no-js no-touch" lang="{{ full_locale_code }}">
In this example, the {{shop.locale
}} value is stored in the {{full_locale_code
}} variable, which can then be used in the HTML.
this is just an example, and the exact implementation may vary depending on the theme you are using.
Thank you for the help! I did not get this to work exactly the way intended, so I had to finally invent a workaround instead. I just find it curious why the {{request.locale.iso_code
}} only retrieves the first part and not the full code. I assume there is a reason for this though, like always.
The problem is mostly with apps, which often target languages and countries differently from the Shopify markets. It's a bit of a mess at the moment as it's a mix of different techniques.
Hello, can you Tell me about the method you invented, i meet the same problem, i really need this!
This only returns the language. Same as "{{ request.locale.iso_code }}"
no, this doesn't work😭
We recently spoke with Zopi developers @Zopi about how dropshipping businesses can enha...
By JasonH Oct 23, 2024A big shout out to all of the merchants who participated in our AMA with 2H Media: Holi...
By Jacqui Oct 21, 2024We want to take a moment to celebrate the incredible ways you all engage with the Shopi...
By JasonH Oct 15, 2024