Skip to content

shop_locale.root_url always returns current session's locale path instead of language-specific URL #2076

Description

@wehrmarc

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions