user3751923
user3751923

Reputation:

How to get LCID String form LCID in JavaSscript?

I'm developing for CRM 2011 and 2013, and I want to get the user's language. The only command I can execute is Xrm.Page.context.getUserLcid(), and it gives the language id, like 1033 for US English. But, I want to have the LCID String, like 'en-US'. Is there a way to get this, in JavaScript? Perhaps a default function in CRM? And is there also a way to get all languages that are installed in CRM?

Upvotes: 3

Views: 2896

Answers (3)

rtur
rtur

Reputation: 165

You can get the language from the variable USER_LANGUAGE_TWO_LETTER_NAME, in CRM2016 at least, probably in older versions too.

From within a WebResource you need to make sure to go up to the top window first, e.g.:

    var root = window.parent;
    while (root.frameElement !== null) {
      root = root.parent;
    }
    var lang = root.USER_LANGUAGE_TWO_LETTER_NAME

Upvotes: 0

Guido Preite
Guido Preite

Reputation: 15128

I created a JavaScript library to handle your requirement (returns the culture name from a decimal lcid value)

The mapping comes from this page: National Language Support (NLS) API Reference (Windows 7)

Practically inside the library there is JSON object with the values and two methods to get them.

You can find more information on my blog:

LCID JavaScript Helper Library

Upvotes: 1

Andrew Butenko
Andrew Butenko

Reputation: 5446

To get the list of installed languages - recheck this article Regarding conversion of Language Code -I believe you will need to write conversion function like:

function GetLocale(languagecode){
if (languagecode == 1033){
return "en-US";
}
else if (languagecode == 1064){
return "ua-UA";
}
else {
return "not found!";
}
}

Upvotes: 0

Related Questions