Determine the current locale from JavaScript (ScriptTag)

lsapan
Shopify Partner
3 0 2

Hello,

 

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.

 

Thanks!

XGen
Shopify Partner
1 0 0

I have the same issue. Any ideas?

0 Likes
ilanush
New Member
2 0 0

did you find a solution for this problem?

0 Likes
lsapan
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.
0 Likes
ilanush
New Member
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.

0 Likes