Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to get the name of the current UI language in a javascript file. I know the following trick:

SP.Res.lcid

But that gets the the LCID. What I really need is the two-letter iso name (like 'en', 'fr', etc)

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

You can create a JS object and fetch the values using the LCID:

var CultureNames = { 1033:"en", 1036:"fr" };//Store it in a utility file somewhere.

var currentCultureName = CultureNames[SP.Res.lcid]; //will return 'en' if current culture is english.
share|improve this answer
    
To avoid having to keep a utility file around, I eventually used javascript to read the 'lang' attribute of the 'html'-tag. With a substring I can get 'en' out of 'en-us'. The reason I did this is that I have another library which keeps languages but in the two-letter format. It's a bit silly to keep two such repositories. Now I just hope that SharePoint will continue to mention that attribute. –  Spongeroberto Squarepantalones Nov 2 '12 at 13:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.