web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

LCID JavaScript Helper Library

Guido Preite Profile Picture Guido Preite 54,086 Moderator

Xrm.Pageobject provides two methods to get the relevant language used inside Dynamics CRM:

  • Xrm.Page.context.getUserLcid() - returns the LCID value that represents the Microsoft Dynamics CRM Language Pack that is the user selected as their preferred language
  • Xrm.Page.context.getOrgLcid() - returns the LCID value that represents the base language for the organization

The value returned is the lcid decimal value, there is not a built-in function to return the culture name ("en-US" for LCID 1033) or the language region ("German (Germany)" for LCID 1031).

The attached library provides an easy way to get the culture name and the language region from the decimal lcid value, it contains two methods:

  • LCIDUtils.getCultureName(lcid)
    returns a string with the culture name of the selected lcid value

    var userLcid = Xrm.Page.context.getUserLcid();
    var userCultureName = LCIDUtils.getCultureName(userLcid);
    alert("User Culture name is: " + userCultureName);
  • LCIDUtils.getLanguageRegion(lcid)
    returns a string with the language region of the selected lcid value

    var orgLcid = Xrm.Page.context.getOrgLcid();
    var orgLanguageRegion = LCIDUtils.getLanguageRegion(orgLcid);
    alert("Organization Language Region is: " + orgLanguageRegion);

The library can be downloaded from Technet Gallery:
http://gallery.technet.microsoft.com/scriptcenter/LCID-JavaScript-Helper-7cfb0829

Note: The culture name and language region mappings come from this MSDN page: National Language Support (NLS) API Reference (Windows 7)


This was originally posted here.

Comments

*This post is locked for comments