[英]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. 我正在开发CRM 2011和2013,并且想要获得用户的语言。 The only command I can execute is Xrm.Page.context.getUserLcid(), and it gives the language id, like 1033 for US English.
我唯一可以执行的命令是Xrm.Page.context.getUserLcid(),它提供语言ID,例如美国英语1033。 But, I want to have the LCID String, like 'en-US'.
但是,我想使用LCID字符串,例如“ en-US”。 Is there a way to get this, in JavaScript?
有没有办法用JavaScript做到这一点? Perhaps a default function in CRM?
也许是CRM中的默认功能? And is there also a way to get all languages that are installed in CRM?
还有没有一种方法可以获取CRM中安装的所有语言?
I created a JavaScript library to handle your requirement (returns the culture name from a decimal lcid value) 我创建了一个JavaScript库来满足您的要求(从十进制lcid值返回区域性名称)
The mapping comes from this page: National Language Support (NLS) API Reference (Windows 7) 映射来自此页面: 国家语言支持(NLS)API参考 (Windows 7)
Practically inside the library there is JSON object with the values and two methods to get them. 实际上,库内部有一个带有值的JSON对象和两种获取它们的方法。
You can find more information on my blog: 您可以在我的博客上找到更多信息:
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!";
}
}
You can get the language from the variable USER_LANGUAGE_TWO_LETTER_NAME
, in CRM2016 at least, probably in older versions too. 您至少可以从
USER_LANGUAGE_TWO_LETTER_NAME
中的变量USER_LANGUAGE_TWO_LETTER_NAME
获取语言,也许也可以在较早的版本中获得。
From within a WebResource you need to make sure to go up to the top window first, eg: 在WebResource中,您需要确保首先进入顶部窗口,例如:
var root = window.parent;
while (root.frameElement !== null) {
root = root.parent;
}
var lang = root.USER_LANGUAGE_TWO_LETTER_NAME
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.