Can't load the right local ISO code in HTML tag

Highlighted
Excursionist
15 1 2

Hello,

I don't know what's wrong here, it's always loaded "de" code for Germany and the current language is Spanish, normally it should be "es", I didn't get it

{% for shop_locale in shop.published_locales %}
<html lang="{{ shop_locale.iso_code }}" >
{% endfor %}

 

Topbright_0-1594719404420.png

 

Website: Topbright

0 Likes
Highlighted
Shopify Partner
480 60 78

@Topbright ,

It returns the  array so did it give you de 2 times? It is possible that this is not being set anywhere and hence it won't return you what you are looking for. Try setting the locale and check

{% for locale in shop.published_locales %}
  {{ locale.name }} ({{ locale.iso_code }})
{% endfor %}
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution

Skype : lokendra.panwar1
0 Likes
Highlighted
Excursionist
15 1 2

I had tried that one still not working, maybe I did something wrong, I want to change the meta tag lang according to the local store language, 

for example, if the store language is English:

<html lang="en-US">

if the store language is Spanish:

<html lang="es" >

and so

 

{% for locale in shop.published_locales %}
  {{ locale.name }} ({{ locale.iso_code }})
{% endfor %}

This one retune "German (de)" but the store language is English, whatever languages I choose it's always returned same results "German (de)"

 

0 Likes
Highlighted
Shopify Partner
480 60 78

@Topbright ,

I think only default locale is published, you may want to try adding languages from admin to enable them in published state....please see below...

shopi1.png

Your default is likely to be German or you might have added only German besides english

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution

Skype : lokendra.panwar1
0 Likes
Highlighted
Excursionist
15 1 2

I have English as default language and 3 more languages published for translation, I really don't get it

Topbright_0-1594778247933.png

 

0 Likes
Highlighted
Shopify Partner
480 60 78

@Topbright ,

I used the following code

{% for locale in shop.published_locales %}
   {{ locale.shop_local }} ({{ locale.iso_code }}),
  {{forloop.length}}
{% endfor %} 

and I got this output

shopi1.png 

So it does work, it stores and outputs them in alphabetical order so you might have to iterate and check till you find the language you want to set.

All the best!

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution

Skype : lokendra.panwar1
0 Likes
Highlighted
Excursionist
15 1 2

I had tried that one and I get the same output like u, it's possible to get only the iso code for the current language of the store, not all of them?

0 Likes