简体   繁体   English

如何在JavaSscript中从LCID获得LCID字符串?

[英]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: 您可以在我的博客上找到更多信息:

LCID JavaScript Helper Library LCID JavaScript帮助器库

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.

相关问题 读取SharePoint分类标准术语库和getDefaultLabel(lcid) - Reading SharePoint Taxonomy Term Store and getDefaultLabel(lcid) 如何在 JavaScript 中将多个选定的图像文件名转换为逗号分隔的字符串? - How to convert multiple selected image filenames to a comma separated string in JavasScript? 如何在 JavaScript 中将字符串转换为脊柱大小写? - How do I convert a string to spinal case in JavasScript? 如何在 JavaScript 中解析一串键/值对,对以逗号分隔? - How to parse a string of key/value pairs in JavasScript, with pairs separated by commas? 如何通过javasscript在ASP DetailsView中获得控制? - how to get control inside ASP DetailsView through javasscript? 多个JavasScript以相同的形式提交 - Multiple JavasScript submits in the same form 使用$&奇数JavasScript字符串替换行为 - Odd JavasScript string replace behavior with $& JavasScript 中是否有用于 Setters 的字符串原型? - Is there any String Prototype for Setters in JavasScript? 如何在Javascript中将对象转换为数组 - how to convert object to array in javasscript 如何使用javascript在一小时内获取数组中最新数据和先前数据之间的差异? - How to get the difference between latest and previous data in an array within one hour using javasscript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM