Determine the current locale from JavaScript (ScriptTag)

Shopify Partner
3 0 2



We're trying to update our app (which is completely loaded via a ScriptTag, no liquid templating required) to support multiple locales on Shopify. The problem is, we can't seem to find any reference to the current locale on the site. I checked the Shopify window object, but it's seemingly absent.


How can we detect the current locale that Shopify is using? I suppose we could fall back to navigator.language, but I want to make sure we're using the same language that Shopify actively is.



Replies 6 (6)
Shopify Partner
1 0 0

I have the same issue. Any ideas?

2 0 0

did you find a solution for this problem?

Shopify Partner
3 0 2
Click to expand...
Unfortunately, no. We worked around it by just using the locale from the browser. It’s not perfect, but Shopify didn’t give us much of a choice.
2 0 0

Thank you.

There is another option that I have used maybe it can help you also: I have picked the selected language from the languages dropdown list and according to this i have manipulated the content by javascript.

1 0 0

I am not sure if something changed or not, but I have noticed that it can be daunting to find some JavaScript objects/methods.

Looking around I found a few ways that may help anyone trying to get the locale.

If you have any access to the Liquid templates you can inject and grab this from anywhere

{{ shop.locale }}

A common use case is (and most Shopify themes have had this from what I seen):

<html lang="{{ shop.locale }}">

Also looking around in the DOM (could not find it in my theme and I am assuming Shopify may be injecting this, but you can grab this script tag and grab that locale value)

<script id="shopify-features" type="application/json">{

However the easiest way within Shopify and probably should have just lead with.. It is part of the Shopify global object.



I did cross reference this with some other languages and it does give the nn-NN codes where multiple variations exist.




For English adding the -** part would fall into the developers hands.

Shopify Partner
826 21 142


Is this Shopify.locale a must-have object in js? I can't find it on one of my client stores

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