Get current locale url and redirect to new locale url

New Member
2 0 0



We are translating our store using the GraphiQL API ( Now that we have our content translated we are willing to develop our own language switcher and redirect users accordingly when they use it.


So if our site is and the user clicks on French in the language switcher we want the page to redirect to to We can do this using pure javascript but is there a way to detect current locale url and get the rest of locale urls in liquid? If so, it would be a better solution than having to parse and deal with the actual url in a javascript string.


The "problem" is not dealing with but with Also taking into account that the main active language of the store doesn't have the /lang subdirectory. This is why it would be nice if there is already a liquid workaround to access to the locales urls.


Thank you.



Replies 4 (4)
Shopify Staff
Shopify Staff
537 103 113

@supermanoul You can retrieve the shops locales from Liquid but using JS to get the customer is the correct way to go. 

Vix | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit or the Shopify Web Design and Development Blog

New Member
1 0 2

The way I see it I already have the value in shop_locale. Using JS to retrieve something I already have seems counterproductive to me. Why is it then the correct way to go?

Shopify Partner
142 5 34


  const urls = {
  {% for locale in shop.published_locales %}
    {{ iso_code }}: {{ locale.root_url }}
  {% endfor %}


 Active locale is: 


const activeLocale = '{{ request.locale.iso_code }}';



Public Apps | Theme customization & App development
 - Was my reply useful? Like it to let me know!
 - Did I answer your question? Please mark as Accepted Solution.
 - Need more help? Contact us.

Shopify Partner
693 16 101


Why not just use Shopify.locale for js but use 

const activeLocale = '{{ request.locale.iso_code }}';


BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview