Why isn't my localization form changing the language on my site?

AbuTamim
Shopify Partner
7 0 1

Hi, 

 

I've been trying to implemented exactly what is been recommended in this url: Multiple Currency and Language Selector , however, the provided script doesn't work and always throw an error of undefined variable. 

So, I tried to make some tweaks utilizing the localization form with Radio Inputs and styling them as a button, however, it doesn't work.

The below code is inserted in the header.liquid file:

  
    <!-- Language Selector -->

  <div class="radio-group">
{% form 'localization' %}

  {% for language in localization.available_languages %}
<input type="radio" id="{{ language.iso_code }}" onclick="this.form.submit()" name="selector" value="{{ language.iso_code }}"
 {%- if language == localization.language %} checked {% endif %}
 >
<label for="{{ language.iso_code }}">{{ language.endonym_name }}</label>
{% endfor %}

{% endform %}
  </div>    
    <!-- Language Selector -->

 

Do you have any idea why the above doesn't work as intended? The form got submitted but the language never changed. 

Moreover, why the above link to shopify Dev doesn't work with their provided script.

Thanks,

Replies 4 (4)

AbuTamim
Shopify Partner
7 0 1

Hi,

 

It will be great if someone gave me at least some hint, I can work that out. 

 

Thanks, 

Store url: https://www.mryelh.com

AbuTamim
Shopify Partner
7 0 1

Looking forward to some solutions for the above issue.

Thanks.

st4lin
Shopify Partner
2 0 0

I have the same problem. I test with currency form https://shopify.dev/api/liquid/tags/deprecated-tags#the-currency-form that is deprecate but it works.

materangai7
Shopify Partner
11 0 0

`/localization` doesn't accept a parameter of "selector". You'd need to use `country_code` or `language_code`