public onChange(args: any): void {
if(this.loadedCultures.indexOf(args.value) === -1) {
this.loadedCultures.push(args.value);
this.loadCultureFiles(args.value);
}
setCulture(args.value);
}
//Function for loading locale files based on culture name
loadLocaleFiles(name: string) {
// load local files
let localeajax: Ajax = new Ajax('./node_modules/@syncfusion/ej2-locale/src/' + name + '.json', 'GET', false);
localeajax.onSuccess = (value: string) => {
L10n.load(JSON.parse(value));
}
localeajax.send();
}
// Function for loading the culture files from cldr-data.
loadCultureFiles(name: string) {
this.loadLocaleFiles(name);
// since default culture files are preloaded no need to load the files again.
if(name === 'en-US'){
return;
}
let files: string[] = ['ca-gregorian.json', 'numbers.json', 'timeZoneNames.json', 'numberingSystems.json'];
let loadCulture = function (prop: any) {
let val: string, ajax: Ajax;
if (prop === files.length - 1) {
ajax = new Ajax('./node_modules/cldr-data/supplemental/' + files[prop], 'GET', false);
} else {
ajax = new Ajax('./node_modules/cldr-data/main/' + name + '/' + files[prop], 'GET', false);
}
ajax.onSuccess = function (value: any) {
val = value;
loadCldr(JSON.parse(val));
};
ajax.send();
};
for (let prop = 0; prop < files.length; prop++) {
loadCulture(prop);
}
} |