igniteui-react-core
Version:
Ignite UI React Core.
97 lines (96 loc) • 3.29 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { Base, markType, NotSupportedException } from "./type";
import { stringIsNullOrEmpty } from "./string";
import { stringFormat1 } from "./stringExtended";
/**
* @hidden
*/
export let Localization = /*@__PURE__*/ (() => {
class Localization extends Base {
static register(a, b) {
if (Localization.c == null) {
Localization.c = {};
}
Localization.c[a] = b;
}
static getString(a, b, ...c) {
let d;
if (Localization.b != null) {
d = Localization.b(a, b);
}
else {
let e = null;
if (Localization.c != null) {
e = Localization.c[a];
}
if (e != null) {
d = (e[b]);
}
else {
throw new NotSupportedException(1, "string override must be specified for localization");
}
}
if (stringIsNullOrEmpty(d)) {
d = "";
}
else if (c != null && c.length > 0) {
d = stringFormat1(d, ...c);
}
return d;
}
static setString(a, b, c) {
let d = null;
if (Localization.c != null) {
d = Localization.c[a];
}
if (d != null) {
d[b] = c;
}
else {
throw new NotSupportedException(1, "locale set for " + a + " was not loaded.");
}
}
static isRegistered(a) {
return (Localization.c && Localization.c[a] !== undefined);
}
static d(a) {
let b = (navigator.language ? navigator.language.toLowerCase() : "");
let c = a + "-";
while (true) {
if (Localization.isRegistered(c + b)) {
return b;
}
let d = Localization.e(b);
if (d != null && Localization.isRegistered(c + d)) {
return d;
}
let e = b.lastIndexOf('-');
if (e <= 0) {
break;
}
b = b.substr(0, e);
}
return "en";
}
static e(a) {
switch (a) {
case "zh-hk":
case "zh-tw":
case "zh-mo": return "zh-Hant";
case "zh-cn":
case "zh-sg":
case "zh": return "zh-Hans";
}
return null;
}
}
Localization.$t = /*@__PURE__*/ markType(Localization, 'Localization');
Localization.b = null;
Localization.c = null;
return Localization;
})();