I want to know if there is somewhere a defined mapping from the Microsoft CultureInfo (which could be looked up here MS-LCID (Windows Language Code ID)) to the Unicode cldr Language Code.
I am currently using jQuery and globalize.js to validate the user input of our asp.net-core site. Our implementation looks similar to this example validationScript.cshtml (asp.net-core code)
We only had to change the script section like this:
<script type="text/javascript">
var culture = "@System.Globalization.CultureInfo.CurrentUICulture";
$.when(
$.get("/lib/newTestLocalization/cldr-core/supplemental/likelySubtags.json"),
$.get("/lib/newTestLocalization/cldr-numbers-modern/main/" + culture + "/numbers.json"),
$.get("/lib/newTestLocalization/cldr-core/supplemental/numberingSystems.json"),
$.get("/lib/newTestLocalization/cldr-core/supplemental/timeData.json"),
$.get("/lib/newTestLocalization/cldr-core/supplemental/weekData.json")
).then(function() {
console.log("sucessfully loaded cldr data");
// Normalize $.get results, we only need the JSON, not the request statuses.
return [].slice.apply(arguments, [0]).map(function(result) {
return result[0];
});
},
function() { console.log("Error loading cldr data!"); }
).then(Globalize.load, function ()
{ console.log("Error loading cldr data!"); }
).then(function () {
Globalize.locale(culture);
console.log("finished Globalize.locale !");
});
</script>
If i switch the site to one of the following :
- CultureInfo("zh-CHS")
- CultureInfo("zh-CHT")
- CultureInfo("de-DE")
- CultureInfo("ja-JP")
- CultureInfo("en-US")
the globalize.js is not working because there is no cldr folder for any of the language IDs above.
I looked it up here cldr-numbers-full/main/ (JSON data for CLDR 33 release), but could not find any of the IDs above.
So my question is: "Is there somewhere a defined mapping from MS-LCIDs to cldr-IDs, if this is a right question to ask?
And my second question is: what is the current standard/best-practice to use?
Finally found the solution here
At the end of _ValidationScriptsPartial.cshtml add the following code.