@akinon/akilocale
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -1,4 +0,4 @@ | ||
import type { Akii18n } from './types'; | ||
export declare const AKII18N_LNG = "akii18nLng"; | ||
export declare const akii18n: Akii18n; | ||
import type { AkilocaleProps } from './types'; | ||
export declare const AKILOCALE_STORAGE_KEY = "akiLocaleLanguage"; | ||
export declare const Akilocale: AkilocaleProps; | ||
//# sourceMappingURL=index.d.ts.map |
import { i as g } from "./i18next-94da8c9f.js"; | ||
const c = "akii18nLng", u = { | ||
createInstance: (n) => { | ||
const { debug: o, fallbackLng: l, translations: t } = n, r = Object.keys(t).reduce((a, s) => (a[s] = { | ||
const c = "akiLocaleLanguage", L = { | ||
createInstance: (e) => { | ||
const { debug: o, fallbackLng: l, translations: t } = e, r = Object.keys(t).reduce((a, s) => (a[s] = { | ||
translation: t[s] | ||
}, a), {}), e = g.createInstance( | ||
}, a), {}), n = g.createInstance( | ||
{ | ||
@@ -18,13 +18,13 @@ debug: o, | ||
return { | ||
lng: e.language, | ||
t: e.t | ||
lng: n.language, | ||
t: n.t | ||
}; | ||
}, | ||
setLng: (n) => { | ||
localStorage.setItem(c, n); | ||
setLanguage: (e) => { | ||
localStorage.setItem(c, e); | ||
} | ||
}; | ||
export { | ||
c as AKII18N_LNG, | ||
u as akii18n | ||
c as AKILOCALE_STORAGE_KEY, | ||
L as Akilocale | ||
}; |
import i18n from 'i18next'; | ||
import { useTranslation, Trans } from 'react-i18next'; | ||
export { useTranslation, Trans, i18n }; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
export { i18n, Trans, useTranslation }; | ||
//# sourceMappingURL=react.d.ts.map |
1188
dist/react.js
@@ -19,545 +19,29 @@ import { i as He } from "./i18next-94da8c9f.js"; | ||
} | ||
var U = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; | ||
function Oe(t) { | ||
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; | ||
} | ||
var Xe = { | ||
area: !0, | ||
base: !0, | ||
br: !0, | ||
col: !0, | ||
embed: !0, | ||
hr: !0, | ||
img: !0, | ||
input: !0, | ||
link: !0, | ||
meta: !0, | ||
param: !0, | ||
source: !0, | ||
track: !0, | ||
wbr: !0 | ||
}; | ||
const ze = /* @__PURE__ */ Oe(Xe); | ||
var Ke = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g; | ||
function ae(t) { | ||
var e = { type: "tag", name: "", voidElement: !1, attrs: {}, children: [] }, n = t.match(/<\/?([^\s]+?)[/\s>]/); | ||
if (n && (e.name = n[1], (ze[n[1]] || t.charAt(t.length - 2) === "/") && (e.voidElement = !0), e.name.startsWith("!--"))) { | ||
var r = t.indexOf("-->"); | ||
return { type: "comment", comment: r !== -1 ? t.slice(4, r) : "" }; | ||
} | ||
for (var s = new RegExp(Ke), i = null; (i = s.exec(t)) !== null; ) | ||
if (i[0].trim()) | ||
if (i[1]) { | ||
var f = i[1].trim(), u = [f, ""]; | ||
f.indexOf("=") > -1 && (u = f.split("=")), e.attrs[u[0]] = u[1], s.lastIndex--; | ||
} else | ||
i[2] && (e.attrs[i[2]] = i[3].trim().substring(1, i[3].length - 1)); | ||
return e; | ||
} | ||
var Ve = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g, We = /^\s*$/, Ge = /* @__PURE__ */ Object.create(null); | ||
function Pe(t, e) { | ||
switch (e.type) { | ||
case "text": | ||
return t + e.content; | ||
case "tag": | ||
return t += "<" + e.name + (e.attrs ? function(n) { | ||
var r = []; | ||
for (var s in n) | ||
r.push(s + '="' + n[s] + '"'); | ||
return r.length ? " " + r.join(" ") : ""; | ||
}(e.attrs) : "") + (e.voidElement ? "/>" : ">"), e.voidElement ? t : t + e.children.reduce(Pe, "") + "</" + e.name + ">"; | ||
case "comment": | ||
return t + "<!--" + e.comment + "-->"; | ||
} | ||
} | ||
var Je = { parse: function(t, e) { | ||
e || (e = {}), e.components || (e.components = Ge); | ||
var n, r = [], s = [], i = -1, f = !1; | ||
if (t.indexOf("<") !== 0) { | ||
var u = t.indexOf("<"); | ||
r.push({ type: "text", content: u === -1 ? t : t.substring(0, u) }); | ||
} | ||
return t.replace(Ve, function(c, l) { | ||
if (f) { | ||
if (c !== "</" + n.name + ">") | ||
return; | ||
f = !1; | ||
} | ||
var d, y = c.charAt(1) !== "/", P = c.startsWith("<!--"), b = l + c.length, j = t.charAt(b); | ||
if (P) { | ||
var h = ae(c); | ||
return i < 0 ? (r.push(h), r) : ((d = s[i]).children.push(h), r); | ||
} | ||
if (y && (i++, (n = ae(c)).type === "tag" && e.components[n.name] && (n.type = "component", f = !0), n.voidElement || f || !j || j === "<" || n.children.push({ type: "text", content: t.slice(b, t.indexOf("<", b)) }), i === 0 && r.push(n), (d = s[i - 1]) && d.children.push(n), s[i] = n), (!y || n.voidElement) && (i > -1 && (n.voidElement || n.name === c.slice(2, -1)) && (i--, n = i === -1 ? r : s[i]), !f && j !== "<" && j)) { | ||
d = i === -1 ? r : s[i].children; | ||
var v = t.indexOf("<", b), w = t.slice(b, v === -1 ? void 0 : v); | ||
We.test(w) && (w = " "), (v > -1 && i + d.length >= 0 || w !== " ") && d.push({ type: "text", content: w }); | ||
} | ||
}), r; | ||
}, stringify: function(t) { | ||
return t.reduce(function(e, n) { | ||
return e + Pe("", n); | ||
}, ""); | ||
} }; | ||
function W() { | ||
if (console && console.warn) { | ||
for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++) | ||
e[n] = arguments[n]; | ||
typeof e[0] == "string" && (e[0] = `react-i18next:: ${e[0]}`), console.warn(...e); | ||
} | ||
} | ||
const fe = {}; | ||
function J() { | ||
for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++) | ||
e[n] = arguments[n]; | ||
typeof e[0] == "string" && fe[e[0]] || (typeof e[0] == "string" && (fe[e[0]] = /* @__PURE__ */ new Date()), W(...e)); | ||
} | ||
const Ee = (t, e) => () => { | ||
if (t.isInitialized) | ||
e(); | ||
else { | ||
const n = () => { | ||
setTimeout(() => { | ||
t.off("initialized", n); | ||
}, 0), e(); | ||
}; | ||
t.on("initialized", n); | ||
} | ||
}; | ||
function ue(t, e, n) { | ||
t.loadNamespaces(e, Ee(t, n)); | ||
} | ||
function ce(t, e, n, r) { | ||
typeof n == "string" && (n = [n]), n.forEach((s) => { | ||
t.options.ns.indexOf(s) < 0 && t.options.ns.push(s); | ||
}), t.loadLanguages(e, Ee(t, r)); | ||
} | ||
function Qe(t, e) { | ||
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; | ||
const r = e.languages[0], s = e.options ? e.options.fallbackLng : !1, i = e.languages[e.languages.length - 1]; | ||
if (r.toLowerCase() === "cimode") | ||
return !0; | ||
const f = (u, c) => { | ||
const l = e.services.backendConnector.state[`${u}|${c}`]; | ||
return l === -1 || l === 2; | ||
}; | ||
return n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && e.services.backendConnector.backend && e.isLanguageChangingTo && !f(e.isLanguageChangingTo, t) ? !1 : !!(e.hasResourceBundle(r, t) || !e.services.backendConnector.backend || e.options.resources && !e.options.partialBundledLanguages || f(r, t) && (!s || f(i, t))); | ||
} | ||
function Ye(t, e) { | ||
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; | ||
return !e.languages || !e.languages.length ? (J("i18n.languages were undefined or empty", e.languages), !0) : e.options.ignoreJSONStructure !== void 0 ? e.hasLoadedNamespace(t, { | ||
lng: n.lng, | ||
precheck: (s, i) => { | ||
if (n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && s.services.backendConnector.backend && s.isLanguageChangingTo && !i(s.isLanguageChangingTo, t)) | ||
return !1; | ||
} | ||
}) : Qe(t, e, n); | ||
} | ||
const Ze = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g, et = { | ||
"&": "&", | ||
"&": "&", | ||
"<": "<", | ||
"<": "<", | ||
">": ">", | ||
">": ">", | ||
"'": "'", | ||
"'": "'", | ||
""": '"', | ||
""": '"', | ||
" ": " ", | ||
" ": " ", | ||
"©": "©", | ||
"©": "©", | ||
"®": "®", | ||
"®": "®", | ||
"…": "…", | ||
"…": "…", | ||
"/": "/", | ||
"/": "/" | ||
}, tt = (t) => et[t], nt = (t) => t.replace(Ze, tt); | ||
let ne = { | ||
bindI18n: "languageChanged", | ||
bindI18nStore: "", | ||
transEmptyNodeValue: "", | ||
transSupportBasicHtmlNodes: !0, | ||
transWrapTextNodes: "", | ||
transKeepBasicHtmlNodesFor: ["br", "strong", "i", "p"], | ||
useSuspense: !0, | ||
unescape: nt | ||
}; | ||
function rt() { | ||
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; | ||
ne = { | ||
...ne, | ||
...t | ||
}; | ||
} | ||
function Te() { | ||
return ne; | ||
} | ||
let je; | ||
function ot(t) { | ||
je = t; | ||
} | ||
function se() { | ||
return je; | ||
} | ||
function Y(t, e) { | ||
if (!t) | ||
return !1; | ||
const n = t.props ? t.props.children : t.children; | ||
return e ? n.length > 0 : !!n; | ||
} | ||
function Z(t) { | ||
if (!t) | ||
return []; | ||
const e = t.props ? t.props.children : t.children; | ||
return t.props && t.props.i18nIsDynamicList ? F(e) : e; | ||
} | ||
function it(t) { | ||
return Object.prototype.toString.call(t) !== "[object Array]" ? !1 : t.every((e) => G(e)); | ||
} | ||
function F(t) { | ||
return Array.isArray(t) ? t : [t]; | ||
} | ||
function st(t, e) { | ||
const n = { | ||
...e | ||
}; | ||
return n.props = Object.assign(t.props, e.props), n; | ||
} | ||
function Ae(t, e) { | ||
if (!t) | ||
return ""; | ||
let n = ""; | ||
const r = F(t), s = e.transSupportBasicHtmlNodes && e.transKeepBasicHtmlNodesFor ? e.transKeepBasicHtmlNodesFor : []; | ||
return r.forEach((i, f) => { | ||
if (typeof i == "string") | ||
n += `${i}`; | ||
else if (G(i)) { | ||
const u = Object.keys(i.props).length, c = s.indexOf(i.type) > -1, l = i.props.children; | ||
if (!l && c && u === 0) | ||
n += `<${i.type}/>`; | ||
else if (!l && (!c || u !== 0)) | ||
n += `<${f}></${f}>`; | ||
else if (i.props.i18nIsDynamicList) | ||
n += `<${f}></${f}>`; | ||
else if (c && u === 1 && typeof l == "string") | ||
n += `<${i.type}>${l}</${i.type}>`; | ||
else { | ||
const d = Ae(l, e); | ||
n += `<${f}>${d}</${f}>`; | ||
} | ||
} else if (i === null) | ||
W("Trans: the passed in value is invalid - seems you passed in a null child."); | ||
else if (typeof i == "object") { | ||
const { | ||
format: u, | ||
...c | ||
} = i, l = Object.keys(c); | ||
if (l.length === 1) { | ||
const d = u ? `${l[0]}, ${u}` : l[0]; | ||
n += `{{${d}}}`; | ||
} else | ||
W("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.", i); | ||
} else | ||
W("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.", i); | ||
}), n; | ||
} | ||
function at(t, e, n, r, s, i) { | ||
if (e === "") | ||
return []; | ||
const f = r.transKeepBasicHtmlNodesFor || [], u = e && new RegExp(f.map((v) => `<${v}`).join("|")).test(e); | ||
if (!t && !u && !i) | ||
return [e]; | ||
const c = {}; | ||
function l(v) { | ||
F(v).forEach((m) => { | ||
typeof m != "string" && (Y(m) ? l(Z(m)) : typeof m == "object" && !G(m) && Object.assign(c, m)); | ||
}); | ||
} | ||
l(t); | ||
const d = Je.parse(`<0>${e}</0>`), y = { | ||
...c, | ||
...s | ||
}; | ||
function P(v, w, m) { | ||
const S = Z(v), T = j(S, w.children, m); | ||
return it(S) && T.length === 0 || v.props && v.props.i18nIsDynamicList ? S : T; | ||
} | ||
function b(v, w, m, S, T) { | ||
v.dummy ? (v.children = w, m.push($e(v, { | ||
key: S | ||
}, T ? void 0 : w))) : m.push(...Fe.map([v], (O) => { | ||
const p = { | ||
...O.props | ||
}; | ||
return delete p.i18nIsDynamicList, L(O.type, { | ||
...p, | ||
key: S, | ||
ref: O.ref | ||
}, T ? null : w); | ||
})); | ||
} | ||
function j(v, w, m) { | ||
const S = F(v); | ||
return F(w).reduce((O, p, x) => { | ||
const D = p.children && p.children[0] && p.children[0].content && n.services.interpolator.interpolate(p.children[0].content, y, n.language); | ||
if (p.type === "tag") { | ||
let _ = S[parseInt(p.name, 10)]; | ||
m.length === 1 && !_ && (_ = m[0][p.name]), _ || (_ = {}); | ||
const B = Object.keys(p.attrs).length !== 0 ? st({ | ||
props: p.attrs | ||
}, _) : _, R = G(B), C = R && Y(p, !0) && !p.voidElement, I = u && typeof B == "object" && B.dummy && !R, M = typeof t == "object" && t !== null && Object.hasOwnProperty.call(t, p.name); | ||
if (typeof B == "string") { | ||
const o = n.services.interpolator.interpolate(B, y, n.language); | ||
O.push(o); | ||
} else if (Y(B) || C) { | ||
const o = P(B, p, m); | ||
b(B, o, O, x); | ||
} else if (I) { | ||
const o = j(S, p.children, m); | ||
b(B, o, O, x); | ||
} else if (Number.isNaN(parseFloat(p.name))) | ||
if (M) { | ||
const o = P(B, p, m); | ||
b(B, o, O, x, p.voidElement); | ||
} else if (r.transSupportBasicHtmlNodes && f.indexOf(p.name) > -1) | ||
if (p.voidElement) | ||
O.push(L(p.name, { | ||
key: `${p.name}-${x}` | ||
})); | ||
else { | ||
const o = j(S, p.children, m); | ||
O.push(L(p.name, { | ||
key: `${p.name}-${x}` | ||
}, o)); | ||
} | ||
else if (p.voidElement) | ||
O.push(`<${p.name} />`); | ||
else { | ||
const o = j(S, p.children, m); | ||
O.push(`<${p.name}>${o}</${p.name}>`); | ||
} | ||
else if (typeof B == "object" && !R) { | ||
const o = p.children[0] ? D : null; | ||
o && O.push(o); | ||
} else | ||
b(B, D, O, x, p.children.length !== 1 || !D); | ||
} else if (p.type === "text") { | ||
const _ = r.transWrapTextNodes, B = i ? r.unescape(n.services.interpolator.interpolate(p.content, y, n.language)) : n.services.interpolator.interpolate(p.content, y, n.language); | ||
_ ? O.push(L(_, { | ||
key: `${p.name}-${x}` | ||
}, B)) : O.push(B); | ||
} | ||
return O; | ||
}, []); | ||
} | ||
const h = j([{ | ||
dummy: !0, | ||
children: t || [] | ||
}], d, F(t || [])); | ||
return Z(h[0]); | ||
} | ||
function ft(t) { | ||
let { | ||
children: e, | ||
count: n, | ||
parent: r, | ||
i18nKey: s, | ||
context: i, | ||
tOptions: f = {}, | ||
values: u, | ||
defaults: c, | ||
components: l, | ||
ns: d, | ||
i18n: y, | ||
t: P, | ||
shouldUnescape: b, | ||
...j | ||
} = t; | ||
const h = y || se(); | ||
if (!h) | ||
return J("You will need to pass in an i18next instance by using i18nextReactModule"), e; | ||
const v = P || h.t.bind(h) || ((R) => R), w = { | ||
...Te(), | ||
...h.options && h.options.react | ||
}; | ||
let m = d || v.ns || h.options && h.options.defaultNS; | ||
m = typeof m == "string" ? [m] : m || ["translation"]; | ||
const S = Ae(e, w), T = c || S || w.transEmptyNodeValue || s, { | ||
hashTransKey: O | ||
} = w, p = s || (O ? O(S || T) : S || T); | ||
h.options && h.options.interpolation && h.options.interpolation.defaultVariables && (u = u && Object.keys(u).length > 0 ? { | ||
...u, | ||
...h.options.interpolation.defaultVariables | ||
} : { | ||
...h.options.interpolation.defaultVariables | ||
}); | ||
const x = { | ||
...f, | ||
context: i || f.context, | ||
count: n, | ||
...u, | ||
defaultValue: T, | ||
ns: m | ||
}, D = p ? v(p, x) : T; | ||
l && Object.keys(l).forEach((R) => { | ||
const C = l[R]; | ||
if (typeof C.type == "function" || !C.props || !C.props.children || D.indexOf(`${R}/>`) < 0 && D.indexOf(`${R} />`) < 0) | ||
return; | ||
function I() { | ||
return L(Le, null, C); | ||
} | ||
l[R] = L(I); | ||
}); | ||
const _ = at(l || e, D, h, w, x, b), B = r !== void 0 ? r : w.defaultTransParent; | ||
return B ? L(B, j, _) : _; | ||
} | ||
const ut = { | ||
type: "3rdParty", | ||
init(t) { | ||
rt(t.options.react), ot(t); | ||
} | ||
}, Se = Ie(); | ||
class ct { | ||
constructor() { | ||
this.usedNamespaces = {}; | ||
} | ||
addUsedNamespaces(e) { | ||
e.forEach((n) => { | ||
this.usedNamespaces[n] || (this.usedNamespaces[n] = !0); | ||
}); | ||
} | ||
getUsedNamespaces() { | ||
return Object.keys(this.usedNamespaces); | ||
} | ||
} | ||
function _t(t) { | ||
let { | ||
children: e, | ||
count: n, | ||
parent: r, | ||
i18nKey: s, | ||
context: i, | ||
tOptions: f = {}, | ||
values: u, | ||
defaults: c, | ||
components: l, | ||
ns: d, | ||
i18n: y, | ||
t: P, | ||
shouldUnescape: b, | ||
...j | ||
} = t; | ||
const { | ||
i18n: h, | ||
defaultNS: v | ||
} = ve(Se) || {}, w = y || h || se(), m = P || w && w.t.bind(w); | ||
return ft({ | ||
children: e, | ||
count: n, | ||
parent: r, | ||
i18nKey: s, | ||
context: i, | ||
tOptions: f, | ||
values: u, | ||
defaults: c, | ||
components: l, | ||
ns: d || m && m.ns || v || w && w.options && w.options.defaultNS, | ||
i18n: w, | ||
t: P, | ||
shouldUnescape: b, | ||
...j | ||
}); | ||
} | ||
const lt = (t, e) => { | ||
const n = we(); | ||
return te(() => { | ||
n.current = e ? n.current : t; | ||
}, [t, e]), n.current; | ||
}; | ||
function xe(t, e, n, r) { | ||
return t.getFixedT(e, n, r); | ||
} | ||
function pt(t, e, n, r) { | ||
return Ue(xe(t, e, n, r), [t, e, n, r]); | ||
} | ||
function Bt(t) { | ||
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; | ||
const { | ||
i18n: n | ||
} = e, { | ||
i18n: r, | ||
defaultNS: s | ||
} = ve(Se) || {}, i = n || r || se(); | ||
if (i && !i.reportNamespaces && (i.reportNamespaces = new ct()), !i) { | ||
J("You will need to pass in an i18next instance by using initReactI18next"); | ||
const T = (p, x) => typeof x == "string" ? x : x && typeof x == "object" && typeof x.defaultValue == "string" ? x.defaultValue : Array.isArray(p) ? p[p.length - 1] : p, O = [T, {}, !1]; | ||
return O.t = T, O.i18n = {}, O.ready = !1, O; | ||
} | ||
i.options.react && i.options.react.wait !== void 0 && J("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour."); | ||
const f = { | ||
...Te(), | ||
...i.options.react, | ||
...e | ||
}, { | ||
useSuspense: u, | ||
keyPrefix: c | ||
} = f; | ||
let l = t || s || i.options && i.options.defaultNS; | ||
l = typeof l == "string" ? [l] : l || ["translation"], i.reportNamespaces.addUsedNamespaces && i.reportNamespaces.addUsedNamespaces(l); | ||
const d = (i.isInitialized || i.initializedStoreOnce) && l.every((T) => Ye(T, i, f)), y = pt(i, e.lng || null, f.nsMode === "fallback" ? l : l[0], c), P = () => y, b = () => xe(i, e.lng || null, f.nsMode === "fallback" ? l : l[0], c), [j, h] = Me(P); | ||
let v = l.join(); | ||
e.lng && (v = `${e.lng}${v}`); | ||
const w = lt(v), m = we(!0); | ||
te(() => { | ||
const { | ||
bindI18n: T, | ||
bindI18nStore: O | ||
} = f; | ||
m.current = !0, !d && !u && (e.lng ? ce(i, e.lng, l, () => { | ||
m.current && h(b); | ||
}) : ue(i, l, () => { | ||
m.current && h(b); | ||
})), d && w && w !== v && m.current && h(b); | ||
function p() { | ||
m.current && h(b); | ||
} | ||
return T && i && i.on(T, p), O && i && i.store.on(O, p), () => { | ||
m.current = !1, T && i && T.split(" ").forEach((x) => i.off(x, p)), O && i && O.split(" ").forEach((x) => i.store.off(x, p)); | ||
}; | ||
}, [i, v]), te(() => { | ||
m.current && d && h(P); | ||
}, [i, c, d]); | ||
const S = [j, i, d]; | ||
if (S.t = j, S.i18n = i, S.ready = d, d || !d && !u) | ||
return S; | ||
throw new Promise((T) => { | ||
e.lng ? ce(i, e.lng, l, () => T()) : ue(i, l, () => T()); | ||
}); | ||
} | ||
function re(t) { | ||
function ne(t) { | ||
"@babel/helpers - typeof"; | ||
return re = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) { | ||
return ne = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) { | ||
return typeof e; | ||
} : function(e) { | ||
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e; | ||
}, re(t); | ||
}, ne(t); | ||
} | ||
function _e() { | ||
return typeof XMLHttpRequest == "function" || (typeof XMLHttpRequest > "u" ? "undefined" : re(XMLHttpRequest)) === "object"; | ||
function Oe() { | ||
return typeof XMLHttpRequest == "function" || (typeof XMLHttpRequest > "u" ? "undefined" : ne(XMLHttpRequest)) === "object"; | ||
} | ||
function dt(t) { | ||
function Xe(t) { | ||
return !!t && typeof t.then == "function"; | ||
} | ||
function ht(t) { | ||
return dt(t) ? t : Promise.resolve(t); | ||
function ze(t) { | ||
return Xe(t) ? t : Promise.resolve(t); | ||
} | ||
function yt(t) { | ||
var U = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; | ||
function Pe(t) { | ||
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; | ||
} | ||
function Ke(t) { | ||
throw new Error('Could not dynamically require "' + t + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); | ||
} | ||
var oe = { exports: {} }, V = { exports: {} }, le; | ||
function mt() { | ||
return le || (le = 1, function(t, e) { | ||
var re = { exports: {} }, V = { exports: {} }, ae; | ||
function Ve() { | ||
return ae || (ae = 1, function(t, e) { | ||
var n = typeof globalThis < "u" && globalThis || typeof self < "u" && self || typeof U < "u" && U, r = function() { | ||
@@ -878,13 +362,13 @@ function i() { | ||
var n; | ||
if (typeof fetch == "function" && (typeof U < "u" && U.fetch ? n = U.fetch : typeof window < "u" && window.fetch ? n = window.fetch : n = fetch), typeof yt < "u" && typeof window > "u") { | ||
var r = n || mt(); | ||
if (typeof fetch == "function" && (typeof U < "u" && U.fetch ? n = U.fetch : typeof window < "u" && window.fetch ? n = window.fetch : n = fetch), typeof Ke < "u" && typeof window > "u") { | ||
var r = n || Ve(); | ||
r.default && (r = r.default), e.default = r, t.exports = e.default; | ||
} | ||
})(oe, oe.exports); | ||
var Be = oe.exports; | ||
const Ne = /* @__PURE__ */ Oe(Be), pe = /* @__PURE__ */ ke({ | ||
})(re, re.exports); | ||
var Ee = re.exports; | ||
const Te = /* @__PURE__ */ Pe(Ee), fe = /* @__PURE__ */ ke({ | ||
__proto__: null, | ||
default: Ne | ||
}, [Be]); | ||
function de(t, e) { | ||
default: Te | ||
}, [Ee]); | ||
function ue(t, e) { | ||
var n = Object.keys(t); | ||
@@ -899,8 +383,8 @@ if (Object.getOwnPropertySymbols) { | ||
} | ||
function he(t) { | ||
function ce(t) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var n = arguments[e] != null ? arguments[e] : {}; | ||
e % 2 ? de(Object(n), !0).forEach(function(r) { | ||
gt(t, r, n[r]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : de(Object(n)).forEach(function(r) { | ||
e % 2 ? ue(Object(n), !0).forEach(function(r) { | ||
We(t, r, n[r]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : ue(Object(n)).forEach(function(r) { | ||
Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r)); | ||
@@ -911,10 +395,10 @@ }); | ||
} | ||
function gt(t, e, n) { | ||
return e = bt(e), e in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = n, t; | ||
function We(t, e, n) { | ||
return e = Ge(e), e in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = n, t; | ||
} | ||
function bt(t) { | ||
var e = vt(t, "string"); | ||
function Ge(t) { | ||
var e = Je(t, "string"); | ||
return $(e) == "symbol" ? e : String(e); | ||
} | ||
function vt(t, e) { | ||
function Je(t, e) { | ||
if ($(t) != "object" || !t) | ||
@@ -942,8 +426,8 @@ return t; | ||
var k; | ||
_e() && (typeof global < "u" && global.XMLHttpRequest ? k = global.XMLHttpRequest : typeof window < "u" && window.XMLHttpRequest && (k = window.XMLHttpRequest)); | ||
var Q; | ||
typeof ActiveXObject == "function" && (typeof global < "u" && global.ActiveXObject ? Q = global.ActiveXObject : typeof window < "u" && window.ActiveXObject && (Q = window.ActiveXObject)); | ||
!H && pe && !k && !Q && (H = Ne || pe); | ||
Oe() && (typeof global < "u" && global.XMLHttpRequest ? k = global.XMLHttpRequest : typeof window < "u" && window.XMLHttpRequest && (k = window.XMLHttpRequest)); | ||
var J; | ||
typeof ActiveXObject == "function" && (typeof global < "u" && global.ActiveXObject ? J = global.ActiveXObject : typeof window < "u" && window.ActiveXObject && (J = window.ActiveXObject)); | ||
!H && fe && !k && !J && (H = Te || fe); | ||
typeof H != "function" && (H = void 0); | ||
var ie = function(e, n) { | ||
var oe = function(e, n) { | ||
if (n && $(n) === "object") { | ||
@@ -958,3 +442,3 @@ var r = ""; | ||
return e; | ||
}, ye = function(e, n, r, s) { | ||
}, le = function(e, n, r, s) { | ||
var i = function(c) { | ||
@@ -980,13 +464,13 @@ if (!c.ok) | ||
typeof fetch == "function" ? fetch(e, n).then(i).catch(r) : H(e, n).then(i).catch(r); | ||
}, me = !1, wt = function(e, n, r, s) { | ||
e.queryStringParams && (n = ie(n, e.queryStringParams)); | ||
var i = he({}, typeof e.customHeaders == "function" ? e.customHeaders() : e.customHeaders); | ||
}, pe = !1, Qe = function(e, n, r, s) { | ||
e.queryStringParams && (n = oe(n, e.queryStringParams)); | ||
var i = ce({}, typeof e.customHeaders == "function" ? e.customHeaders() : e.customHeaders); | ||
typeof window > "u" && typeof global < "u" && typeof global.process < "u" && global.process.versions && global.process.versions.node && (i["User-Agent"] = "i18next-http-backend (node/".concat(global.process.version, "; ").concat(global.process.platform, " ").concat(global.process.arch, ")")), r && (i["Content-Type"] = "application/json"); | ||
var f = typeof e.requestOptions == "function" ? e.requestOptions(r) : e.requestOptions, u = he({ | ||
var f = typeof e.requestOptions == "function" ? e.requestOptions(r) : e.requestOptions, u = ce({ | ||
method: r ? "POST" : "GET", | ||
body: r ? e.stringify(r) : void 0, | ||
headers: i | ||
}, me ? {} : f), c = typeof e.alternateFetch == "function" && e.alternateFetch.length >= 1 ? e.alternateFetch : void 0; | ||
}, pe ? {} : f), c = typeof e.alternateFetch == "function" && e.alternateFetch.length >= 1 ? e.alternateFetch : void 0; | ||
try { | ||
ye(n, u, s, c); | ||
le(n, u, s, c); | ||
} catch (l) { | ||
@@ -998,3 +482,3 @@ if (!f || Object.keys(f).length === 0 || !l.message || l.message.indexOf("not implemented") < 0) | ||
delete u[d]; | ||
}), ye(n, u, s, c), me = !0; | ||
}), le(n, u, s, c), pe = !0; | ||
} catch (d) { | ||
@@ -1004,7 +488,7 @@ s(d); | ||
} | ||
}, Ot = function(e, n, r, s) { | ||
r && $(r) === "object" && (r = ie("", r).slice(1)), e.queryStringParams && (n = ie(n, e.queryStringParams)); | ||
}, Ye = function(e, n, r, s) { | ||
r && $(r) === "object" && (r = oe("", r).slice(1)), e.queryStringParams && (n = oe(n, e.queryStringParams)); | ||
try { | ||
var i; | ||
k ? i = new k() : i = new Q("MSXML2.XMLHTTP.3.0"), i.open(r ? "POST" : "GET", n, 1), e.crossDomain || i.setRequestHeader("X-Requested-With", "XMLHttpRequest"), i.withCredentials = !!e.withCredentials, r && i.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), i.overrideMimeType && i.overrideMimeType("application/json"); | ||
k ? i = new k() : i = new J("MSXML2.XMLHTTP.3.0"), i.open(r ? "POST" : "GET", n, 1), e.crossDomain || i.setRequestHeader("X-Requested-With", "XMLHttpRequest"), i.withCredentials = !!e.withCredentials, r && i.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), i.overrideMimeType && i.overrideMimeType("application/json"); | ||
var f = e.customHeaders; | ||
@@ -1023,8 +507,8 @@ if (f = typeof f == "function" ? f() : f, f) | ||
} | ||
}, Pt = function(e, n, r, s) { | ||
}, Ze = function(e, n, r, s) { | ||
if (typeof r == "function" && (s = r, r = void 0), s = s || function() { | ||
}, H && n.indexOf("file:") !== 0) | ||
return wt(e, n, r, s); | ||
if (_e() || typeof ActiveXObject == "function") | ||
return Ot(e, n, r, s); | ||
return Qe(e, n, r, s); | ||
if (Oe() || typeof ActiveXObject == "function") | ||
return Ye(e, n, r, s); | ||
s(new Error("No fetch and no xhr implementation found!")); | ||
@@ -1040,3 +524,3 @@ }; | ||
} | ||
function ge(t, e) { | ||
function de(t, e) { | ||
var n = Object.keys(t); | ||
@@ -1051,8 +535,8 @@ if (Object.getOwnPropertySymbols) { | ||
} | ||
function ee(t) { | ||
function Y(t) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var n = arguments[e] != null ? arguments[e] : {}; | ||
e % 2 ? ge(Object(n), !0).forEach(function(r) { | ||
Ce(t, r, n[r]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : ge(Object(n)).forEach(function(r) { | ||
e % 2 ? de(Object(n), !0).forEach(function(r) { | ||
je(t, r, n[r]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : de(Object(n)).forEach(function(r) { | ||
Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r)); | ||
@@ -1063,23 +547,23 @@ }); | ||
} | ||
function Et(t, e) { | ||
function et(t, e) { | ||
if (!(t instanceof e)) | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
function be(t, e) { | ||
function he(t, e) { | ||
for (var n = 0; n < e.length; n++) { | ||
var r = e[n]; | ||
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(t, Re(r.key), r); | ||
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(t, Ae(r.key), r); | ||
} | ||
} | ||
function Tt(t, e, n) { | ||
return e && be(t.prototype, e), n && be(t, n), Object.defineProperty(t, "prototype", { writable: !1 }), t; | ||
function tt(t, e, n) { | ||
return e && he(t.prototype, e), n && he(t, n), Object.defineProperty(t, "prototype", { writable: !1 }), t; | ||
} | ||
function Ce(t, e, n) { | ||
return e = Re(e), e in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = n, t; | ||
function je(t, e, n) { | ||
return e = Ae(e), e in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = n, t; | ||
} | ||
function Re(t) { | ||
var e = jt(t, "string"); | ||
function Ae(t) { | ||
var e = nt(t, "string"); | ||
return X(e) == "symbol" ? e : String(e); | ||
} | ||
function jt(t, e) { | ||
function nt(t, e) { | ||
if (X(t) != "object" || !t) | ||
@@ -1096,3 +580,3 @@ return t; | ||
} | ||
var At = function() { | ||
var rt = function() { | ||
return { | ||
@@ -1106,7 +590,7 @@ loadPath: "/locales/{{lng}}/{{ns}}.json", | ||
parsePayload: function(n, r, s) { | ||
return Ce({}, r, s || ""); | ||
return je({}, r, s || ""); | ||
}, | ||
parseLoadPayload: function(n, r) { | ||
}, | ||
request: Pt, | ||
request: Ze, | ||
reloadInterval: typeof window < "u" ? !1 : 60 * 60 * 1e3, | ||
@@ -1124,12 +608,12 @@ customHeaders: {}, | ||
}; | ||
}, qe = function() { | ||
}, Se = function() { | ||
function t(e) { | ||
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; | ||
Et(this, t), this.services = e, this.options = n, this.allOptions = r, this.type = "backend", this.init(e, n, r); | ||
et(this, t), this.services = e, this.options = n, this.allOptions = r, this.type = "backend", this.init(e, n, r); | ||
} | ||
return Tt(t, [{ | ||
return tt(t, [{ | ||
key: "init", | ||
value: function(n) { | ||
var r = this, s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; | ||
this.services = n, this.options = ee(ee(ee({}, At()), this.options || {}), s), this.allOptions = i, this.services && this.options.reloadInterval && setInterval(function() { | ||
this.services = n, this.options = Y(Y(Y({}, rt()), this.options || {}), s), this.allOptions = i, this.services && this.options.reloadInterval && setInterval(function() { | ||
return r.reload(); | ||
@@ -1152,3 +636,3 @@ }, this.options.reloadInterval); | ||
var u = this, c = this.options.loadPath; | ||
typeof this.options.loadPath == "function" && (c = this.options.loadPath(n, s)), c = ht(c), c.then(function(l) { | ||
typeof this.options.loadPath == "function" && (c = this.options.loadPath(n, s)), c = ze(c), c.then(function(l) { | ||
if (!l) | ||
@@ -1231,4 +715,520 @@ return f(null, {}); | ||
}(); | ||
qe.type = "backend"; | ||
He.use(qe).use(ut).init({ | ||
Se.type = "backend"; | ||
var ot = { | ||
area: !0, | ||
base: !0, | ||
br: !0, | ||
col: !0, | ||
embed: !0, | ||
hr: !0, | ||
img: !0, | ||
input: !0, | ||
link: !0, | ||
meta: !0, | ||
param: !0, | ||
source: !0, | ||
track: !0, | ||
wbr: !0 | ||
}; | ||
const it = /* @__PURE__ */ Pe(ot); | ||
var st = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g; | ||
function ye(t) { | ||
var e = { type: "tag", name: "", voidElement: !1, attrs: {}, children: [] }, n = t.match(/<\/?([^\s]+?)[/\s>]/); | ||
if (n && (e.name = n[1], (it[n[1]] || t.charAt(t.length - 2) === "/") && (e.voidElement = !0), e.name.startsWith("!--"))) { | ||
var r = t.indexOf("-->"); | ||
return { type: "comment", comment: r !== -1 ? t.slice(4, r) : "" }; | ||
} | ||
for (var s = new RegExp(st), i = null; (i = s.exec(t)) !== null; ) | ||
if (i[0].trim()) | ||
if (i[1]) { | ||
var f = i[1].trim(), u = [f, ""]; | ||
f.indexOf("=") > -1 && (u = f.split("=")), e.attrs[u[0]] = u[1], s.lastIndex--; | ||
} else | ||
i[2] && (e.attrs[i[2]] = i[3].trim().substring(1, i[3].length - 1)); | ||
return e; | ||
} | ||
var at = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g, ft = /^\s*$/, ut = /* @__PURE__ */ Object.create(null); | ||
function xe(t, e) { | ||
switch (e.type) { | ||
case "text": | ||
return t + e.content; | ||
case "tag": | ||
return t += "<" + e.name + (e.attrs ? function(n) { | ||
var r = []; | ||
for (var s in n) | ||
r.push(s + '="' + n[s] + '"'); | ||
return r.length ? " " + r.join(" ") : ""; | ||
}(e.attrs) : "") + (e.voidElement ? "/>" : ">"), e.voidElement ? t : t + e.children.reduce(xe, "") + "</" + e.name + ">"; | ||
case "comment": | ||
return t + "<!--" + e.comment + "-->"; | ||
} | ||
} | ||
var ct = { parse: function(t, e) { | ||
e || (e = {}), e.components || (e.components = ut); | ||
var n, r = [], s = [], i = -1, f = !1; | ||
if (t.indexOf("<") !== 0) { | ||
var u = t.indexOf("<"); | ||
r.push({ type: "text", content: u === -1 ? t : t.substring(0, u) }); | ||
} | ||
return t.replace(at, function(c, l) { | ||
if (f) { | ||
if (c !== "</" + n.name + ">") | ||
return; | ||
f = !1; | ||
} | ||
var d, y = c.charAt(1) !== "/", P = c.startsWith("<!--"), b = l + c.length, j = t.charAt(b); | ||
if (P) { | ||
var h = ye(c); | ||
return i < 0 ? (r.push(h), r) : ((d = s[i]).children.push(h), r); | ||
} | ||
if (y && (i++, (n = ye(c)).type === "tag" && e.components[n.name] && (n.type = "component", f = !0), n.voidElement || f || !j || j === "<" || n.children.push({ type: "text", content: t.slice(b, t.indexOf("<", b)) }), i === 0 && r.push(n), (d = s[i - 1]) && d.children.push(n), s[i] = n), (!y || n.voidElement) && (i > -1 && (n.voidElement || n.name === c.slice(2, -1)) && (i--, n = i === -1 ? r : s[i]), !f && j !== "<" && j)) { | ||
d = i === -1 ? r : s[i].children; | ||
var v = t.indexOf("<", b), w = t.slice(b, v === -1 ? void 0 : v); | ||
ft.test(w) && (w = " "), (v > -1 && i + d.length >= 0 || w !== " ") && d.push({ type: "text", content: w }); | ||
} | ||
}), r; | ||
}, stringify: function(t) { | ||
return t.reduce(function(e, n) { | ||
return e + xe("", n); | ||
}, ""); | ||
} }; | ||
function W() { | ||
if (console && console.warn) { | ||
for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++) | ||
e[n] = arguments[n]; | ||
typeof e[0] == "string" && (e[0] = `react-i18next:: ${e[0]}`), console.warn(...e); | ||
} | ||
} | ||
const me = {}; | ||
function Q() { | ||
for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++) | ||
e[n] = arguments[n]; | ||
typeof e[0] == "string" && me[e[0]] || (typeof e[0] == "string" && (me[e[0]] = /* @__PURE__ */ new Date()), W(...e)); | ||
} | ||
const _e = (t, e) => () => { | ||
if (t.isInitialized) | ||
e(); | ||
else { | ||
const n = () => { | ||
setTimeout(() => { | ||
t.off("initialized", n); | ||
}, 0), e(); | ||
}; | ||
t.on("initialized", n); | ||
} | ||
}; | ||
function ge(t, e, n) { | ||
t.loadNamespaces(e, _e(t, n)); | ||
} | ||
function be(t, e, n, r) { | ||
typeof n == "string" && (n = [n]), n.forEach((s) => { | ||
t.options.ns.indexOf(s) < 0 && t.options.ns.push(s); | ||
}), t.loadLanguages(e, _e(t, r)); | ||
} | ||
function lt(t, e) { | ||
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; | ||
const r = e.languages[0], s = e.options ? e.options.fallbackLng : !1, i = e.languages[e.languages.length - 1]; | ||
if (r.toLowerCase() === "cimode") | ||
return !0; | ||
const f = (u, c) => { | ||
const l = e.services.backendConnector.state[`${u}|${c}`]; | ||
return l === -1 || l === 2; | ||
}; | ||
return n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && e.services.backendConnector.backend && e.isLanguageChangingTo && !f(e.isLanguageChangingTo, t) ? !1 : !!(e.hasResourceBundle(r, t) || !e.services.backendConnector.backend || e.options.resources && !e.options.partialBundledLanguages || f(r, t) && (!s || f(i, t))); | ||
} | ||
function pt(t, e) { | ||
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; | ||
return !e.languages || !e.languages.length ? (Q("i18n.languages were undefined or empty", e.languages), !0) : e.options.ignoreJSONStructure !== void 0 ? e.hasLoadedNamespace(t, { | ||
lng: n.lng, | ||
precheck: (s, i) => { | ||
if (n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && s.services.backendConnector.backend && s.isLanguageChangingTo && !i(s.isLanguageChangingTo, t)) | ||
return !1; | ||
} | ||
}) : lt(t, e, n); | ||
} | ||
const dt = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g, ht = { | ||
"&": "&", | ||
"&": "&", | ||
"<": "<", | ||
"<": "<", | ||
">": ">", | ||
">": ">", | ||
"'": "'", | ||
"'": "'", | ||
""": '"', | ||
""": '"', | ||
" ": " ", | ||
" ": " ", | ||
"©": "©", | ||
"©": "©", | ||
"®": "®", | ||
"®": "®", | ||
"…": "…", | ||
"…": "…", | ||
"/": "/", | ||
"/": "/" | ||
}, yt = (t) => ht[t], mt = (t) => t.replace(dt, yt); | ||
let ie = { | ||
bindI18n: "languageChanged", | ||
bindI18nStore: "", | ||
transEmptyNodeValue: "", | ||
transSupportBasicHtmlNodes: !0, | ||
transWrapTextNodes: "", | ||
transKeepBasicHtmlNodesFor: ["br", "strong", "i", "p"], | ||
useSuspense: !0, | ||
unescape: mt | ||
}; | ||
function gt() { | ||
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; | ||
ie = { | ||
...ie, | ||
...t | ||
}; | ||
} | ||
function Be() { | ||
return ie; | ||
} | ||
let Ne; | ||
function bt(t) { | ||
Ne = t; | ||
} | ||
function se() { | ||
return Ne; | ||
} | ||
function Z(t, e) { | ||
if (!t) | ||
return !1; | ||
const n = t.props ? t.props.children : t.children; | ||
return e ? n.length > 0 : !!n; | ||
} | ||
function ee(t) { | ||
if (!t) | ||
return []; | ||
const e = t.props ? t.props.children : t.children; | ||
return t.props && t.props.i18nIsDynamicList ? F(e) : e; | ||
} | ||
function vt(t) { | ||
return Object.prototype.toString.call(t) !== "[object Array]" ? !1 : t.every((e) => G(e)); | ||
} | ||
function F(t) { | ||
return Array.isArray(t) ? t : [t]; | ||
} | ||
function wt(t, e) { | ||
const n = { | ||
...e | ||
}; | ||
return n.props = Object.assign(t.props, e.props), n; | ||
} | ||
function Ce(t, e) { | ||
if (!t) | ||
return ""; | ||
let n = ""; | ||
const r = F(t), s = e.transSupportBasicHtmlNodes && e.transKeepBasicHtmlNodesFor ? e.transKeepBasicHtmlNodesFor : []; | ||
return r.forEach((i, f) => { | ||
if (typeof i == "string") | ||
n += `${i}`; | ||
else if (G(i)) { | ||
const u = Object.keys(i.props).length, c = s.indexOf(i.type) > -1, l = i.props.children; | ||
if (!l && c && u === 0) | ||
n += `<${i.type}/>`; | ||
else if (!l && (!c || u !== 0)) | ||
n += `<${f}></${f}>`; | ||
else if (i.props.i18nIsDynamicList) | ||
n += `<${f}></${f}>`; | ||
else if (c && u === 1 && typeof l == "string") | ||
n += `<${i.type}>${l}</${i.type}>`; | ||
else { | ||
const d = Ce(l, e); | ||
n += `<${f}>${d}</${f}>`; | ||
} | ||
} else if (i === null) | ||
W("Trans: the passed in value is invalid - seems you passed in a null child."); | ||
else if (typeof i == "object") { | ||
const { | ||
format: u, | ||
...c | ||
} = i, l = Object.keys(c); | ||
if (l.length === 1) { | ||
const d = u ? `${l[0]}, ${u}` : l[0]; | ||
n += `{{${d}}}`; | ||
} else | ||
W("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.", i); | ||
} else | ||
W("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.", i); | ||
}), n; | ||
} | ||
function Ot(t, e, n, r, s, i) { | ||
if (e === "") | ||
return []; | ||
const f = r.transKeepBasicHtmlNodesFor || [], u = e && new RegExp(f.map((v) => `<${v}`).join("|")).test(e); | ||
if (!t && !u && !i) | ||
return [e]; | ||
const c = {}; | ||
function l(v) { | ||
F(v).forEach((m) => { | ||
typeof m != "string" && (Z(m) ? l(ee(m)) : typeof m == "object" && !G(m) && Object.assign(c, m)); | ||
}); | ||
} | ||
l(t); | ||
const d = ct.parse(`<0>${e}</0>`), y = { | ||
...c, | ||
...s | ||
}; | ||
function P(v, w, m) { | ||
const S = ee(v), T = j(S, w.children, m); | ||
return vt(S) && T.length === 0 || v.props && v.props.i18nIsDynamicList ? S : T; | ||
} | ||
function b(v, w, m, S, T) { | ||
v.dummy ? (v.children = w, m.push($e(v, { | ||
key: S | ||
}, T ? void 0 : w))) : m.push(...Fe.map([v], (O) => { | ||
const p = { | ||
...O.props | ||
}; | ||
return delete p.i18nIsDynamicList, L(O.type, { | ||
...p, | ||
key: S, | ||
ref: O.ref | ||
}, T ? null : w); | ||
})); | ||
} | ||
function j(v, w, m) { | ||
const S = F(v); | ||
return F(w).reduce((O, p, x) => { | ||
const D = p.children && p.children[0] && p.children[0].content && n.services.interpolator.interpolate(p.children[0].content, y, n.language); | ||
if (p.type === "tag") { | ||
let _ = S[parseInt(p.name, 10)]; | ||
m.length === 1 && !_ && (_ = m[0][p.name]), _ || (_ = {}); | ||
const B = Object.keys(p.attrs).length !== 0 ? wt({ | ||
props: p.attrs | ||
}, _) : _, R = G(B), C = R && Z(p, !0) && !p.voidElement, I = u && typeof B == "object" && B.dummy && !R, M = typeof t == "object" && t !== null && Object.hasOwnProperty.call(t, p.name); | ||
if (typeof B == "string") { | ||
const o = n.services.interpolator.interpolate(B, y, n.language); | ||
O.push(o); | ||
} else if (Z(B) || C) { | ||
const o = P(B, p, m); | ||
b(B, o, O, x); | ||
} else if (I) { | ||
const o = j(S, p.children, m); | ||
b(B, o, O, x); | ||
} else if (Number.isNaN(parseFloat(p.name))) | ||
if (M) { | ||
const o = P(B, p, m); | ||
b(B, o, O, x, p.voidElement); | ||
} else if (r.transSupportBasicHtmlNodes && f.indexOf(p.name) > -1) | ||
if (p.voidElement) | ||
O.push(L(p.name, { | ||
key: `${p.name}-${x}` | ||
})); | ||
else { | ||
const o = j(S, p.children, m); | ||
O.push(L(p.name, { | ||
key: `${p.name}-${x}` | ||
}, o)); | ||
} | ||
else if (p.voidElement) | ||
O.push(`<${p.name} />`); | ||
else { | ||
const o = j(S, p.children, m); | ||
O.push(`<${p.name}>${o}</${p.name}>`); | ||
} | ||
else if (typeof B == "object" && !R) { | ||
const o = p.children[0] ? D : null; | ||
o && O.push(o); | ||
} else | ||
b(B, D, O, x, p.children.length !== 1 || !D); | ||
} else if (p.type === "text") { | ||
const _ = r.transWrapTextNodes, B = i ? r.unescape(n.services.interpolator.interpolate(p.content, y, n.language)) : n.services.interpolator.interpolate(p.content, y, n.language); | ||
_ ? O.push(L(_, { | ||
key: `${p.name}-${x}` | ||
}, B)) : O.push(B); | ||
} | ||
return O; | ||
}, []); | ||
} | ||
const h = j([{ | ||
dummy: !0, | ||
children: t || [] | ||
}], d, F(t || [])); | ||
return ee(h[0]); | ||
} | ||
function Pt(t) { | ||
let { | ||
children: e, | ||
count: n, | ||
parent: r, | ||
i18nKey: s, | ||
context: i, | ||
tOptions: f = {}, | ||
values: u, | ||
defaults: c, | ||
components: l, | ||
ns: d, | ||
i18n: y, | ||
t: P, | ||
shouldUnescape: b, | ||
...j | ||
} = t; | ||
const h = y || se(); | ||
if (!h) | ||
return Q("You will need to pass in an i18next instance by using i18nextReactModule"), e; | ||
const v = P || h.t.bind(h) || ((R) => R), w = { | ||
...Be(), | ||
...h.options && h.options.react | ||
}; | ||
let m = d || v.ns || h.options && h.options.defaultNS; | ||
m = typeof m == "string" ? [m] : m || ["translation"]; | ||
const S = Ce(e, w), T = c || S || w.transEmptyNodeValue || s, { | ||
hashTransKey: O | ||
} = w, p = s || (O ? O(S || T) : S || T); | ||
h.options && h.options.interpolation && h.options.interpolation.defaultVariables && (u = u && Object.keys(u).length > 0 ? { | ||
...u, | ||
...h.options.interpolation.defaultVariables | ||
} : { | ||
...h.options.interpolation.defaultVariables | ||
}); | ||
const x = { | ||
...f, | ||
context: i || f.context, | ||
count: n, | ||
...u, | ||
defaultValue: T, | ||
ns: m | ||
}, D = p ? v(p, x) : T; | ||
l && Object.keys(l).forEach((R) => { | ||
const C = l[R]; | ||
if (typeof C.type == "function" || !C.props || !C.props.children || D.indexOf(`${R}/>`) < 0 && D.indexOf(`${R} />`) < 0) | ||
return; | ||
function I() { | ||
return L(Le, null, C); | ||
} | ||
l[R] = L(I); | ||
}); | ||
const _ = Ot(l || e, D, h, w, x, b), B = r !== void 0 ? r : w.defaultTransParent; | ||
return B ? L(B, j, _) : _; | ||
} | ||
const Et = { | ||
type: "3rdParty", | ||
init(t) { | ||
gt(t.options.react), bt(t); | ||
} | ||
}, Re = Ie(); | ||
class Tt { | ||
constructor() { | ||
this.usedNamespaces = {}; | ||
} | ||
addUsedNamespaces(e) { | ||
e.forEach((n) => { | ||
this.usedNamespaces[n] || (this.usedNamespaces[n] = !0); | ||
}); | ||
} | ||
getUsedNamespaces() { | ||
return Object.keys(this.usedNamespaces); | ||
} | ||
} | ||
function _t(t) { | ||
let { | ||
children: e, | ||
count: n, | ||
parent: r, | ||
i18nKey: s, | ||
context: i, | ||
tOptions: f = {}, | ||
values: u, | ||
defaults: c, | ||
components: l, | ||
ns: d, | ||
i18n: y, | ||
t: P, | ||
shouldUnescape: b, | ||
...j | ||
} = t; | ||
const { | ||
i18n: h, | ||
defaultNS: v | ||
} = ve(Re) || {}, w = y || h || se(), m = P || w && w.t.bind(w); | ||
return Pt({ | ||
children: e, | ||
count: n, | ||
parent: r, | ||
i18nKey: s, | ||
context: i, | ||
tOptions: f, | ||
values: u, | ||
defaults: c, | ||
components: l, | ||
ns: d || m && m.ns || v || w && w.options && w.options.defaultNS, | ||
i18n: w, | ||
t: P, | ||
shouldUnescape: b, | ||
...j | ||
}); | ||
} | ||
const jt = (t, e) => { | ||
const n = we(); | ||
return te(() => { | ||
n.current = e ? n.current : t; | ||
}, [t, e]), n.current; | ||
}; | ||
function qe(t, e, n, r) { | ||
return t.getFixedT(e, n, r); | ||
} | ||
function At(t, e, n, r) { | ||
return Ue(qe(t, e, n, r), [t, e, n, r]); | ||
} | ||
function Bt(t) { | ||
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; | ||
const { | ||
i18n: n | ||
} = e, { | ||
i18n: r, | ||
defaultNS: s | ||
} = ve(Re) || {}, i = n || r || se(); | ||
if (i && !i.reportNamespaces && (i.reportNamespaces = new Tt()), !i) { | ||
Q("You will need to pass in an i18next instance by using initReactI18next"); | ||
const T = (p, x) => typeof x == "string" ? x : x && typeof x == "object" && typeof x.defaultValue == "string" ? x.defaultValue : Array.isArray(p) ? p[p.length - 1] : p, O = [T, {}, !1]; | ||
return O.t = T, O.i18n = {}, O.ready = !1, O; | ||
} | ||
i.options.react && i.options.react.wait !== void 0 && Q("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour."); | ||
const f = { | ||
...Be(), | ||
...i.options.react, | ||
...e | ||
}, { | ||
useSuspense: u, | ||
keyPrefix: c | ||
} = f; | ||
let l = t || s || i.options && i.options.defaultNS; | ||
l = typeof l == "string" ? [l] : l || ["translation"], i.reportNamespaces.addUsedNamespaces && i.reportNamespaces.addUsedNamespaces(l); | ||
const d = (i.isInitialized || i.initializedStoreOnce) && l.every((T) => pt(T, i, f)), y = At(i, e.lng || null, f.nsMode === "fallback" ? l : l[0], c), P = () => y, b = () => qe(i, e.lng || null, f.nsMode === "fallback" ? l : l[0], c), [j, h] = Me(P); | ||
let v = l.join(); | ||
e.lng && (v = `${e.lng}${v}`); | ||
const w = jt(v), m = we(!0); | ||
te(() => { | ||
const { | ||
bindI18n: T, | ||
bindI18nStore: O | ||
} = f; | ||
m.current = !0, !d && !u && (e.lng ? be(i, e.lng, l, () => { | ||
m.current && h(b); | ||
}) : ge(i, l, () => { | ||
m.current && h(b); | ||
})), d && w && w !== v && m.current && h(b); | ||
function p() { | ||
m.current && h(b); | ||
} | ||
return T && i && i.on(T, p), O && i && i.store.on(O, p), () => { | ||
m.current = !1, T && i && T.split(" ").forEach((x) => i.off(x, p)), O && i && O.split(" ").forEach((x) => i.store.off(x, p)); | ||
}; | ||
}, [i, v]), te(() => { | ||
m.current && d && h(P); | ||
}, [i, c, d]); | ||
const S = [j, i, d]; | ||
if (S.t = j, S.i18n = i, S.ready = d, d || !d && !u) | ||
return S; | ||
throw new Promise((T) => { | ||
e.lng ? be(i, e.lng, l, () => T()) : ge(i, l, () => T()); | ||
}); | ||
} | ||
He.use(Se).use(Et).init({ | ||
lng: "en", | ||
@@ -1235,0 +1235,0 @@ fallbackLng: "en", |
import type { TOptions } from 'i18next'; | ||
/** | ||
* Translations is a recursive type that allows for nested structures, where each key can either map to a string or to another nested Translations object. | ||
* Translations is a recursive type that allows for nested structures, | ||
* where each key can either map to a string or to | ||
* another nested Translations object. | ||
* e.g. { key: 'value', nested: { key: 'value' } } | ||
@@ -24,5 +26,5 @@ */ | ||
}; | ||
export type Akii18n = { | ||
export type AkilocaleProps = { | ||
/** | ||
* Creates an instance of akii18n. | ||
* Creates an instance of Akilocale. | ||
* @param options - Options to create the instance. | ||
@@ -43,8 +45,10 @@ */ | ||
/** | ||
* It provides a way to personalize the language of the application. Sets the global ref for the language of akii18n. May need reload to take effect depending on the implementation. | ||
* It provides a way to personalize the language of the application. | ||
* Sets the global ref for the language of Akilocale. May need reload | ||
* to take effect depending on the implementation. | ||
* @param lng - Language to set. | ||
*/ | ||
setLng: (lng: string) => void; | ||
setLanguage: (lng: string) => void; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@akinon/akilocale", | ||
"description": "AkiLocale is a localization library for Akinon projects.", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"type": "module", | ||
@@ -19,4 +19,4 @@ "main": "dist/index.js", | ||
"@akinon/eslint-config": "0.1.0", | ||
"@akinon/typescript-config": "0.0.0", | ||
"@akinon/vite-config": "^0.1.1" | ||
"@akinon/vite-config": "^0.1.1", | ||
"@akinon/typescript-config": "0.0.0" | ||
}, | ||
@@ -41,3 +41,3 @@ "clean-package": "./clean-package.config.json", | ||
"lint": "eslint *.ts*", | ||
"test": "clean-package", | ||
"test": "vitest run", | ||
"test:ui": "vitest --ui", | ||
@@ -44,0 +44,0 @@ "test:watch": "vitest watch", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
201655
3224