Re: Changing the country does not work when having language as subfolder

Changing the country does not work when having language as subfolder

st_consult
Shopify Partner
17 1 7

I have issues when switching the country in combination with language subfolders:

 

Assume I have Canada (CA) as currently selected country and French as language. Then my URL looks like this: https://my-shop.myshopify.com/frand in the background the Liquid variable `localization.country.iso_code` has the value `CA`. When I set the URL parameter to switch the country, like in https://my-shop.myshopify.com/fr?country=BE, the page reloads and correctly shows the new country and currency. But as soon as I don't use the parameter again (like this: https://my-shop.myshopify.com/fr), Canada is shown again. There is no permanent assignment.

 

This behavior is only shown in a productive/merchant shop and only if I have a language subfolder. In my dev environment or in production with no subfolder (like https://my-shop.myshopify.com), the new country is permanently assigned as soon as I used it once as URL parameter.

I switched to the form-based way of letting the user select the country:

          {% form 'localization'
            , id: 'HeaderCountryForm'
            , class: 'localization-form'
          %}
            <select name="country_code">
              {%- for country in localization.available_countries -%}
                <option
                  value="{{ country.iso_code }}"
                  {%- if country.iso_code == localization.country.iso_code %}
                  selected{% endif %}>
                  {{ country.name }} ({{ country.currency.symbol }})
                </option>
              {%- endfor -%}
            </select>
            <button type="submit">Update Country</button>
          {% endform %}

and even there, in my production environment, when pressing the 'Update Country' button and I have a language subfolder in place, the language doesn't update.

 

I used the browser developer tools to check the network traffic:
In my dev environment, the response header of the page contains a field `Content-Language: fr` whereas in my prod environment, the field contains `Content-Language: fr-BE`. So the response seems to be wrong here.
I also see some `preloads.js?locale=fr-BE` in dev (good) which is `preloads.js?locale=fr-CA` in prod (not good).

Could someone from the Shopify developers please have a look into this?

Reply 1 (1)

st_consult
Shopify Partner
17 1 7

Ping 😉