Description
shop_locale.root_url inside a localization.available_countries / country.available_languages loop does not return the root URL for that language — it returns the root URL of the currently active locale for every iteration.
Liquid template:
{%- for country in localization.available_countries -%}
"{{ country.iso_code }}": [
{%- for lang in country.available_languages -%}
{
"iso_code": "{{ lang.iso_code }}",
"endonym_name": {{ lang.endonym_name | json }},
"root_url": {{ lang.root_url | json }}
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
]{% unless forloop.last %},{% endunless %}
{%- endfor -%}
Resulting output (truncated):
"AT": [
{"iso_code": "de", "endonym_name": "Deutsch", "root_url": "/en-gb"},
{"iso_code": "en", "endonym_name": "English", "root_url": "/en-gb"}
],
"DK": [
{"iso_code": "da", "endonym_name": "Dansk", "root_url": "/en-gb"},
{"iso_code": "en", "endonym_name": "English", "root_url": "/en-gb"}
],
...
Every root_url is /en-gb — the path of the active session locale — regardless of which country or language is being iterated.
Expected behavior:
lang.root_url should return the root URL path for that specific language, e.g.:
"AT": [
{"iso_code": "de", "endonym_name": "Deutsch", "root_url": "/de"},
{"iso_code": "en", "endonym_name": "English", "root_url": "/en-gb"}
],
"DK": [
{"iso_code": "da", "endonym_name": "Dansk", "root_url": "/da"},
{"iso_code": "en", "endonym_name": "English", "root_url": "/en-gb"}
],
Impact:
This makes it impossible to build a reliable language/country switcher using localization.available_countries — the root_url property is unusable for any language other than the currently active one.
Environment:
- Reproduced on a live Shopify storefront with multiple market/language configurations
- Active locale at time of render:
en-gb
- All other locales inherit the same
/en-gb root URL
Description
shop_locale.root_urlinside alocalization.available_countries/country.available_languagesloop does not return the root URL for that language — it returns the root URL of the currently active locale for every iteration.Liquid template:
{%- for country in localization.available_countries -%} "{{ country.iso_code }}": [ {%- for lang in country.available_languages -%} { "iso_code": "{{ lang.iso_code }}", "endonym_name": {{ lang.endonym_name | json }}, "root_url": {{ lang.root_url | json }} }{% unless forloop.last %},{% endunless %} {%- endfor -%} ]{% unless forloop.last %},{% endunless %} {%- endfor -%}Resulting output (truncated):
Every
root_urlis/en-gb— the path of the active session locale — regardless of which country or language is being iterated.Expected behavior:
lang.root_urlshould return the root URL path for that specific language, e.g.:Impact:
This makes it impossible to build a reliable language/country switcher using
localization.available_countries— theroot_urlproperty is unusable for any language other than the currently active one.Environment:
en-gb/en-gbroot URL