Shopify / Shopify/liquid

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

Open
#2,076 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the implementation of the localization language objects and the tests covering available countries, available languages, and root_url. Reproduce the supplied Liquid loop, then add regression coverage showing each language returns its own root path rather than the active locale’s path.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
localization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.