@dialpad/dialtone
Version:
Dialpad's Dialtone design system monorepo
75 lines (74 loc) • 1.94 kB
JavaScript
import { RawBundleSource as l, LocaleManager as a, useI18N as o } from "@dialpad/i18n-vue2";
import c from "./en-US.js";
import n from "./zh-CN.js";
import i from "./nl-NL.js";
import u from "./fr-FR.js";
import m from "./de-DE.js";
import f from "./it-IT.js";
import p from "./ja-JP.js";
import d from "./pt-BR.js";
import N from "./ru-RU.js";
import h from "./es-LA.js";
const e = "dialtone";
class t {
constructor(r = "en-US") {
if (typeof t.instance == "object")
return t.instance;
this._locale = r, this._allowedLocales = {
ENGLISH: "en-US",
CHINESE: "zh-CN",
DUTCH: "nl-NL",
FRENCH: "fr-FR",
GERMAN: "de-DE",
ITALIAN: "it-IT",
JAPANESE: "ja-JP",
PORTUGUESE: "pt-BR",
RUSSIAN: "ru-RU",
SPANISH: "es-LA"
};
const s = new l({
resources: l.builtResources([
["en-US", e, c],
["zh-CN", e, n],
["nl-NL", e, i],
["fr-FR", e, u],
["de-DE", e, m],
["it-IT", e, f],
["ja-JP", e, p],
["pt-BR", e, d],
["ru-RU", e, N],
["es-LA", e, h]
])
});
return new a({
bundleSource: s,
allowedLocales: Object.values(this.allowedLocales),
fallbackLocale: r,
preferredLocale: r,
namespaces: [e]
}).install(e), t.instance = this, this;
}
$t(...r) {
return o(e).$t(...r);
}
$ta(...r) {
return o(e).$ta(...r);
}
get currentLocale() {
return this._locale;
}
set currentLocale(r) {
if (r !== this._locale) {
if (!Object.values(this.allowedLocales).includes(r))
throw new Error(`Locale ${r} is not allowed, please use one of the following: ${Object.values(this.allowedLocales).join(", ")}`);
this._locale = r, o(e).setI18N({ preferredLocale: r }, e);
}
}
get allowedLocales() {
return this._allowedLocales;
}
}
export {
t as DialtoneLocalization
};
//# sourceMappingURL=index.js.map