globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 605 forks source link

How to handle if locale folder missing for any module (e.g.) number module ? #886

Open himensuthar opened 4 years ago

himensuthar commented 4 years ago

I am initializing Globalize dynamically, How should I handle if the selected locale's cldr data missing?

locale = $("#selectedLocale").val());

$.ajaxSetup({ async: false });
const likelySubtags = $.getJSON("../../node_modules/cldr-data/supplemental/likelySubtags.json");
const numberingSystems = $.getJSON("../../node_modules/cldr-data/supplemental/numberingSystems.json");
const numbers = $.getJSON("../../node_modules/cldr-numbers-full/main/" + locale+ "/numbers.json");

 Globalize.load(likelySubtags.responseJSON);
 Globalize.load(numberingSystems.responseJSON);
 Globalize.load(numbers.responseJSON);
 $.ajaxSetup({ async: true });

 Globalize.locale(locale);