UNPKG

dap-design-system

Version:

Official design system for the DÁP (dap.gov.hu)

125 lines (124 loc) 4.16 kB
var j = Object.defineProperty; var d = Object.getOwnPropertySymbols; var b = Object.prototype.hasOwnProperty, w = Object.prototype.propertyIsEnumerable; var f = (a, e, t) => e in a ? j(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, n = (a, e) => { for (var t in e || (e = {})) b.call(e, t) && f(a, t, e[t]); if (d) for (var t of d(e)) w.call(e, t) && f(a, t, e[t]); return a; }; var g = (a, e, t) => new Promise((o, s) => { var y = (i) => { try { l(t.next(i)); } catch (c) { s(c); } }, D = (i) => { try { l(t.throw(i)); } catch (c) { s(c); } }, l = (i) => i.done ? o(i.value) : Promise.resolve(i.value).then(y, D); l((t = t.apply(a, e)).next()); }); import "../_virtual/hu.js"; import "../_virtual/en.js"; import "../_virtual/de.js"; import r from "../_virtual/dayjs.min.js"; import x from "../_virtual/customParseFormat.js"; import F from "../_virtual/localeData.js"; import k from "../_virtual/localizedFormat.js"; import v from "../_virtual/weekday.js"; import u from "../node_modules/i18next/dist/esm/i18next.js"; import { t as tt } from "../node_modules/i18next/dist/esm/i18next.js"; import T from "../node_modules/i18next-browser-languagedetector/dist/esm/i18nextBrowserLanguageDetector.js"; import { initLitI18n as E } from "../node_modules/lit-i18n/src/lit-i18n.js"; import { translate as at } from "../node_modules/lit-i18n/src/lit-i18n.js"; import z from "./locales/de.json.js"; import A from "./locales/en.json.js"; import $ from "./locales/hu.json.js"; r.extend(F); r.extend(v); r.extend(k); r.extend(x); const m = "hu", p = () => { let a = document.documentElement.lang || navigator.language || m; return a = a.slice(0, 2), a; }, h = /* @__PURE__ */ new Set(["hu", "en", "de"]); function W(a) { return g(this, null, function* () { const e = a.slice(0, 2); e && (h.has(e) || console.warn( `[DAP Design System] Day.js locale "${e}" is not registered. Date/month/day names will not be localized for this language. Falling back to "${m}" locale for Day.js. To fix this, manually import and register the locale: import 'dayjs/locale/${e}' import { registerDayjsLocale } from 'dap-design-system' registerDayjsLocale('${e}')` ), h.has(e) ? r.locale(e) : r.locale(m)); }); } u.use(T).use(E).init({ fallbackLng: "hu", interpolation: { escapeValue: !1 }, resources: { de: { translation: n({}, z) }, en: { translation: n({}, A) }, hu: { translation: n({}, $) } } }); const L = p(); W(L); u.changeLanguage(L); const C = new MutationObserver(H); C.observe(document.documentElement, { attributes: !0, attributeFilter: ["dir", "lang"] }); function H() { const a = p(); W(a), u.changeLanguage(a); } function R(a) { try { const e = r.locale(); r.locale(a); const o = r.localeData().longDateFormat("LT"); if (r.locale(e), o && o !== "LT") { if (o.includes("A") || o.includes("a")) return "12h"; if (o.includes("H:mm") || o.includes("HH:mm")) return "24h"; if (o.includes("h:mm")) return "12h"; } const s = a.toLowerCase(); return s.startsWith("en") || s.startsWith("us") || s.startsWith("ca") || s.startsWith("au") || s.startsWith("nz") || s.startsWith("ph") || s.startsWith("in") || s.startsWith("pk") || s.startsWith("bd") || s.startsWith("lk") || s.startsWith("np") || s.startsWith("mm") || s.startsWith("my") || s.startsWith("sg") ? "12h" : "24h"; } catch (e) { const t = a.toLowerCase(); return t.startsWith("en") || t.startsWith("us") || t.startsWith("ca") || t.startsWith("au") || t.startsWith("nz") || t.startsWith("ph") || t.startsWith("in") || t.startsWith("pk") || t.startsWith("bd") || t.startsWith("lk") || t.startsWith("np") || t.startsWith("mm") || t.startsWith("my") || t.startsWith("sg") ? "12h" : "24h"; } } function X(a) { const e = a.slice(0, 2); e && (h.add(e), r.locale(e)); } export { R as getTimeFormatPreference, u as i18next, X as registerDayjsLocale, tt as t, at as translate, H as update }; //# sourceMappingURL=localization.js.map