I'm trying to get the Globalize.js library to work under an ASP.NET MVC 5 application + unobstrusive validation. Specifically, I have most of the libraries and requirements working as per the post https://stackoverflow.com/a/25289555/1838819. However, when validation actually kicks in on an input
tag of type="text"
but contains a decimal number, I get the following error;
Uncaught Error: E_MISSING_BUNDLE: {"locale":"en"}
at createError (cldr.js:339)
at validate (cldr.js:355)
at Cldr.main (cldr.js:669)
at numberNumberingSystem (number.js:450)
at numberPattern (number.js:1325)
at Function.Globalize.numberParser.Globalize.numberParser (number.js:1429)
at Function.Globalize.parseNumber.Globalize.parseNumber (number.js:1474)
at a.validator.methods.number (jquery.validate.globalize.min.js:1)
at a.validator.check (jquery.validate.min.js:4)
at a.validator.checkForm (jquery.validate.min.js:4)
I'm loading and configuring the library via;
$.when($.get("/Scripts/cldr/supplemental/likelySubtags.json"))
.done(function(result) {
Globalize.load(result);
Globalize.locale("en");
});
Which works and runs through fine until validation is attempted via;
$.validator.unobtrusive.parse(_form);
_form.validate();
if (_form.valid()) { // ** error thrown here
_uiModalConfirmForm.modal('toggle');
}
I'm nearly sure that I'm missing a load
reference to locale/en.json
or something very similar but finding that resource is seemingly next to impossible. The documentation for cldr (what Globalize currently uses as it's main source of localized data), is...self referential at best and quite frustrating to navigate. There are no specific NuGet packages for this either that I can find.
The documentation that I can find says that the resource should be compiled. Looking at the documentation for that compiler links back to the Gloablize documentation and further goes on about spinning up a test server, installing Node Package Manger or Bower and installing from there. Which...seems like overkill when all I want is a file. I haven't yet gone down this road as I'm hoping there's an easier, quicker method to locate the needed file.
Any help on actually configuring the resources for this library in Visual studio would be greatly appreciated.
- CLDR-core: https://github.com/unicode-cldr/cldr-core
- Globalize doc: https://github.com/globalizejs/globalize/blob/master/README.md
- likelySubtags.json (weirdly difficult to find): https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/likelySubtags.json