@andre1502/react-utilities 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -51
- package/dist/EnvironmentEnum-CXTWJxNo.js +10 -0
- package/dist/EnvironmentEnum-CXTWJxNo.js.map +1 -0
- package/dist/Utils-CJ7ureSW.js +14 -0
- package/dist/Utils-CJ7ureSW.js.map +1 -0
- package/dist/browser-ponyfill-C-HVh7ck.js +321 -0
- package/dist/browser-ponyfill-C-HVh7ck.js.map +1 -0
- package/dist/chunk-vKJrgz-R.js +16 -0
- package/dist/config-cli-BIF4xuoO.js +1491 -0
- package/dist/config-cli-BIF4xuoO.js.map +1 -0
- package/dist/config-cli.js +3 -229
- package/dist/enums/CurrencySymbolEnum.d.ts +6 -5
- package/dist/enums/DeviceEnum.d.ts +5 -4
- package/dist/enums/EnvironmentEnum.d.ts +6 -5
- package/dist/format-BgweN3o5.js +65549 -0
- package/dist/format-BgweN3o5.js.map +1 -0
- package/dist/format.d.ts +26 -26
- package/dist/format.js +2 -55
- package/dist/hooks-oAipbPQ2.js +78 -0
- package/dist/hooks-oAipbPQ2.js.map +1 -0
- package/dist/hooks.js +2 -86
- package/dist/i18n-D1jKJPI0.js +1941 -0
- package/dist/i18n-D1jKJPI0.js.map +1 -0
- package/dist/i18n.js +4 -28
- package/dist/index-cli.d.ts +0 -1
- package/dist/index-cli.js +3 -28
- package/dist/index-rn.js +6 -39
- package/dist/index.js +7 -61
- package/dist/sentry-rn-DZwIel7y.js +743 -0
- package/dist/sentry-rn-DZwIel7y.js.map +1 -0
- package/dist/sentry-rn.js +2 -28
- package/dist/sentry.js +39 -26
- package/dist/sentry.js.map +1 -1
- package/dist/utils.js +45 -37
- package/dist/utils.js.map +1 -1
- package/package.json +56 -86
- package/src/Config/GoogleAuth.ts +1 -1
- package/src/Sentry/React.ts +2 -4
- package/src/Sentry/ReactNative.ts +2 -4
- package/src/enums/CurrencySymbolEnum.ts +8 -5
- package/src/enums/DeviceEnum.ts +6 -4
- package/src/enums/EnvironmentEnum.ts +8 -5
- package/src/format.ts +32 -32
- package/src/index-cli.ts +0 -1
- package/dist/Config/Config.js +0 -249
- package/dist/Config/Config.js.map +0 -1
- package/dist/Config/GoogleAuth.js +0 -68
- package/dist/Config/GoogleAuth.js.map +0 -1
- package/dist/Config/Locales.js +0 -62
- package/dist/Config/Locales.js.map +0 -1
- package/dist/Config/Output.js +0 -36
- package/dist/Config/Output.js.map +0 -1
- package/dist/Config/Sitemap.js +0 -72
- package/dist/Config/Sitemap.js.map +0 -1
- package/dist/EnvironmentEnum-BjXsfSRZ.js +0 -9
- package/dist/EnvironmentEnum-BjXsfSRZ.js.map +0 -1
- package/dist/EnvironmentEnum-UcQ6Il1O.js +0 -9
- package/dist/EnvironmentEnum-UcQ6Il1O.js.map +0 -1
- package/dist/Format/NumberFormat.js +0 -77
- package/dist/Format/NumberFormat.js.map +0 -1
- package/dist/Format/NumberParser.js +0 -51
- package/dist/Format/NumberParser.js.map +0 -1
- package/dist/Hooks/useDevice.js +0 -47
- package/dist/Hooks/useDevice.js.map +0 -1
- package/dist/Hooks/useSound.js +0 -47
- package/dist/Hooks/useSound.js.map +0 -1
- package/dist/Hooks/useWebSocket.js +0 -120
- package/dist/Hooks/useWebSocket.js.map +0 -1
- package/dist/I18n/I18n.js +0 -134
- package/dist/I18n/I18n.js.map +0 -1
- package/dist/NumberFormat-CvvBWhHc.js +0 -89
- package/dist/NumberFormat-CvvBWhHc.js.map +0 -1
- package/dist/NumberFormat-glmpbk7E.js +0 -94
- package/dist/NumberFormat-glmpbk7E.js.map +0 -1
- package/dist/React-BaJ1KfGF.js +0 -87
- package/dist/React-BaJ1KfGF.js.map +0 -1
- package/dist/React-qUl0CBmE.js +0 -109
- package/dist/React-qUl0CBmE.js.map +0 -1
- package/dist/ReactNative-B4gt8nBr.js +0 -1790
- package/dist/ReactNative-B4gt8nBr.js.map +0 -1
- package/dist/ReactNative-CDMfQFfN.js +0 -1812
- package/dist/ReactNative-CDMfQFfN.js.map +0 -1
- package/dist/Sentry/Build.d.ts +0 -9
- package/dist/Sentry/Build.js +0 -87
- package/dist/Sentry/Build.js.map +0 -1
- package/dist/Sentry/React.js +0 -103
- package/dist/Sentry/React.js.map +0 -1
- package/dist/Sentry/ReactNative.js +0 -113
- package/dist/Sentry/ReactNative.js.map +0 -1
- package/dist/Sentry/Utils.js +0 -24
- package/dist/Sentry/Utils.js.map +0 -1
- package/dist/Utils/Array.js +0 -26
- package/dist/Utils/Array.js.map +0 -1
- package/dist/Utils/Files.js +0 -51
- package/dist/Utils/Files.js.map +0 -1
- package/dist/Utils/Pagination.js +0 -32
- package/dist/Utils/Pagination.js.map +0 -1
- package/dist/Utils/Utils.js +0 -101
- package/dist/Utils/Utils.js.map +0 -1
- package/dist/Utils-BC1fDy39.js +0 -74
- package/dist/Utils-BC1fDy39.js.map +0 -1
- package/dist/Utils-Cq948gfa.js +0 -20
- package/dist/Utils-Cq948gfa.js.map +0 -1
- package/dist/Utils-D7KRF8VU.js +0 -64
- package/dist/Utils-D7KRF8VU.js.map +0 -1
- package/dist/Utils-Dilye04y.js +0 -22
- package/dist/Utils-Dilye04y.js.map +0 -1
- package/dist/config-cli.cjs +0 -532
- package/dist/config-cli.cjs.map +0 -1
- package/dist/config-cli.js.map +0 -1
- package/dist/config-cli.mjs +0 -500
- package/dist/config-cli.mjs.map +0 -1
- package/dist/enums/CurrencySymbolEnum.js +0 -15
- package/dist/enums/CurrencySymbolEnum.js.map +0 -1
- package/dist/enums/DeviceEnum.js +0 -12
- package/dist/enums/DeviceEnum.js.map +0 -1
- package/dist/enums/EnvironmentEnum.js +0 -13
- package/dist/enums/EnvironmentEnum.js.map +0 -1
- package/dist/format.cjs +0 -43
- package/dist/format.cjs.map +0 -1
- package/dist/format.js.map +0 -1
- package/dist/format.mjs +0 -30
- package/dist/format.mjs.map +0 -1
- package/dist/hooks.cjs +0 -13
- package/dist/hooks.cjs.map +0 -1
- package/dist/hooks.js.map +0 -1
- package/dist/hooks.mjs +0 -4
- package/dist/hooks.mjs.map +0 -1
- package/dist/i18n.cjs +0 -3039
- package/dist/i18n.cjs.map +0 -1
- package/dist/i18n.js.map +0 -1
- package/dist/i18n.mjs +0 -3032
- package/dist/i18n.mjs.map +0 -1
- package/dist/index-cli.cjs +0 -31
- package/dist/index-cli.cjs.map +0 -1
- package/dist/index-cli.js.map +0 -1
- package/dist/index-cli.mjs +0 -14
- package/dist/index-cli.mjs.map +0 -1
- package/dist/index-rn.cjs +0 -57
- package/dist/index-rn.cjs.map +0 -1
- package/dist/index-rn.js.map +0 -1
- package/dist/index-rn.mjs +0 -36
- package/dist/index-rn.mjs.map +0 -1
- package/dist/index.cjs +0 -79
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -40
- package/dist/index.mjs.map +0 -1
- package/dist/interfaces/Config/ConfigOptions.js +0 -6
- package/dist/interfaces/Config/ConfigOptions.js.map +0 -1
- package/dist/interfaces/Config/EntryOptions.js +0 -6
- package/dist/interfaces/Config/EntryOptions.js.map +0 -1
- package/dist/interfaces/Config/OutputMap.js +0 -6
- package/dist/interfaces/Config/OutputMap.js.map +0 -1
- package/dist/interfaces/Config/OutputOptions.js +0 -6
- package/dist/interfaces/Config/OutputOptions.js.map +0 -1
- package/dist/interfaces/Config/SitemapMap.js +0 -6
- package/dist/interfaces/Config/SitemapMap.js.map +0 -1
- package/dist/interfaces/Config/StringMap.js +0 -6
- package/dist/interfaces/Config/StringMap.js.map +0 -1
- package/dist/interfaces/Format/FormatOptions.js +0 -6
- package/dist/interfaces/Format/FormatOptions.js.map +0 -1
- package/dist/interfaces/Sentry/InitOptions.js +0 -6
- package/dist/interfaces/Sentry/InitOptions.js.map +0 -1
- package/dist/interfaces/Sentry/InitOptionsRN.js +0 -6
- package/dist/interfaces/Sentry/InitOptionsRN.js.map +0 -1
- package/dist/interfaces/Sentry/SourceMapOptions.d.ts +0 -7
- package/dist/interfaces/Sentry/SourceMapOptions.js +0 -6
- package/dist/interfaces/Sentry/SourceMapOptions.js.map +0 -1
- package/dist/sentry-cli.cjs +0 -119
- package/dist/sentry-cli.cjs.map +0 -1
- package/dist/sentry-cli.d.ts +0 -9
- package/dist/sentry-cli.js +0 -49
- package/dist/sentry-cli.js.map +0 -1
- package/dist/sentry-cli.mjs +0 -98
- package/dist/sentry-cli.mjs.map +0 -1
- package/dist/sentry-rn.cjs +0 -11
- package/dist/sentry-rn.cjs.map +0 -1
- package/dist/sentry-rn.js.map +0 -1
- package/dist/sentry-rn.mjs +0 -4
- package/dist/sentry-rn.mjs.map +0 -1
- package/dist/sentry.cjs +0 -11
- package/dist/sentry.cjs.map +0 -1
- package/dist/sentry.mjs +0 -4
- package/dist/sentry.mjs.map +0 -1
- package/dist/types/Config/OptionType.js +0 -6
- package/dist/types/Config/OptionType.js.map +0 -1
- package/dist/types/Format/OptionType.js +0 -6
- package/dist/types/Format/OptionType.js.map +0 -1
- package/dist/types/Sentry/OptionType.js +0 -6
- package/dist/types/Sentry/OptionType.js.map +0 -1
- package/dist/useWebSocket-B_B6kWXM.js +0 -167
- package/dist/useWebSocket-B_B6kWXM.js.map +0 -1
- package/dist/useWebSocket-YQWaiBz9.js +0 -172
- package/dist/useWebSocket-YQWaiBz9.js.map +0 -1
- package/dist/utils.cjs +0 -59
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.mjs +0 -43
- package/dist/utils.mjs.map +0 -1
- package/src/Sentry/Build.ts +0 -67
- package/src/interfaces/Sentry/SourceMapOptions.ts +0 -7
- package/src/sentry-cli.ts +0 -16
|
@@ -0,0 +1,1941 @@
|
|
|
1
|
+
import { r as e } from "./chunk-vKJrgz-R.js";
|
|
2
|
+
import { getV as t } from "./utils.js";
|
|
3
|
+
//#region node_modules/i18next/dist/esm/i18next.js
|
|
4
|
+
var n = (e) => typeof e == "string", r = () => {
|
|
5
|
+
let e, t, n = new Promise((n, r) => {
|
|
6
|
+
e = n, t = r;
|
|
7
|
+
});
|
|
8
|
+
return n.resolve = e, n.reject = t, n;
|
|
9
|
+
}, i = (e) => e == null ? "" : String(e), a = (e, t, n) => {
|
|
10
|
+
e.forEach((e) => {
|
|
11
|
+
t[e] && (n[e] = t[e]);
|
|
12
|
+
});
|
|
13
|
+
}, o = /###/g, s = (e) => e && e.includes("###") ? e.replace(o, ".") : e, c = (e) => !e || n(e), l = (e, t, r) => {
|
|
14
|
+
let i = n(t) ? t.split(".") : t, a = 0;
|
|
15
|
+
for (; a < i.length - 1;) {
|
|
16
|
+
if (c(e)) return {};
|
|
17
|
+
let t = s(i[a]);
|
|
18
|
+
!e[t] && r && (e[t] = new r()), e = Object.prototype.hasOwnProperty.call(e, t) ? e[t] : {}, ++a;
|
|
19
|
+
}
|
|
20
|
+
return c(e) ? {} : {
|
|
21
|
+
obj: e,
|
|
22
|
+
k: s(i[a])
|
|
23
|
+
};
|
|
24
|
+
}, u = (e, t, n) => {
|
|
25
|
+
let { obj: r, k: i } = l(e, t, Object);
|
|
26
|
+
if (r !== void 0 || t.length === 1) {
|
|
27
|
+
r[i] = n;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let a = t[t.length - 1], o = t.slice(0, t.length - 1), s = l(e, o, Object);
|
|
31
|
+
for (; s.obj === void 0 && o.length;) a = `${o[o.length - 1]}.${a}`, o = o.slice(0, o.length - 1), s = l(e, o, Object), s?.obj && s.obj[`${s.k}.${a}`] !== void 0 && (s.obj = void 0);
|
|
32
|
+
s.obj[`${s.k}.${a}`] = n;
|
|
33
|
+
}, d = (e, t, n, r) => {
|
|
34
|
+
let { obj: i, k: a } = l(e, t, Object);
|
|
35
|
+
i[a] = i[a] || [], i[a].push(n);
|
|
36
|
+
}, f = (e, t) => {
|
|
37
|
+
let { obj: n, k: r } = l(e, t);
|
|
38
|
+
if (n && Object.prototype.hasOwnProperty.call(n, r)) return n[r];
|
|
39
|
+
}, p = (e, t, n) => {
|
|
40
|
+
let r = f(e, n);
|
|
41
|
+
return r === void 0 ? f(t, n) : r;
|
|
42
|
+
}, m = (e, t, r) => {
|
|
43
|
+
for (let i in t) i !== "__proto__" && i !== "constructor" && (i in e ? n(e[i]) || e[i] instanceof String || n(t[i]) || t[i] instanceof String ? r && (e[i] = t[i]) : m(e[i], t[i], r) : e[i] = t[i]);
|
|
44
|
+
return e;
|
|
45
|
+
}, h = (e) => e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), g = {
|
|
46
|
+
"&": "&",
|
|
47
|
+
"<": "<",
|
|
48
|
+
">": ">",
|
|
49
|
+
"\"": """,
|
|
50
|
+
"'": "'",
|
|
51
|
+
"/": "/"
|
|
52
|
+
}, _ = (e) => n(e) ? e.replace(/[&<>"'\/]/g, (e) => g[e]) : e, v = class {
|
|
53
|
+
constructor(e) {
|
|
54
|
+
this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
|
|
55
|
+
}
|
|
56
|
+
getRegExp(e) {
|
|
57
|
+
let t = this.regExpMap.get(e);
|
|
58
|
+
if (t !== void 0) return t;
|
|
59
|
+
let n = new RegExp(e);
|
|
60
|
+
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, n), this.regExpQueue.push(e), n;
|
|
61
|
+
}
|
|
62
|
+
}, y = [
|
|
63
|
+
" ",
|
|
64
|
+
",",
|
|
65
|
+
"?",
|
|
66
|
+
"!",
|
|
67
|
+
";"
|
|
68
|
+
], b = new v(20), x = (e, t, n) => {
|
|
69
|
+
t ||= "", n ||= "";
|
|
70
|
+
let r = y.filter((e) => !t.includes(e) && !n.includes(e));
|
|
71
|
+
if (r.length === 0) return !0;
|
|
72
|
+
let i = b.getRegExp(`(${r.map((e) => e === "?" ? "\\?" : e).join("|")})`), a = !i.test(e);
|
|
73
|
+
if (!a) {
|
|
74
|
+
let t = e.indexOf(n);
|
|
75
|
+
t > 0 && !i.test(e.substring(0, t)) && (a = !0);
|
|
76
|
+
}
|
|
77
|
+
return a;
|
|
78
|
+
}, S = (e, t, n = ".") => {
|
|
79
|
+
if (!e) return;
|
|
80
|
+
if (e[t]) return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
|
|
81
|
+
let r = t.split(n), i = e;
|
|
82
|
+
for (let e = 0; e < r.length;) {
|
|
83
|
+
if (!i || typeof i != "object") return;
|
|
84
|
+
let t, a = "";
|
|
85
|
+
for (let o = e; o < r.length; ++o) if (o !== e && (a += n), a += r[o], t = i[a], t !== void 0) {
|
|
86
|
+
if ([
|
|
87
|
+
"string",
|
|
88
|
+
"number",
|
|
89
|
+
"boolean"
|
|
90
|
+
].includes(typeof t) && o < r.length - 1) continue;
|
|
91
|
+
e += o - e + 1;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
i = t;
|
|
95
|
+
}
|
|
96
|
+
return i;
|
|
97
|
+
}, C = (e) => e?.replace(/_/g, "-"), ee = {
|
|
98
|
+
type: "logger",
|
|
99
|
+
log(e) {
|
|
100
|
+
this.output("log", e);
|
|
101
|
+
},
|
|
102
|
+
warn(e) {
|
|
103
|
+
this.output("warn", e);
|
|
104
|
+
},
|
|
105
|
+
error(e) {
|
|
106
|
+
this.output("error", e);
|
|
107
|
+
},
|
|
108
|
+
output(e, t) {
|
|
109
|
+
console?.[e]?.apply?.(console, t);
|
|
110
|
+
}
|
|
111
|
+
}, w = new class e {
|
|
112
|
+
constructor(e, t = {}) {
|
|
113
|
+
this.init(e, t);
|
|
114
|
+
}
|
|
115
|
+
init(e, t = {}) {
|
|
116
|
+
this.prefix = t.prefix || "i18next:", this.logger = e || ee, this.options = t, this.debug = t.debug;
|
|
117
|
+
}
|
|
118
|
+
log(...e) {
|
|
119
|
+
return this.forward(e, "log", "", !0);
|
|
120
|
+
}
|
|
121
|
+
warn(...e) {
|
|
122
|
+
return this.forward(e, "warn", "", !0);
|
|
123
|
+
}
|
|
124
|
+
error(...e) {
|
|
125
|
+
return this.forward(e, "error", "");
|
|
126
|
+
}
|
|
127
|
+
deprecate(...e) {
|
|
128
|
+
return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
|
|
129
|
+
}
|
|
130
|
+
forward(e, t, r, i) {
|
|
131
|
+
return i && !this.debug ? null : (n(e[0]) && (e[0] = `${r}${this.prefix} ${e[0]}`), this.logger[t](e));
|
|
132
|
+
}
|
|
133
|
+
create(t) {
|
|
134
|
+
return new e(this.logger, {
|
|
135
|
+
prefix: `${this.prefix}:${t}:`,
|
|
136
|
+
...this.options
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
clone(t) {
|
|
140
|
+
return t ||= this.options, t.prefix = t.prefix || this.prefix, new e(this.logger, t);
|
|
141
|
+
}
|
|
142
|
+
}(), T = class {
|
|
143
|
+
constructor() {
|
|
144
|
+
this.observers = {};
|
|
145
|
+
}
|
|
146
|
+
on(e, t) {
|
|
147
|
+
return e.split(" ").forEach((e) => {
|
|
148
|
+
this.observers[e] || (this.observers[e] = /* @__PURE__ */ new Map());
|
|
149
|
+
let n = this.observers[e].get(t) || 0;
|
|
150
|
+
this.observers[e].set(t, n + 1);
|
|
151
|
+
}), this;
|
|
152
|
+
}
|
|
153
|
+
off(e, t) {
|
|
154
|
+
if (this.observers[e]) {
|
|
155
|
+
if (!t) {
|
|
156
|
+
delete this.observers[e];
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
this.observers[e].delete(t);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
once(e, t) {
|
|
163
|
+
let n = (...r) => {
|
|
164
|
+
t(...r), this.off(e, n);
|
|
165
|
+
};
|
|
166
|
+
return this.on(e, n), this;
|
|
167
|
+
}
|
|
168
|
+
emit(e, ...t) {
|
|
169
|
+
this.observers[e] && Array.from(this.observers[e].entries()).forEach(([e, n]) => {
|
|
170
|
+
for (let r = 0; r < n; r++) e(...t);
|
|
171
|
+
}), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([n, r]) => {
|
|
172
|
+
for (let i = 0; i < r; i++) n(e, ...t);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}, E = class extends T {
|
|
176
|
+
constructor(e, t = {
|
|
177
|
+
ns: ["translation"],
|
|
178
|
+
defaultNS: "translation"
|
|
179
|
+
}) {
|
|
180
|
+
super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
|
|
181
|
+
}
|
|
182
|
+
addNamespaces(e) {
|
|
183
|
+
this.options.ns.includes(e) || this.options.ns.push(e);
|
|
184
|
+
}
|
|
185
|
+
removeNamespaces(e) {
|
|
186
|
+
let t = this.options.ns.indexOf(e);
|
|
187
|
+
t > -1 && this.options.ns.splice(t, 1);
|
|
188
|
+
}
|
|
189
|
+
getResource(e, t, r, i = {}) {
|
|
190
|
+
let a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = i.ignoreJSONStructure === void 0 ? this.options.ignoreJSONStructure : i.ignoreJSONStructure, s;
|
|
191
|
+
e.includes(".") ? s = e.split(".") : (s = [e, t], r && (Array.isArray(r) ? s.push(...r) : n(r) && a ? s.push(...r.split(a)) : s.push(r)));
|
|
192
|
+
let c = f(this.data, s);
|
|
193
|
+
return !c && !t && !r && e.includes(".") && (e = s[0], t = s[1], r = s.slice(2).join(".")), c || !o || !n(r) ? c : S(this.data?.[e]?.[t], r, a);
|
|
194
|
+
}
|
|
195
|
+
addResource(e, t, n, r, i = { silent: !1 }) {
|
|
196
|
+
let a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = [e, t];
|
|
197
|
+
n && (o = o.concat(a ? n.split(a) : n)), e.includes(".") && (o = e.split("."), r = t, t = o[1]), this.addNamespaces(t), u(this.data, o, r), i.silent || this.emit("added", e, t, n, r);
|
|
198
|
+
}
|
|
199
|
+
addResources(e, t, r, i = { silent: !1 }) {
|
|
200
|
+
for (let i in r) (n(r[i]) || Array.isArray(r[i])) && this.addResource(e, t, i, r[i], { silent: !0 });
|
|
201
|
+
i.silent || this.emit("added", e, t, r);
|
|
202
|
+
}
|
|
203
|
+
addResourceBundle(e, t, n, r, i, a = {
|
|
204
|
+
silent: !1,
|
|
205
|
+
skipCopy: !1
|
|
206
|
+
}) {
|
|
207
|
+
let o = [e, t];
|
|
208
|
+
e.includes(".") && (o = e.split("."), r = n, n = t, t = o[1]), this.addNamespaces(t);
|
|
209
|
+
let s = f(this.data, o) || {};
|
|
210
|
+
a.skipCopy || (n = JSON.parse(JSON.stringify(n))), r ? m(s, n, i) : s = {
|
|
211
|
+
...s,
|
|
212
|
+
...n
|
|
213
|
+
}, u(this.data, o, s), a.silent || this.emit("added", e, t, n);
|
|
214
|
+
}
|
|
215
|
+
removeResourceBundle(e, t) {
|
|
216
|
+
this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
|
|
217
|
+
}
|
|
218
|
+
hasResourceBundle(e, t) {
|
|
219
|
+
return this.getResource(e, t) !== void 0;
|
|
220
|
+
}
|
|
221
|
+
getResourceBundle(e, t) {
|
|
222
|
+
return t ||= this.options.defaultNS, this.getResource(e, t);
|
|
223
|
+
}
|
|
224
|
+
getDataByLanguage(e) {
|
|
225
|
+
return this.data[e];
|
|
226
|
+
}
|
|
227
|
+
hasLanguageSomeTranslations(e) {
|
|
228
|
+
let t = this.getDataByLanguage(e);
|
|
229
|
+
return !!(t && Object.keys(t) || []).find((e) => t[e] && Object.keys(t[e]).length > 0);
|
|
230
|
+
}
|
|
231
|
+
toJSON() {
|
|
232
|
+
return this.data;
|
|
233
|
+
}
|
|
234
|
+
}, D = {
|
|
235
|
+
processors: {},
|
|
236
|
+
addPostProcessor(e) {
|
|
237
|
+
this.processors[e.name] = e;
|
|
238
|
+
},
|
|
239
|
+
handle(e, t, n, r, i) {
|
|
240
|
+
return e.forEach((e) => {
|
|
241
|
+
t = this.processors[e]?.process(t, n, r, i) ?? t;
|
|
242
|
+
}), t;
|
|
243
|
+
}
|
|
244
|
+
}, O = Symbol("i18next/PATH_KEY");
|
|
245
|
+
function te() {
|
|
246
|
+
let e = [], t = Object.create(null), n;
|
|
247
|
+
return t.get = (r, i) => (n?.revoke?.(), i === O ? e : (e.push(i), n = Proxy.revocable(r, t), n.proxy)), Proxy.revocable(Object.create(null), t).proxy;
|
|
248
|
+
}
|
|
249
|
+
function k(e, t) {
|
|
250
|
+
let { [O]: n } = e(te()), r = t?.keySeparator ?? ".", i = t?.nsSeparator ?? ":";
|
|
251
|
+
if (n.length > 1 && i) {
|
|
252
|
+
let e = t?.ns, a = Array.isArray(e) ? e : null;
|
|
253
|
+
if (a && a.length > 1 && a.slice(1).includes(n[0])) return `${n[0]}${i}${n.slice(1).join(r)}`;
|
|
254
|
+
}
|
|
255
|
+
return n.join(r);
|
|
256
|
+
}
|
|
257
|
+
var A = (e) => !n(e) && typeof e != "boolean" && typeof e != "number", j = class e extends T {
|
|
258
|
+
constructor(e, t = {}) {
|
|
259
|
+
super(), a([
|
|
260
|
+
"resourceStore",
|
|
261
|
+
"languageUtils",
|
|
262
|
+
"pluralResolver",
|
|
263
|
+
"interpolator",
|
|
264
|
+
"backendConnector",
|
|
265
|
+
"i18nFormat",
|
|
266
|
+
"utils"
|
|
267
|
+
], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = w.create("translator"), this.checkedLoadedFor = {};
|
|
268
|
+
}
|
|
269
|
+
changeLanguage(e) {
|
|
270
|
+
e && (this.language = e);
|
|
271
|
+
}
|
|
272
|
+
exists(e, t = { interpolation: {} }) {
|
|
273
|
+
let n = { ...t };
|
|
274
|
+
if (e == null) return !1;
|
|
275
|
+
let r = this.resolve(e, n);
|
|
276
|
+
if (r?.res === void 0) return !1;
|
|
277
|
+
let i = A(r.res);
|
|
278
|
+
return !(n.returnObjects === !1 && i);
|
|
279
|
+
}
|
|
280
|
+
extractFromKey(e, t) {
|
|
281
|
+
let r = t.nsSeparator === void 0 ? this.options.nsSeparator : t.nsSeparator;
|
|
282
|
+
r === void 0 && (r = ":");
|
|
283
|
+
let i = t.keySeparator === void 0 ? this.options.keySeparator : t.keySeparator, a = t.ns || this.options.defaultNS || [], o = r && e.includes(r), s = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !x(e, r, i);
|
|
284
|
+
if (o && !s) {
|
|
285
|
+
let t = e.match(this.interpolator.nestingRegexp);
|
|
286
|
+
if (t && t.length > 0) return {
|
|
287
|
+
key: e,
|
|
288
|
+
namespaces: n(a) ? [a] : a
|
|
289
|
+
};
|
|
290
|
+
let o = e.split(r);
|
|
291
|
+
(r !== i || r === i && this.options.ns.includes(o[0])) && (a = o.shift()), e = o.join(i);
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
key: e,
|
|
295
|
+
namespaces: n(a) ? [a] : a
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
translate(t, r, i) {
|
|
299
|
+
let a = typeof r == "object" ? { ...r } : r;
|
|
300
|
+
if (typeof a != "object" && this.options.overloadTranslationOptionHandler && (a = this.options.overloadTranslationOptionHandler(arguments)), typeof a == "object" && (a = { ...a }), a ||= {}, t == null) return "";
|
|
301
|
+
typeof t == "function" && (t = k(t, {
|
|
302
|
+
...this.options,
|
|
303
|
+
...a
|
|
304
|
+
})), Array.isArray(t) || (t = [String(t)]), t = t.map((e) => typeof e == "function" ? k(e, {
|
|
305
|
+
...this.options,
|
|
306
|
+
...a
|
|
307
|
+
}) : String(e));
|
|
308
|
+
let o = a.returnDetails === void 0 ? this.options.returnDetails : a.returnDetails, s = a.keySeparator === void 0 ? this.options.keySeparator : a.keySeparator, { key: c, namespaces: l } = this.extractFromKey(t[t.length - 1], a), u = l[l.length - 1], d = a.nsSeparator === void 0 ? this.options.nsSeparator : a.nsSeparator;
|
|
309
|
+
d === void 0 && (d = ":");
|
|
310
|
+
let f = a.lng || this.language, p = a.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
311
|
+
if (f?.toLowerCase() === "cimode") return p ? o ? {
|
|
312
|
+
res: `${u}${d}${c}`,
|
|
313
|
+
usedKey: c,
|
|
314
|
+
exactUsedKey: c,
|
|
315
|
+
usedLng: f,
|
|
316
|
+
usedNS: u,
|
|
317
|
+
usedParams: this.getUsedParamsDetails(a)
|
|
318
|
+
} : `${u}${d}${c}` : o ? {
|
|
319
|
+
res: c,
|
|
320
|
+
usedKey: c,
|
|
321
|
+
exactUsedKey: c,
|
|
322
|
+
usedLng: f,
|
|
323
|
+
usedNS: u,
|
|
324
|
+
usedParams: this.getUsedParamsDetails(a)
|
|
325
|
+
} : c;
|
|
326
|
+
let m = this.resolve(t, a), h = m?.res, g = m?.usedKey || c, _ = m?.exactUsedKey || c, v = [
|
|
327
|
+
"[object Number]",
|
|
328
|
+
"[object Function]",
|
|
329
|
+
"[object RegExp]"
|
|
330
|
+
], y = a.joinArrays === void 0 ? this.options.joinArrays : a.joinArrays, b = !this.i18nFormat || this.i18nFormat.handleAsObject, x = a.count !== void 0 && !n(a.count), S = e.hasDefaultValue(a), C = x ? this.pluralResolver.getSuffix(f, a.count, a) : "", ee = a.ordinal && x ? this.pluralResolver.getSuffix(f, a.count, { ordinal: !1 }) : "", w = x && !a.ordinal && a.count === 0, T = w && a[`defaultValue${this.options.pluralSeparator}zero`] || a[`defaultValue${C}`] || a[`defaultValue${ee}`] || a.defaultValue, E = h;
|
|
331
|
+
b && !h && S && (E = T);
|
|
332
|
+
let D = A(E), O = Object.prototype.toString.apply(E);
|
|
333
|
+
if (b && E && D && !v.includes(O) && !(n(y) && Array.isArray(E))) {
|
|
334
|
+
if (!a.returnObjects && !this.options.returnObjects) {
|
|
335
|
+
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
336
|
+
let e = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(g, E, {
|
|
337
|
+
...a,
|
|
338
|
+
ns: l
|
|
339
|
+
}) : `key '${c} (${this.language})' returned an object instead of string.`;
|
|
340
|
+
return o ? (m.res = e, m.usedParams = this.getUsedParamsDetails(a), m) : e;
|
|
341
|
+
}
|
|
342
|
+
if (s) {
|
|
343
|
+
let e = Array.isArray(E), t = e ? [] : {}, n = e ? _ : g;
|
|
344
|
+
for (let e in E) if (Object.prototype.hasOwnProperty.call(E, e)) {
|
|
345
|
+
let r = `${n}${s}${e}`;
|
|
346
|
+
S && !h ? t[e] = this.translate(r, {
|
|
347
|
+
...a,
|
|
348
|
+
defaultValue: A(T) ? T[e] : void 0,
|
|
349
|
+
joinArrays: !1,
|
|
350
|
+
ns: l
|
|
351
|
+
}) : t[e] = this.translate(r, {
|
|
352
|
+
...a,
|
|
353
|
+
joinArrays: !1,
|
|
354
|
+
ns: l
|
|
355
|
+
}), t[e] === r && (t[e] = E[e]);
|
|
356
|
+
}
|
|
357
|
+
h = t;
|
|
358
|
+
}
|
|
359
|
+
} else if (b && n(y) && Array.isArray(h)) h = h.join(y), h &&= this.extendTranslation(h, t, a, i);
|
|
360
|
+
else {
|
|
361
|
+
let e = !1, n = !1;
|
|
362
|
+
!this.isValidLookup(h) && S && (e = !0, h = T), this.isValidLookup(h) || (n = !0, h = c);
|
|
363
|
+
let r = (a.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && n ? void 0 : h, o = S && T !== h && this.options.updateMissing;
|
|
364
|
+
if (n || e || o) {
|
|
365
|
+
if (this.logger.log(o ? "updateKey" : "missingKey", f, u, c, o ? T : h), s) {
|
|
366
|
+
let e = this.resolve(c, {
|
|
367
|
+
...a,
|
|
368
|
+
keySeparator: !1
|
|
369
|
+
});
|
|
370
|
+
e && e.res && this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
|
|
371
|
+
}
|
|
372
|
+
let e = [], t = this.languageUtils.getFallbackCodes(this.options.fallbackLng, a.lng || this.language);
|
|
373
|
+
if (this.options.saveMissingTo === "fallback" && t && t[0]) for (let n = 0; n < t.length; n++) e.push(t[n]);
|
|
374
|
+
else this.options.saveMissingTo === "all" ? e = this.languageUtils.toResolveHierarchy(a.lng || this.language) : e.push(a.lng || this.language);
|
|
375
|
+
let n = (e, t, n) => {
|
|
376
|
+
let i = S && n !== h ? n : r;
|
|
377
|
+
this.options.missingKeyHandler ? this.options.missingKeyHandler(e, u, t, i, o, a) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(e, u, t, i, o, a), this.emit("missingKey", e, u, t, h);
|
|
378
|
+
};
|
|
379
|
+
this.options.saveMissing && (this.options.saveMissingPlurals && x ? e.forEach((e) => {
|
|
380
|
+
let t = this.pluralResolver.getSuffixes(e, a);
|
|
381
|
+
w && a[`defaultValue${this.options.pluralSeparator}zero`] && !t.includes(`${this.options.pluralSeparator}zero`) && t.push(`${this.options.pluralSeparator}zero`), t.forEach((t) => {
|
|
382
|
+
n([e], c + t, a[`defaultValue${t}`] || T);
|
|
383
|
+
});
|
|
384
|
+
}) : n(e, c, T));
|
|
385
|
+
}
|
|
386
|
+
h = this.extendTranslation(h, t, a, m, i), n && h === c && this.options.appendNamespaceToMissingKey && (h = `${u}${d}${c}`), (n || e) && this.options.parseMissingKeyHandler && (h = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${u}${d}${c}` : c, e ? h : void 0, a));
|
|
387
|
+
}
|
|
388
|
+
return o ? (m.res = h, m.usedParams = this.getUsedParamsDetails(a), m) : h;
|
|
389
|
+
}
|
|
390
|
+
extendTranslation(e, t, r, i, a) {
|
|
391
|
+
if (this.i18nFormat?.parse) e = this.i18nFormat.parse(e, {
|
|
392
|
+
...this.options.interpolation.defaultVariables,
|
|
393
|
+
...r
|
|
394
|
+
}, r.lng || this.language || i.usedLng, i.usedNS, i.usedKey, { resolved: i });
|
|
395
|
+
else if (!r.skipInterpolation) {
|
|
396
|
+
r.interpolation && this.interpolator.init({
|
|
397
|
+
...r,
|
|
398
|
+
interpolation: {
|
|
399
|
+
...this.options.interpolation,
|
|
400
|
+
...r.interpolation
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
let o = n(e) && (r?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : r.interpolation.skipOnVariables), s;
|
|
404
|
+
if (o) {
|
|
405
|
+
let t = e.match(this.interpolator.nestingRegexp);
|
|
406
|
+
s = t && t.length;
|
|
407
|
+
}
|
|
408
|
+
let c = r.replace && !n(r.replace) ? r.replace : r;
|
|
409
|
+
if (this.options.interpolation.defaultVariables && (c = {
|
|
410
|
+
...this.options.interpolation.defaultVariables,
|
|
411
|
+
...c
|
|
412
|
+
}), e = this.interpolator.interpolate(e, c, r.lng || this.language || i.usedLng, r), o) {
|
|
413
|
+
let t = e.match(this.interpolator.nestingRegexp), n = t && t.length;
|
|
414
|
+
s < n && (r.nest = !1);
|
|
415
|
+
}
|
|
416
|
+
!r.lng && i && i.res && (r.lng = this.language || i.usedLng), r.nest !== !1 && (e = this.interpolator.nest(e, (...e) => a?.[0] === e[0] && !r.context ? (this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`), null) : this.translate(...e, t), r)), r.interpolation && this.interpolator.reset();
|
|
417
|
+
}
|
|
418
|
+
let o = r.postProcess || this.options.postProcess, s = n(o) ? [o] : o;
|
|
419
|
+
return e != null && s?.length && r.applyPostProcessor !== !1 && (e = D.handle(s, e, t, this.options && this.options.postProcessPassResolved ? {
|
|
420
|
+
i18nResolved: {
|
|
421
|
+
...i,
|
|
422
|
+
usedParams: this.getUsedParamsDetails(r)
|
|
423
|
+
},
|
|
424
|
+
...r
|
|
425
|
+
} : r, this)), e;
|
|
426
|
+
}
|
|
427
|
+
resolve(e, t = {}) {
|
|
428
|
+
let r, i, a, o, s;
|
|
429
|
+
return n(e) && (e = [e]), Array.isArray(e) && (e = e.map((e) => typeof e == "function" ? k(e, {
|
|
430
|
+
...this.options,
|
|
431
|
+
...t
|
|
432
|
+
}) : e)), e.forEach((e) => {
|
|
433
|
+
if (this.isValidLookup(r)) return;
|
|
434
|
+
let c = this.extractFromKey(e, t), l = c.key;
|
|
435
|
+
i = l;
|
|
436
|
+
let u = c.namespaces;
|
|
437
|
+
this.options.fallbackNS && (u = u.concat(this.options.fallbackNS));
|
|
438
|
+
let d = t.count !== void 0 && !n(t.count), f = d && !t.ordinal && t.count === 0, p = t.context !== void 0 && (n(t.context) || typeof t.context == "number") && t.context !== "", m = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
|
|
439
|
+
u.forEach((e) => {
|
|
440
|
+
this.isValidLookup(r) || (s = e, !this.checkedLoadedFor[`${m[0]}-${e}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(s) && (this.checkedLoadedFor[`${m[0]}-${e}`] = !0, this.logger.warn(`key "${i}" for languages "${m.join(", ")}" won't get resolved as namespace "${s}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")), m.forEach((n) => {
|
|
441
|
+
if (this.isValidLookup(r)) return;
|
|
442
|
+
o = n;
|
|
443
|
+
let i = [l];
|
|
444
|
+
if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(i, l, n, e, t);
|
|
445
|
+
else {
|
|
446
|
+
let e;
|
|
447
|
+
d && (e = this.pluralResolver.getSuffix(n, t.count, t));
|
|
448
|
+
let r = `${this.options.pluralSeparator}zero`, a = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
449
|
+
if (d && (t.ordinal && e.startsWith(a) && i.push(l + e.replace(a, this.options.pluralSeparator)), i.push(l + e), f && i.push(l + r)), p) {
|
|
450
|
+
let n = `${l}${this.options.contextSeparator || "_"}${t.context}`;
|
|
451
|
+
i.push(n), d && (t.ordinal && e.startsWith(a) && i.push(n + e.replace(a, this.options.pluralSeparator)), i.push(n + e), f && i.push(n + r));
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
let s;
|
|
455
|
+
for (; s = i.pop();) this.isValidLookup(r) || (a = s, r = this.getResource(n, e, s, t));
|
|
456
|
+
}));
|
|
457
|
+
});
|
|
458
|
+
}), {
|
|
459
|
+
res: r,
|
|
460
|
+
usedKey: i,
|
|
461
|
+
exactUsedKey: a,
|
|
462
|
+
usedLng: o,
|
|
463
|
+
usedNS: s
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
isValidLookup(e) {
|
|
467
|
+
return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
|
|
468
|
+
}
|
|
469
|
+
getResource(e, t, n, r = {}) {
|
|
470
|
+
return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, n, r) : this.resourceStore.getResource(e, t, n, r);
|
|
471
|
+
}
|
|
472
|
+
getUsedParamsDetails(e = {}) {
|
|
473
|
+
let t = [
|
|
474
|
+
"defaultValue",
|
|
475
|
+
"ordinal",
|
|
476
|
+
"context",
|
|
477
|
+
"replace",
|
|
478
|
+
"lng",
|
|
479
|
+
"lngs",
|
|
480
|
+
"fallbackLng",
|
|
481
|
+
"ns",
|
|
482
|
+
"keySeparator",
|
|
483
|
+
"nsSeparator",
|
|
484
|
+
"returnObjects",
|
|
485
|
+
"returnDetails",
|
|
486
|
+
"joinArrays",
|
|
487
|
+
"postProcess",
|
|
488
|
+
"interpolation"
|
|
489
|
+
], r = e.replace && !n(e.replace), i = r ? e.replace : e;
|
|
490
|
+
if (r && e.count !== void 0 && (i.count = e.count), this.options.interpolation.defaultVariables && (i = {
|
|
491
|
+
...this.options.interpolation.defaultVariables,
|
|
492
|
+
...i
|
|
493
|
+
}), !r) {
|
|
494
|
+
i = { ...i };
|
|
495
|
+
for (let e of t) delete i[e];
|
|
496
|
+
}
|
|
497
|
+
return i;
|
|
498
|
+
}
|
|
499
|
+
static hasDefaultValue(e) {
|
|
500
|
+
for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && t.startsWith("defaultValue") && e[t] !== void 0) return !0;
|
|
501
|
+
return !1;
|
|
502
|
+
}
|
|
503
|
+
}, M = class {
|
|
504
|
+
constructor(e) {
|
|
505
|
+
this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = w.create("languageUtils");
|
|
506
|
+
}
|
|
507
|
+
getScriptPartFromCode(e) {
|
|
508
|
+
if (e = C(e), !e || !e.includes("-")) return null;
|
|
509
|
+
let t = e.split("-");
|
|
510
|
+
return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
|
|
511
|
+
}
|
|
512
|
+
getLanguagePartFromCode(e) {
|
|
513
|
+
if (e = C(e), !e || !e.includes("-")) return e;
|
|
514
|
+
let t = e.split("-");
|
|
515
|
+
return this.formatLanguageCode(t[0]);
|
|
516
|
+
}
|
|
517
|
+
formatLanguageCode(e) {
|
|
518
|
+
if (n(e) && e.includes("-")) {
|
|
519
|
+
let t;
|
|
520
|
+
try {
|
|
521
|
+
t = Intl.getCanonicalLocales(e)[0];
|
|
522
|
+
} catch {}
|
|
523
|
+
return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
|
|
524
|
+
}
|
|
525
|
+
return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
|
|
526
|
+
}
|
|
527
|
+
isSupportedCode(e) {
|
|
528
|
+
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.includes(e);
|
|
529
|
+
}
|
|
530
|
+
getBestMatchFromCodes(e) {
|
|
531
|
+
if (!e) return null;
|
|
532
|
+
let t;
|
|
533
|
+
return e.forEach((e) => {
|
|
534
|
+
if (t) return;
|
|
535
|
+
let n = this.formatLanguageCode(e);
|
|
536
|
+
(!this.options.supportedLngs || this.isSupportedCode(n)) && (t = n);
|
|
537
|
+
}), !t && this.options.supportedLngs && e.forEach((e) => {
|
|
538
|
+
if (t) return;
|
|
539
|
+
let n = this.getScriptPartFromCode(e);
|
|
540
|
+
if (this.isSupportedCode(n)) return t = n;
|
|
541
|
+
let r = this.getLanguagePartFromCode(e);
|
|
542
|
+
if (this.isSupportedCode(r)) return t = r;
|
|
543
|
+
t = this.options.supportedLngs.find((e) => e === r ? !0 : !e.includes("-") && !r.includes("-") ? !1 : !!(e.includes("-") && !r.includes("-") && e.slice(0, e.indexOf("-")) === r || e.startsWith(r) && r.length > 1));
|
|
544
|
+
}), t ||= this.getFallbackCodes(this.options.fallbackLng)[0], t;
|
|
545
|
+
}
|
|
546
|
+
getFallbackCodes(e, t) {
|
|
547
|
+
if (!e) return [];
|
|
548
|
+
if (typeof e == "function" && (e = e(t)), n(e) && (e = [e]), Array.isArray(e)) return e;
|
|
549
|
+
if (!t) return e.default || [];
|
|
550
|
+
let r = e[t];
|
|
551
|
+
return r ||= e[this.getScriptPartFromCode(t)], r ||= e[this.formatLanguageCode(t)], r ||= e[this.getLanguagePartFromCode(t)], r ||= e.default, r || [];
|
|
552
|
+
}
|
|
553
|
+
toResolveHierarchy(e, t) {
|
|
554
|
+
let r = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), i = [], a = (e) => {
|
|
555
|
+
e && (this.isSupportedCode(e) ? i.push(e) : this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`));
|
|
556
|
+
};
|
|
557
|
+
return n(e) && (e.includes("-") || e.includes("_")) ? (this.options.load !== "languageOnly" && a(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && a(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && a(this.getLanguagePartFromCode(e))) : n(e) && a(this.formatLanguageCode(e)), r.forEach((e) => {
|
|
558
|
+
i.includes(e) || a(this.formatLanguageCode(e));
|
|
559
|
+
}), i;
|
|
560
|
+
}
|
|
561
|
+
}, N = {
|
|
562
|
+
zero: 0,
|
|
563
|
+
one: 1,
|
|
564
|
+
two: 2,
|
|
565
|
+
few: 3,
|
|
566
|
+
many: 4,
|
|
567
|
+
other: 5
|
|
568
|
+
}, ne = {
|
|
569
|
+
select: (e) => e === 1 ? "one" : "other",
|
|
570
|
+
resolvedOptions: () => ({ pluralCategories: ["one", "other"] })
|
|
571
|
+
}, re = class {
|
|
572
|
+
constructor(e, t = {}) {
|
|
573
|
+
this.languageUtils = e, this.options = t, this.logger = w.create("pluralResolver"), this.pluralRulesCache = {};
|
|
574
|
+
}
|
|
575
|
+
clearCache() {
|
|
576
|
+
this.pluralRulesCache = {};
|
|
577
|
+
}
|
|
578
|
+
getRule(e, t = {}) {
|
|
579
|
+
let n = C(e === "dev" ? "en" : e), r = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({
|
|
580
|
+
cleanedCode: n,
|
|
581
|
+
type: r
|
|
582
|
+
});
|
|
583
|
+
if (i in this.pluralRulesCache) return this.pluralRulesCache[i];
|
|
584
|
+
let a;
|
|
585
|
+
try {
|
|
586
|
+
a = new Intl.PluralRules(n, { type: r });
|
|
587
|
+
} catch {
|
|
588
|
+
if (typeof Intl > "u") return this.logger.error("No Intl support, please use an Intl polyfill!"), ne;
|
|
589
|
+
if (!e.match(/-|_/)) return ne;
|
|
590
|
+
let n = this.languageUtils.getLanguagePartFromCode(e);
|
|
591
|
+
a = this.getRule(n, t);
|
|
592
|
+
}
|
|
593
|
+
return this.pluralRulesCache[i] = a, a;
|
|
594
|
+
}
|
|
595
|
+
needsPlural(e, t = {}) {
|
|
596
|
+
let n = this.getRule(e, t);
|
|
597
|
+
return n ||= this.getRule("dev", t), n?.resolvedOptions().pluralCategories.length > 1;
|
|
598
|
+
}
|
|
599
|
+
getPluralFormsOfKey(e, t, n = {}) {
|
|
600
|
+
return this.getSuffixes(e, n).map((e) => `${t}${e}`);
|
|
601
|
+
}
|
|
602
|
+
getSuffixes(e, t = {}) {
|
|
603
|
+
let n = this.getRule(e, t);
|
|
604
|
+
return n ||= this.getRule("dev", t), n ? n.resolvedOptions().pluralCategories.sort((e, t) => N[e] - N[t]).map((e) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${e}`) : [];
|
|
605
|
+
}
|
|
606
|
+
getSuffix(e, t, n = {}) {
|
|
607
|
+
let r = this.getRule(e, n);
|
|
608
|
+
return r ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${r.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, n));
|
|
609
|
+
}
|
|
610
|
+
}, ie = (e, t, r, i = ".", a = !0) => {
|
|
611
|
+
let o = p(e, t, r);
|
|
612
|
+
return !o && a && n(r) && (o = S(e, r, i), o === void 0 && (o = S(t, r, i))), o;
|
|
613
|
+
}, P = (e) => e.replace(/\$/g, "$$$$"), ae = class {
|
|
614
|
+
constructor(e = {}) {
|
|
615
|
+
this.logger = w.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((e) => e), this.init(e);
|
|
616
|
+
}
|
|
617
|
+
init(e = {}) {
|
|
618
|
+
e.interpolation ||= { escapeValue: !0 };
|
|
619
|
+
let { escape: t, escapeValue: n, useRawValueToEscape: r, prefix: i, prefixEscaped: a, suffix: o, suffixEscaped: s, formatSeparator: c, unescapeSuffix: l, unescapePrefix: u, nestingPrefix: d, nestingPrefixEscaped: f, nestingSuffix: p, nestingSuffixEscaped: m, nestingOptionsSeparator: g, maxReplaces: v, alwaysFormat: y } = e.interpolation;
|
|
620
|
+
this.escape = t === void 0 ? _ : t, this.escapeValue = n === void 0 ? !0 : n, this.useRawValueToEscape = r === void 0 ? !1 : r, this.prefix = i ? h(i) : a || "{{", this.suffix = o ? h(o) : s || "}}", this.formatSeparator = c || ",", this.unescapePrefix = l ? "" : u || "-", this.unescapeSuffix = this.unescapePrefix ? "" : l || "", this.nestingPrefix = d ? h(d) : f || h("$t("), this.nestingSuffix = p ? h(p) : m || h(")"), this.nestingOptionsSeparator = g || ",", this.maxReplaces = v || 1e3, this.alwaysFormat = y === void 0 ? !1 : y, this.resetRegExp();
|
|
621
|
+
}
|
|
622
|
+
reset() {
|
|
623
|
+
this.options && this.init(this.options);
|
|
624
|
+
}
|
|
625
|
+
resetRegExp() {
|
|
626
|
+
let e = (e, t) => e?.source === t ? (e.lastIndex = 0, e) : new RegExp(t, "g");
|
|
627
|
+
this.regexp = e(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = e(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = e(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
|
|
628
|
+
}
|
|
629
|
+
interpolate(e, t, r, a) {
|
|
630
|
+
let o, s, c, l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (e) => {
|
|
631
|
+
if (!e.includes(this.formatSeparator)) {
|
|
632
|
+
let n = ie(t, l, e, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
633
|
+
return this.alwaysFormat ? this.format(n, void 0, r, {
|
|
634
|
+
...a,
|
|
635
|
+
...t,
|
|
636
|
+
interpolationkey: e
|
|
637
|
+
}) : n;
|
|
638
|
+
}
|
|
639
|
+
let n = e.split(this.formatSeparator), i = n.shift().trim(), o = n.join(this.formatSeparator).trim();
|
|
640
|
+
return this.format(ie(t, l, i, this.options.keySeparator, this.options.ignoreJSONStructure), o, r, {
|
|
641
|
+
...a,
|
|
642
|
+
...t,
|
|
643
|
+
interpolationkey: i
|
|
644
|
+
});
|
|
645
|
+
};
|
|
646
|
+
this.resetRegExp();
|
|
647
|
+
let d = a?.missingInterpolationHandler || this.options.missingInterpolationHandler, f = a?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : a.interpolation.skipOnVariables;
|
|
648
|
+
return [{
|
|
649
|
+
regex: this.regexpUnescape,
|
|
650
|
+
safeValue: (e) => P(e)
|
|
651
|
+
}, {
|
|
652
|
+
regex: this.regexp,
|
|
653
|
+
safeValue: (e) => this.escapeValue ? P(this.escape(e)) : P(e)
|
|
654
|
+
}].forEach((t) => {
|
|
655
|
+
for (c = 0; o = t.regex.exec(e);) {
|
|
656
|
+
let r = o[1].trim();
|
|
657
|
+
if (s = u(r), s === void 0) if (typeof d == "function") {
|
|
658
|
+
let t = d(e, o, a);
|
|
659
|
+
s = n(t) ? t : "";
|
|
660
|
+
} else if (a && Object.prototype.hasOwnProperty.call(a, r)) s = "";
|
|
661
|
+
else if (f) {
|
|
662
|
+
s = o[0];
|
|
663
|
+
continue;
|
|
664
|
+
} else this.logger.warn(`missed to pass in variable ${r} for interpolating ${e}`), s = "";
|
|
665
|
+
else !n(s) && !this.useRawValueToEscape && (s = i(s));
|
|
666
|
+
let l = t.safeValue(s);
|
|
667
|
+
if (e = e.replace(o[0], l), f ? (t.regex.lastIndex += s.length, t.regex.lastIndex -= o[0].length) : t.regex.lastIndex = 0, c++, c >= this.maxReplaces) break;
|
|
668
|
+
}
|
|
669
|
+
}), e;
|
|
670
|
+
}
|
|
671
|
+
nest(e, t, r = {}) {
|
|
672
|
+
let a, o, s, c = (e, t) => {
|
|
673
|
+
let n = this.nestingOptionsSeparator;
|
|
674
|
+
if (!e.includes(n)) return e;
|
|
675
|
+
let r = e.split(RegExp(`${h(n)}[ ]*{`)), i = `{${r[1]}`;
|
|
676
|
+
e = r[0], i = this.interpolate(i, s);
|
|
677
|
+
let a = i.match(/'/g), o = i.match(/"/g);
|
|
678
|
+
((a?.length ?? 0) % 2 == 0 && !o || (o?.length ?? 0) % 2 != 0) && (i = i.replace(/'/g, "\""));
|
|
679
|
+
try {
|
|
680
|
+
s = JSON.parse(i), t && (s = {
|
|
681
|
+
...t,
|
|
682
|
+
...s
|
|
683
|
+
});
|
|
684
|
+
} catch (t) {
|
|
685
|
+
return this.logger.warn(`failed parsing options string in nesting for key ${e}`, t), `${e}${n}${i}`;
|
|
686
|
+
}
|
|
687
|
+
return s.defaultValue && s.defaultValue.includes(this.prefix) && delete s.defaultValue, e;
|
|
688
|
+
};
|
|
689
|
+
for (; a = this.nestingRegexp.exec(e);) {
|
|
690
|
+
let l = [];
|
|
691
|
+
s = { ...r }, s = s.replace && !n(s.replace) ? s.replace : s, s.applyPostProcessor = !1, delete s.defaultValue;
|
|
692
|
+
let u = /{.*}/.test(a[1]) ? a[1].lastIndexOf("}") + 1 : a[1].indexOf(this.formatSeparator);
|
|
693
|
+
if (u !== -1 && (l = a[1].slice(u).split(this.formatSeparator).map((e) => e.trim()).filter(Boolean), a[1] = a[1].slice(0, u)), o = t(c.call(this, a[1].trim(), s), s), o && a[0] === e && !n(o)) return o;
|
|
694
|
+
n(o) || (o = i(o)), o ||= (this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`), ""), l.length && (o = l.reduce((e, t) => this.format(e, t, r.lng, {
|
|
695
|
+
...r,
|
|
696
|
+
interpolationkey: a[1].trim()
|
|
697
|
+
}), o.trim())), e = e.replace(a[0], o), this.regexp.lastIndex = 0;
|
|
698
|
+
}
|
|
699
|
+
return e;
|
|
700
|
+
}
|
|
701
|
+
}, oe = (e) => {
|
|
702
|
+
let t = e.toLowerCase().trim(), n = {};
|
|
703
|
+
if (e.includes("(")) {
|
|
704
|
+
let r = e.split("(");
|
|
705
|
+
t = r[0].toLowerCase().trim();
|
|
706
|
+
let i = r[1].slice(0, -1);
|
|
707
|
+
t === "currency" && !i.includes(":") ? n.currency ||= i.trim() : t === "relativetime" && !i.includes(":") ? n.range ||= i.trim() : i.split(";").forEach((e) => {
|
|
708
|
+
if (e) {
|
|
709
|
+
let [t, ...r] = e.split(":"), i = r.join(":").trim().replace(/^'+|'+$/g, ""), a = t.trim();
|
|
710
|
+
n[a] || (n[a] = i), i === "false" && (n[a] = !1), i === "true" && (n[a] = !0), isNaN(i) || (n[a] = parseInt(i, 10));
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
return {
|
|
715
|
+
formatName: t,
|
|
716
|
+
formatOptions: n
|
|
717
|
+
};
|
|
718
|
+
}, se = (e) => {
|
|
719
|
+
let t = {};
|
|
720
|
+
return (n, r, i) => {
|
|
721
|
+
let a = i;
|
|
722
|
+
i && i.interpolationkey && i.formatParams && i.formatParams[i.interpolationkey] && i[i.interpolationkey] && (a = {
|
|
723
|
+
...a,
|
|
724
|
+
[i.interpolationkey]: void 0
|
|
725
|
+
});
|
|
726
|
+
let o = r + JSON.stringify(a), s = t[o];
|
|
727
|
+
return s || (s = e(C(r), i), t[o] = s), s(n);
|
|
728
|
+
};
|
|
729
|
+
}, ce = (e) => (t, n, r) => e(C(n), r)(t), le = class {
|
|
730
|
+
constructor(e = {}) {
|
|
731
|
+
this.logger = w.create("formatter"), this.options = e, this.init(e);
|
|
732
|
+
}
|
|
733
|
+
init(e, t = { interpolation: {} }) {
|
|
734
|
+
this.formatSeparator = t.interpolation.formatSeparator || ",";
|
|
735
|
+
let n = t.cacheInBuiltFormats ? se : ce;
|
|
736
|
+
this.formats = {
|
|
737
|
+
number: n((e, t) => {
|
|
738
|
+
let n = new Intl.NumberFormat(e, { ...t });
|
|
739
|
+
return (e) => n.format(e);
|
|
740
|
+
}),
|
|
741
|
+
currency: n((e, t) => {
|
|
742
|
+
let n = new Intl.NumberFormat(e, {
|
|
743
|
+
...t,
|
|
744
|
+
style: "currency"
|
|
745
|
+
});
|
|
746
|
+
return (e) => n.format(e);
|
|
747
|
+
}),
|
|
748
|
+
datetime: n((e, t) => {
|
|
749
|
+
let n = new Intl.DateTimeFormat(e, { ...t });
|
|
750
|
+
return (e) => n.format(e);
|
|
751
|
+
}),
|
|
752
|
+
relativetime: n((e, t) => {
|
|
753
|
+
let n = new Intl.RelativeTimeFormat(e, { ...t });
|
|
754
|
+
return (e) => n.format(e, t.range || "day");
|
|
755
|
+
}),
|
|
756
|
+
list: n((e, t) => {
|
|
757
|
+
let n = new Intl.ListFormat(e, { ...t });
|
|
758
|
+
return (e) => n.format(e);
|
|
759
|
+
})
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
add(e, t) {
|
|
763
|
+
this.formats[e.toLowerCase().trim()] = t;
|
|
764
|
+
}
|
|
765
|
+
addCached(e, t) {
|
|
766
|
+
this.formats[e.toLowerCase().trim()] = se(t);
|
|
767
|
+
}
|
|
768
|
+
format(e, t, n, r = {}) {
|
|
769
|
+
if (!t || e == null) return e;
|
|
770
|
+
let i = t.split(this.formatSeparator);
|
|
771
|
+
if (i.length > 1 && i[0].indexOf("(") > 1 && !i[0].includes(")") && i.find((e) => e.includes(")"))) {
|
|
772
|
+
let e = i.findIndex((e) => e.includes(")"));
|
|
773
|
+
i[0] = [i[0], ...i.splice(1, e)].join(this.formatSeparator);
|
|
774
|
+
}
|
|
775
|
+
return i.reduce((e, t) => {
|
|
776
|
+
let { formatName: i, formatOptions: a } = oe(t);
|
|
777
|
+
if (this.formats[i]) {
|
|
778
|
+
let t = e;
|
|
779
|
+
try {
|
|
780
|
+
let o = r?.formatParams?.[r.interpolationkey] || {}, s = o.locale || o.lng || r.locale || r.lng || n;
|
|
781
|
+
t = this.formats[i](e, s, {
|
|
782
|
+
...a,
|
|
783
|
+
...r,
|
|
784
|
+
...o
|
|
785
|
+
});
|
|
786
|
+
} catch (e) {
|
|
787
|
+
this.logger.warn(e);
|
|
788
|
+
}
|
|
789
|
+
return t;
|
|
790
|
+
} else this.logger.warn(`there was no format function for ${i}`);
|
|
791
|
+
return e;
|
|
792
|
+
}, e);
|
|
793
|
+
}
|
|
794
|
+
}, ue = (e, t) => {
|
|
795
|
+
e.pending[t] !== void 0 && (delete e.pending[t], e.pendingCount--);
|
|
796
|
+
}, de = class extends T {
|
|
797
|
+
constructor(e, t, n, r = {}) {
|
|
798
|
+
super(), this.backend = e, this.store = t, this.services = n, this.languageUtils = n.languageUtils, this.options = r, this.logger = w.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = r.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = r.maxRetries >= 0 ? r.maxRetries : 5, this.retryTimeout = r.retryTimeout >= 1 ? r.retryTimeout : 350, this.state = {}, this.queue = [], this.backend?.init?.(n, r.backend, r);
|
|
799
|
+
}
|
|
800
|
+
queueLoad(e, t, n, r) {
|
|
801
|
+
let i = {}, a = {}, o = {}, s = {};
|
|
802
|
+
return e.forEach((e) => {
|
|
803
|
+
let r = !0;
|
|
804
|
+
t.forEach((t) => {
|
|
805
|
+
let o = `${e}|${t}`;
|
|
806
|
+
!n.reload && this.store.hasResourceBundle(e, t) ? this.state[o] = 2 : this.state[o] < 0 || (this.state[o] === 1 ? a[o] === void 0 && (a[o] = !0) : (this.state[o] = 1, r = !1, a[o] === void 0 && (a[o] = !0), i[o] === void 0 && (i[o] = !0), s[t] === void 0 && (s[t] = !0)));
|
|
807
|
+
}), r || (o[e] = !0);
|
|
808
|
+
}), (Object.keys(i).length || Object.keys(a).length) && this.queue.push({
|
|
809
|
+
pending: a,
|
|
810
|
+
pendingCount: Object.keys(a).length,
|
|
811
|
+
loaded: {},
|
|
812
|
+
errors: [],
|
|
813
|
+
callback: r
|
|
814
|
+
}), {
|
|
815
|
+
toLoad: Object.keys(i),
|
|
816
|
+
pending: Object.keys(a),
|
|
817
|
+
toLoadLanguages: Object.keys(o),
|
|
818
|
+
toLoadNamespaces: Object.keys(s)
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
loaded(e, t, n) {
|
|
822
|
+
let r = e.split("|"), i = r[0], a = r[1];
|
|
823
|
+
t && this.emit("failedLoading", i, a, t), !t && n && this.store.addResourceBundle(i, a, n, void 0, void 0, { skipCopy: !0 }), this.state[e] = t ? -1 : 2, t && n && (this.state[e] = 0);
|
|
824
|
+
let o = {};
|
|
825
|
+
this.queue.forEach((n) => {
|
|
826
|
+
d(n.loaded, [i], a), ue(n, e), t && n.errors.push(t), n.pendingCount === 0 && !n.done && (Object.keys(n.loaded).forEach((e) => {
|
|
827
|
+
o[e] || (o[e] = {});
|
|
828
|
+
let t = n.loaded[e];
|
|
829
|
+
t.length && t.forEach((t) => {
|
|
830
|
+
o[e][t] === void 0 && (o[e][t] = !0);
|
|
831
|
+
});
|
|
832
|
+
}), n.done = !0, n.errors.length ? n.callback(n.errors) : n.callback());
|
|
833
|
+
}), this.emit("loaded", o), this.queue = this.queue.filter((e) => !e.done);
|
|
834
|
+
}
|
|
835
|
+
read(e, t, n, r = 0, i = this.retryTimeout, a) {
|
|
836
|
+
if (!e.length) return a(null, {});
|
|
837
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
|
838
|
+
this.waitingReads.push({
|
|
839
|
+
lng: e,
|
|
840
|
+
ns: t,
|
|
841
|
+
fcName: n,
|
|
842
|
+
tried: r,
|
|
843
|
+
wait: i,
|
|
844
|
+
callback: a
|
|
845
|
+
});
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
this.readingCalls++;
|
|
849
|
+
let o = (o, s) => {
|
|
850
|
+
if (this.readingCalls--, this.waitingReads.length > 0) {
|
|
851
|
+
let e = this.waitingReads.shift();
|
|
852
|
+
this.read(e.lng, e.ns, e.fcName, e.tried, e.wait, e.callback);
|
|
853
|
+
}
|
|
854
|
+
if (o && s && r < this.maxRetries) {
|
|
855
|
+
setTimeout(() => {
|
|
856
|
+
this.read(e, t, n, r + 1, i * 2, a);
|
|
857
|
+
}, i);
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
a(o, s);
|
|
861
|
+
}, s = this.backend[n].bind(this.backend);
|
|
862
|
+
if (s.length === 2) {
|
|
863
|
+
try {
|
|
864
|
+
let n = s(e, t);
|
|
865
|
+
n && typeof n.then == "function" ? n.then((e) => o(null, e)).catch(o) : o(null, n);
|
|
866
|
+
} catch (e) {
|
|
867
|
+
o(e);
|
|
868
|
+
}
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
return s(e, t, o);
|
|
872
|
+
}
|
|
873
|
+
prepareLoading(e, t, r = {}, i) {
|
|
874
|
+
if (!this.backend) return this.logger.warn("No backend was added via i18next.use. Will not load resources."), i && i();
|
|
875
|
+
n(e) && (e = this.languageUtils.toResolveHierarchy(e)), n(t) && (t = [t]);
|
|
876
|
+
let a = this.queueLoad(e, t, r, i);
|
|
877
|
+
if (!a.toLoad.length) return a.pending.length || i(), null;
|
|
878
|
+
a.toLoad.forEach((e) => {
|
|
879
|
+
this.loadOne(e);
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
load(e, t, n) {
|
|
883
|
+
this.prepareLoading(e, t, {}, n);
|
|
884
|
+
}
|
|
885
|
+
reload(e, t, n) {
|
|
886
|
+
this.prepareLoading(e, t, { reload: !0 }, n);
|
|
887
|
+
}
|
|
888
|
+
loadOne(e, t = "") {
|
|
889
|
+
let n = e.split("|"), r = n[0], i = n[1];
|
|
890
|
+
this.read(r, i, "read", void 0, void 0, (n, a) => {
|
|
891
|
+
n && this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`, n), !n && a && this.logger.log(`${t}loaded namespace ${i} for language ${r}`, a), this.loaded(e, n, a);
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
saveMissing(e, t, n, r, i, a = {}, o = () => {}) {
|
|
895
|
+
if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) {
|
|
896
|
+
this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
if (!(n == null || n === "")) {
|
|
900
|
+
if (this.backend?.create) {
|
|
901
|
+
let s = {
|
|
902
|
+
...a,
|
|
903
|
+
isUpdate: i
|
|
904
|
+
}, c = this.backend.create.bind(this.backend);
|
|
905
|
+
if (c.length < 6) try {
|
|
906
|
+
let i;
|
|
907
|
+
i = c.length === 5 ? c(e, t, n, r, s) : c(e, t, n, r), i && typeof i.then == "function" ? i.then((e) => o(null, e)).catch(o) : o(null, i);
|
|
908
|
+
} catch (e) {
|
|
909
|
+
o(e);
|
|
910
|
+
}
|
|
911
|
+
else c(e, t, n, r, o, s);
|
|
912
|
+
}
|
|
913
|
+
!e || !e[0] || this.store.addResource(e[0], t, n, r);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}, F = () => ({
|
|
917
|
+
debug: !1,
|
|
918
|
+
initAsync: !0,
|
|
919
|
+
ns: ["translation"],
|
|
920
|
+
defaultNS: ["translation"],
|
|
921
|
+
fallbackLng: ["dev"],
|
|
922
|
+
fallbackNS: !1,
|
|
923
|
+
supportedLngs: !1,
|
|
924
|
+
nonExplicitSupportedLngs: !1,
|
|
925
|
+
load: "all",
|
|
926
|
+
preload: !1,
|
|
927
|
+
keySeparator: ".",
|
|
928
|
+
nsSeparator: ":",
|
|
929
|
+
pluralSeparator: "_",
|
|
930
|
+
contextSeparator: "_",
|
|
931
|
+
partialBundledLanguages: !1,
|
|
932
|
+
saveMissing: !1,
|
|
933
|
+
updateMissing: !1,
|
|
934
|
+
saveMissingTo: "fallback",
|
|
935
|
+
saveMissingPlurals: !0,
|
|
936
|
+
missingKeyHandler: !1,
|
|
937
|
+
missingInterpolationHandler: !1,
|
|
938
|
+
postProcess: !1,
|
|
939
|
+
postProcessPassResolved: !1,
|
|
940
|
+
returnNull: !1,
|
|
941
|
+
returnEmptyString: !0,
|
|
942
|
+
returnObjects: !1,
|
|
943
|
+
joinArrays: !1,
|
|
944
|
+
returnedObjectHandler: !1,
|
|
945
|
+
parseMissingKeyHandler: !1,
|
|
946
|
+
appendNamespaceToMissingKey: !1,
|
|
947
|
+
appendNamespaceToCIMode: !1,
|
|
948
|
+
overloadTranslationOptionHandler: (e) => {
|
|
949
|
+
let t = {};
|
|
950
|
+
if (typeof e[1] == "object" && (t = e[1]), n(e[1]) && (t.defaultValue = e[1]), n(e[2]) && (t.tDescription = e[2]), typeof e[2] == "object" || typeof e[3] == "object") {
|
|
951
|
+
let n = e[3] || e[2];
|
|
952
|
+
Object.keys(n).forEach((e) => {
|
|
953
|
+
t[e] = n[e];
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
return t;
|
|
957
|
+
},
|
|
958
|
+
interpolation: {
|
|
959
|
+
escapeValue: !0,
|
|
960
|
+
prefix: "{{",
|
|
961
|
+
suffix: "}}",
|
|
962
|
+
formatSeparator: ",",
|
|
963
|
+
unescapePrefix: "-",
|
|
964
|
+
nestingPrefix: "$t(",
|
|
965
|
+
nestingSuffix: ")",
|
|
966
|
+
nestingOptionsSeparator: ",",
|
|
967
|
+
maxReplaces: 1e3,
|
|
968
|
+
skipOnVariables: !0
|
|
969
|
+
},
|
|
970
|
+
cacheInBuiltFormats: !0
|
|
971
|
+
}), I = (e) => (n(e.ns) && (e.ns = [e.ns]), n(e.fallbackLng) && (e.fallbackLng = [e.fallbackLng]), n(e.fallbackNS) && (e.fallbackNS = [e.fallbackNS]), e.supportedLngs && !e.supportedLngs.includes("cimode") && (e.supportedLngs = e.supportedLngs.concat(["cimode"])), e), L = () => {}, fe = (e) => {
|
|
972
|
+
Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((t) => {
|
|
973
|
+
typeof e[t] == "function" && (e[t] = e[t].bind(e));
|
|
974
|
+
});
|
|
975
|
+
}, R = class e extends T {
|
|
976
|
+
constructor(e = {}, t) {
|
|
977
|
+
if (super(), this.options = I(e), this.services = {}, this.logger = w, this.modules = { external: [] }, fe(this), t && !this.isInitialized && !e.isClone) {
|
|
978
|
+
if (!this.options.initAsync) return this.init(e, t), this;
|
|
979
|
+
setTimeout(() => {
|
|
980
|
+
this.init(e, t);
|
|
981
|
+
}, 0);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
init(e = {}, t) {
|
|
985
|
+
this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (n(e.ns) ? e.defaultNS = e.ns : e.ns.includes("translation") || (e.defaultNS = e.ns[0]));
|
|
986
|
+
let i = F();
|
|
987
|
+
this.options = {
|
|
988
|
+
...i,
|
|
989
|
+
...this.options,
|
|
990
|
+
...I(e)
|
|
991
|
+
}, this.options.interpolation = {
|
|
992
|
+
...i.interpolation,
|
|
993
|
+
...this.options.interpolation
|
|
994
|
+
}, e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator), typeof this.options.overloadTranslationOptionHandler != "function" && (this.options.overloadTranslationOptionHandler = i.overloadTranslationOptionHandler);
|
|
995
|
+
let a = (e) => e ? typeof e == "function" ? new e() : e : null;
|
|
996
|
+
if (!this.options.isClone) {
|
|
997
|
+
this.modules.logger ? w.init(a(this.modules.logger), this.options) : w.init(null, this.options);
|
|
998
|
+
let e;
|
|
999
|
+
e = this.modules.formatter ? this.modules.formatter : le;
|
|
1000
|
+
let t = new M(this.options);
|
|
1001
|
+
this.store = new E(this.options.resources, this.options);
|
|
1002
|
+
let n = this.services;
|
|
1003
|
+
n.logger = w, n.resourceStore = this.store, n.languageUtils = t, n.pluralResolver = new re(t, { prepend: this.options.pluralSeparator }), e && (n.formatter = a(e), n.formatter.init && n.formatter.init(n, this.options), this.options.interpolation.format = n.formatter.format.bind(n.formatter)), n.interpolator = new ae(this.options), n.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) }, n.backendConnector = new de(a(this.modules.backend), n.resourceStore, n, this.options), n.backendConnector.on("*", (e, ...t) => {
|
|
1004
|
+
this.emit(e, ...t);
|
|
1005
|
+
}), this.modules.languageDetector && (n.languageDetector = a(this.modules.languageDetector), n.languageDetector.init && n.languageDetector.init(n, this.options.detection, this.options)), this.modules.i18nFormat && (n.i18nFormat = a(this.modules.i18nFormat), n.i18nFormat.init && n.i18nFormat.init(this)), this.translator = new j(this.services, this.options), this.translator.on("*", (e, ...t) => {
|
|
1006
|
+
this.emit(e, ...t);
|
|
1007
|
+
}), this.modules.external.forEach((e) => {
|
|
1008
|
+
e.init && e.init(this);
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
if (this.format = this.options.interpolation.format, t ||= L, this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
1012
|
+
let e = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
1013
|
+
e.length > 0 && e[0] !== "dev" && (this.options.lng = e[0]);
|
|
1014
|
+
}
|
|
1015
|
+
!this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), [
|
|
1016
|
+
"getResource",
|
|
1017
|
+
"hasResourceBundle",
|
|
1018
|
+
"getResourceBundle",
|
|
1019
|
+
"getDataByLanguage"
|
|
1020
|
+
].forEach((e) => {
|
|
1021
|
+
this[e] = (...t) => this.store[e](...t);
|
|
1022
|
+
}), [
|
|
1023
|
+
"addResource",
|
|
1024
|
+
"addResources",
|
|
1025
|
+
"addResourceBundle",
|
|
1026
|
+
"removeResourceBundle"
|
|
1027
|
+
].forEach((e) => {
|
|
1028
|
+
this[e] = (...t) => (this.store[e](...t), this);
|
|
1029
|
+
});
|
|
1030
|
+
let o = r(), s = () => {
|
|
1031
|
+
let e = (e, n) => {
|
|
1032
|
+
this.isInitializing = !1, this.isInitialized && !this.initializedStoreOnce && this.logger.warn("init: i18next is already initialized. You should call init just once!"), this.isInitialized = !0, this.options.isClone || this.logger.log("initialized", this.options), this.emit("initialized", this.options), o.resolve(n), t(e, n);
|
|
1033
|
+
};
|
|
1034
|
+
if (this.languages && !this.isInitialized) return e(null, this.t.bind(this));
|
|
1035
|
+
this.changeLanguage(this.options.lng, e);
|
|
1036
|
+
};
|
|
1037
|
+
return this.options.resources || !this.options.initAsync ? s() : setTimeout(s, 0), o;
|
|
1038
|
+
}
|
|
1039
|
+
loadResources(e, t = L) {
|
|
1040
|
+
let r = t, i = n(e) ? e : this.language;
|
|
1041
|
+
if (typeof e == "function" && (r = e), !this.options.resources || this.options.partialBundledLanguages) {
|
|
1042
|
+
if (i?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return r();
|
|
1043
|
+
let e = [], t = (t) => {
|
|
1044
|
+
t && t !== "cimode" && this.services.languageUtils.toResolveHierarchy(t).forEach((t) => {
|
|
1045
|
+
t !== "cimode" && (e.includes(t) || e.push(t));
|
|
1046
|
+
});
|
|
1047
|
+
};
|
|
1048
|
+
i ? t(i) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((e) => t(e)), this.options.preload?.forEach?.((e) => t(e)), this.services.backendConnector.load(e, this.options.ns, (e) => {
|
|
1049
|
+
!e && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), r(e);
|
|
1050
|
+
});
|
|
1051
|
+
} else r(null);
|
|
1052
|
+
}
|
|
1053
|
+
reloadResources(e, t, n) {
|
|
1054
|
+
let i = r();
|
|
1055
|
+
return typeof e == "function" && (n = e, e = void 0), typeof t == "function" && (n = t, t = void 0), e ||= this.languages, t ||= this.options.ns, n ||= L, this.services.backendConnector.reload(e, t, (e) => {
|
|
1056
|
+
i.resolve(), n(e);
|
|
1057
|
+
}), i;
|
|
1058
|
+
}
|
|
1059
|
+
use(e) {
|
|
1060
|
+
if (!e) throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
|
|
1061
|
+
if (!e.type) throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
|
|
1062
|
+
return e.type === "backend" && (this.modules.backend = e), (e.type === "logger" || e.log && e.warn && e.error) && (this.modules.logger = e), e.type === "languageDetector" && (this.modules.languageDetector = e), e.type === "i18nFormat" && (this.modules.i18nFormat = e), e.type === "postProcessor" && D.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
|
|
1063
|
+
}
|
|
1064
|
+
setResolvedLanguage(e) {
|
|
1065
|
+
if (!(!e || !this.languages) && !["cimode", "dev"].includes(e)) {
|
|
1066
|
+
for (let e = 0; e < this.languages.length; e++) {
|
|
1067
|
+
let t = this.languages[e];
|
|
1068
|
+
if (!["cimode", "dev"].includes(t) && this.store.hasLanguageSomeTranslations(t)) {
|
|
1069
|
+
this.resolvedLanguage = t;
|
|
1070
|
+
break;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
!this.resolvedLanguage && !this.languages.includes(e) && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
changeLanguage(e, t) {
|
|
1077
|
+
this.isLanguageChangingTo = e;
|
|
1078
|
+
let i = r();
|
|
1079
|
+
this.emit("languageChanging", e);
|
|
1080
|
+
let a = (e) => {
|
|
1081
|
+
this.language = e, this.languages = this.services.languageUtils.toResolveHierarchy(e), this.resolvedLanguage = void 0, this.setResolvedLanguage(e);
|
|
1082
|
+
}, o = (n, r) => {
|
|
1083
|
+
r ? this.isLanguageChangingTo === e && (a(r), this.translator.changeLanguage(r), this.isLanguageChangingTo = void 0, this.emit("languageChanged", r), this.logger.log("languageChanged", r)) : this.isLanguageChangingTo = void 0, i.resolve((...e) => this.t(...e)), t && t(n, (...e) => this.t(...e));
|
|
1084
|
+
}, s = (t) => {
|
|
1085
|
+
!e && !t && this.services.languageDetector && (t = []);
|
|
1086
|
+
let r = n(t) ? t : t && t[0], i = this.store.hasLanguageSomeTranslations(r) ? r : this.services.languageUtils.getBestMatchFromCodes(n(t) ? [t] : t);
|
|
1087
|
+
i && (this.language || a(i), this.translator.language || this.translator.changeLanguage(i), this.services.languageDetector?.cacheUserLanguage?.(i)), this.loadResources(i, (e) => {
|
|
1088
|
+
o(e, i);
|
|
1089
|
+
});
|
|
1090
|
+
};
|
|
1091
|
+
return !e && this.services.languageDetector && !this.services.languageDetector.async ? s(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(s) : this.services.languageDetector.detect(s) : s(e), i;
|
|
1092
|
+
}
|
|
1093
|
+
getFixedT(e, t, r) {
|
|
1094
|
+
let i = (e, t, ...n) => {
|
|
1095
|
+
let a;
|
|
1096
|
+
a = typeof t == "object" ? { ...t } : this.options.overloadTranslationOptionHandler([e, t].concat(n)), a.lng = a.lng || i.lng, a.lngs = a.lngs || i.lngs, a.ns = a.ns || i.ns, a.keyPrefix !== "" && (a.keyPrefix = a.keyPrefix || r || i.keyPrefix);
|
|
1097
|
+
let o = {
|
|
1098
|
+
...this.options,
|
|
1099
|
+
...a
|
|
1100
|
+
};
|
|
1101
|
+
typeof a.keyPrefix == "function" && (a.keyPrefix = k(a.keyPrefix, o));
|
|
1102
|
+
let s = this.options.keySeparator || ".", c;
|
|
1103
|
+
return a.keyPrefix && Array.isArray(e) ? c = e.map((e) => (typeof e == "function" && (e = k(e, o)), `${a.keyPrefix}${s}${e}`)) : (typeof e == "function" && (e = k(e, o)), c = a.keyPrefix ? `${a.keyPrefix}${s}${e}` : e), this.t(c, a);
|
|
1104
|
+
};
|
|
1105
|
+
return n(e) ? i.lng = e : i.lngs = e, i.ns = t, i.keyPrefix = r, i;
|
|
1106
|
+
}
|
|
1107
|
+
t(...e) {
|
|
1108
|
+
return this.translator?.translate(...e);
|
|
1109
|
+
}
|
|
1110
|
+
exists(...e) {
|
|
1111
|
+
return this.translator?.exists(...e);
|
|
1112
|
+
}
|
|
1113
|
+
setDefaultNamespace(e) {
|
|
1114
|
+
this.options.defaultNS = e;
|
|
1115
|
+
}
|
|
1116
|
+
hasLoadedNamespace(e, t = {}) {
|
|
1117
|
+
if (!this.isInitialized) return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
|
|
1118
|
+
if (!this.languages || !this.languages.length) return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
|
|
1119
|
+
let n = t.lng || this.resolvedLanguage || this.languages[0], r = this.options ? this.options.fallbackLng : !1, i = this.languages[this.languages.length - 1];
|
|
1120
|
+
if (n.toLowerCase() === "cimode") return !0;
|
|
1121
|
+
let a = (e, t) => {
|
|
1122
|
+
let n = this.services.backendConnector.state[`${e}|${t}`];
|
|
1123
|
+
return n === -1 || n === 0 || n === 2;
|
|
1124
|
+
};
|
|
1125
|
+
if (t.precheck) {
|
|
1126
|
+
let e = t.precheck(this, a);
|
|
1127
|
+
if (e !== void 0) return e;
|
|
1128
|
+
}
|
|
1129
|
+
return !!(this.hasResourceBundle(n, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(n, e) && (!r || a(i, e)));
|
|
1130
|
+
}
|
|
1131
|
+
loadNamespaces(e, t) {
|
|
1132
|
+
let i = r();
|
|
1133
|
+
return this.options.ns ? (n(e) && (e = [e]), e.forEach((e) => {
|
|
1134
|
+
this.options.ns.includes(e) || this.options.ns.push(e);
|
|
1135
|
+
}), this.loadResources((e) => {
|
|
1136
|
+
i.resolve(), t && t(e);
|
|
1137
|
+
}), i) : (t && t(), Promise.resolve());
|
|
1138
|
+
}
|
|
1139
|
+
loadLanguages(e, t) {
|
|
1140
|
+
let i = r();
|
|
1141
|
+
n(e) && (e = [e]);
|
|
1142
|
+
let a = this.options.preload || [], o = e.filter((e) => !a.includes(e) && this.services.languageUtils.isSupportedCode(e));
|
|
1143
|
+
return o.length ? (this.options.preload = a.concat(o), this.loadResources((e) => {
|
|
1144
|
+
i.resolve(), t && t(e);
|
|
1145
|
+
}), i) : (t && t(), Promise.resolve());
|
|
1146
|
+
}
|
|
1147
|
+
dir(e) {
|
|
1148
|
+
if (e ||= this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language), !e) return "rtl";
|
|
1149
|
+
try {
|
|
1150
|
+
let t = new Intl.Locale(e);
|
|
1151
|
+
if (t && t.getTextInfo) {
|
|
1152
|
+
let e = t.getTextInfo();
|
|
1153
|
+
if (e && e.direction) return e.direction;
|
|
1154
|
+
}
|
|
1155
|
+
} catch {}
|
|
1156
|
+
let t = /* @__PURE__ */ "ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb".split("."), n = this.services?.languageUtils || new M(F());
|
|
1157
|
+
return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.includes(n.getLanguagePartFromCode(e)) || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
1158
|
+
}
|
|
1159
|
+
static createInstance(t = {}, n) {
|
|
1160
|
+
let r = new e(t, n);
|
|
1161
|
+
return r.createInstance = e.createInstance, r;
|
|
1162
|
+
}
|
|
1163
|
+
cloneInstance(t = {}, n = L) {
|
|
1164
|
+
let r = t.forkResourceStore;
|
|
1165
|
+
r && delete t.forkResourceStore;
|
|
1166
|
+
let i = {
|
|
1167
|
+
...this.options,
|
|
1168
|
+
...t,
|
|
1169
|
+
isClone: !0
|
|
1170
|
+
}, a = new e(i);
|
|
1171
|
+
if ((t.debug !== void 0 || t.prefix !== void 0) && (a.logger = a.logger.clone(t)), [
|
|
1172
|
+
"store",
|
|
1173
|
+
"services",
|
|
1174
|
+
"language"
|
|
1175
|
+
].forEach((e) => {
|
|
1176
|
+
a[e] = this[e];
|
|
1177
|
+
}), a.services = { ...this.services }, a.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, r && (a.store = new E(Object.keys(this.store.data).reduce((e, t) => (e[t] = { ...this.store.data[t] }, e[t] = Object.keys(e[t]).reduce((n, r) => (n[r] = { ...e[t][r] }, n), e[t]), e), {}), i), a.services.resourceStore = a.store), t.interpolation) {
|
|
1178
|
+
let e = {
|
|
1179
|
+
...F().interpolation,
|
|
1180
|
+
...this.options.interpolation,
|
|
1181
|
+
...t.interpolation
|
|
1182
|
+
}, n = {
|
|
1183
|
+
...i,
|
|
1184
|
+
interpolation: e
|
|
1185
|
+
};
|
|
1186
|
+
a.services.interpolator = new ae(n);
|
|
1187
|
+
}
|
|
1188
|
+
return a.translator = new j(a.services, i), a.translator.on("*", (e, ...t) => {
|
|
1189
|
+
a.emit(e, ...t);
|
|
1190
|
+
}), a.init(i, n), a.translator.options = i, a.translator.backendConnector.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, a;
|
|
1191
|
+
}
|
|
1192
|
+
toJSON() {
|
|
1193
|
+
return {
|
|
1194
|
+
options: this.options,
|
|
1195
|
+
store: this.store,
|
|
1196
|
+
language: this.language,
|
|
1197
|
+
languages: this.languages,
|
|
1198
|
+
resolvedLanguage: this.resolvedLanguage
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
}.createInstance();
|
|
1202
|
+
R.createInstance, R.dir, R.init, R.loadResources, R.reloadResources, R.use, R.changeLanguage, R.getFixedT, R.t, R.exists, R.setDefaultNamespace, R.hasLoadedNamespace, R.loadNamespaces, R.loadLanguages;
|
|
1203
|
+
//#endregion
|
|
1204
|
+
//#region node_modules/@babel/runtime/helpers/esm/classCallCheck.js
|
|
1205
|
+
function z(e, t) {
|
|
1206
|
+
if (!(e instanceof t)) throw TypeError("Cannot call a class as a function");
|
|
1207
|
+
}
|
|
1208
|
+
//#endregion
|
|
1209
|
+
//#region node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
1210
|
+
function B(e) {
|
|
1211
|
+
"@babel/helpers - typeof";
|
|
1212
|
+
return B = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
1213
|
+
return typeof e;
|
|
1214
|
+
} : function(e) {
|
|
1215
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
1216
|
+
}, B(e);
|
|
1217
|
+
}
|
|
1218
|
+
//#endregion
|
|
1219
|
+
//#region node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
1220
|
+
function pe(e, t) {
|
|
1221
|
+
if (B(e) != "object" || !e) return e;
|
|
1222
|
+
var n = e[Symbol.toPrimitive];
|
|
1223
|
+
if (n !== void 0) {
|
|
1224
|
+
var r = n.call(e, t || "default");
|
|
1225
|
+
if (B(r) != "object") return r;
|
|
1226
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
1227
|
+
}
|
|
1228
|
+
return (t === "string" ? String : Number)(e);
|
|
1229
|
+
}
|
|
1230
|
+
//#endregion
|
|
1231
|
+
//#region node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
1232
|
+
function V(e) {
|
|
1233
|
+
var t = pe(e, "string");
|
|
1234
|
+
return B(t) == "symbol" ? t : t + "";
|
|
1235
|
+
}
|
|
1236
|
+
//#endregion
|
|
1237
|
+
//#region node_modules/@babel/runtime/helpers/esm/createClass.js
|
|
1238
|
+
function H(e, t) {
|
|
1239
|
+
for (var n = 0; n < t.length; n++) {
|
|
1240
|
+
var r = t[n];
|
|
1241
|
+
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, V(r.key), r);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
function U(e, t, n) {
|
|
1245
|
+
return t && H(e.prototype, t), n && H(e, n), Object.defineProperty(e, "prototype", { writable: !1 }), e;
|
|
1246
|
+
}
|
|
1247
|
+
//#endregion
|
|
1248
|
+
//#region node_modules/i18next-chained-backend/dist/esm/index.js
|
|
1249
|
+
var me = [], he = me.forEach, ge = me.slice;
|
|
1250
|
+
function _e(e) {
|
|
1251
|
+
return he.call(ge.call(arguments, 1), function(t) {
|
|
1252
|
+
if (t) for (var n in t) e[n] === void 0 && (e[n] = t[n]);
|
|
1253
|
+
}), e;
|
|
1254
|
+
}
|
|
1255
|
+
function ve(e) {
|
|
1256
|
+
return e ? typeof e == "function" ? new e() : e : null;
|
|
1257
|
+
}
|
|
1258
|
+
function ye() {
|
|
1259
|
+
return {
|
|
1260
|
+
handleEmptyResourcesAsFailed: !0,
|
|
1261
|
+
cacheHitMode: "none"
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
function be(e, t, n, r) {
|
|
1265
|
+
var i = e.read.bind(e);
|
|
1266
|
+
if (i.length === 2) {
|
|
1267
|
+
try {
|
|
1268
|
+
var a = i(t, n);
|
|
1269
|
+
a && typeof a.then == "function" ? a.then(function(e) {
|
|
1270
|
+
return r(null, e);
|
|
1271
|
+
}).catch(r) : r(null, a);
|
|
1272
|
+
} catch (e) {
|
|
1273
|
+
r(e);
|
|
1274
|
+
}
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
i(t, n, r);
|
|
1278
|
+
}
|
|
1279
|
+
var xe = /* @__PURE__ */ function() {
|
|
1280
|
+
function e(t) {
|
|
1281
|
+
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1282
|
+
z(this, e), this.backends = [], this.type = "backend", this.allOptions = r, this.init(t, n);
|
|
1283
|
+
}
|
|
1284
|
+
return U(e, [
|
|
1285
|
+
{
|
|
1286
|
+
key: "init",
|
|
1287
|
+
value: function(e) {
|
|
1288
|
+
var t = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1289
|
+
this.services = e, this.options = _e(n, this.options || {}, ye()), this.allOptions = r, this.options.backends && this.options.backends.length > 1 && (this.allOptions.saveMissing || this.allOptions.updateMissing) && this.services && this.services.logger && this.services.logger.warn("i18next-chained-backend: Using multiple backends in combination with saveMissing/updateMissing is not recommended, as it may trigger based on stale data."), this.options.backends && this.options.backends.forEach(function(n, i) {
|
|
1290
|
+
t.backends[i] = t.backends[i] || ve(n), t.backends[i].init(e, t.options.backendOptions && t.options.backendOptions[i] || {}, r);
|
|
1291
|
+
}), this.services && this.options.reloadInterval && setInterval(function() {
|
|
1292
|
+
return t.reload();
|
|
1293
|
+
}, this.options.reloadInterval);
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
{
|
|
1297
|
+
key: "read",
|
|
1298
|
+
value: function(e, t, n) {
|
|
1299
|
+
var r = this, i = this.backends.length, a = function(s) {
|
|
1300
|
+
if (s >= i) return n(Error("non of the backend loaded data", !0));
|
|
1301
|
+
var c = s === i - 1, l = r.options.handleEmptyResourcesAsFailed && !c ? 0 : -1, u = r.backends[s];
|
|
1302
|
+
u.read ? be(u, e, t, function(i, c, d) {
|
|
1303
|
+
if (!i && c && Object.keys(c).length > l) {
|
|
1304
|
+
if (n(null, c, s), o(s - 1, c), u.save && r.options.cacheHitMode && ["refresh", "refreshAndUpdateStore"].indexOf(r.options.cacheHitMode) > -1) {
|
|
1305
|
+
if (d && r.options.refreshExpirationTime && d + r.options.refreshExpirationTime > Date.now()) return;
|
|
1306
|
+
var f = r.backends[s + 1];
|
|
1307
|
+
f && f.read && be(f, e, t, function(n, i) {
|
|
1308
|
+
n || i && (Object.keys(i).length <= l || (o(s, i), r.options.cacheHitMode === "refreshAndUpdateStore" && r.services && r.services.resourceStore && r.services.resourceStore.addResourceBundle(e, t, i)));
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
} else a(s + 1);
|
|
1312
|
+
}) : a(s + 1);
|
|
1313
|
+
}, o = function(n, i) {
|
|
1314
|
+
if (!(n < 0)) {
|
|
1315
|
+
var a = r.backends[n];
|
|
1316
|
+
a.save && a.save(e, t, i), o(n - 1, i);
|
|
1317
|
+
}
|
|
1318
|
+
};
|
|
1319
|
+
a(0);
|
|
1320
|
+
}
|
|
1321
|
+
},
|
|
1322
|
+
{
|
|
1323
|
+
key: "create",
|
|
1324
|
+
value: function(e, t, n, r) {
|
|
1325
|
+
var i = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : function() {}, a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {};
|
|
1326
|
+
this.backends.forEach(function(o) {
|
|
1327
|
+
if (o.create) {
|
|
1328
|
+
var s = o.create.bind(o);
|
|
1329
|
+
if (s.length < 6) {
|
|
1330
|
+
try {
|
|
1331
|
+
var c = s.length === 5 ? s(e, t, n, r, a) : s(e, t, n, r);
|
|
1332
|
+
c && typeof c.then == "function" ? c.then(function(e) {
|
|
1333
|
+
return i(null, e);
|
|
1334
|
+
}).catch(i) : i(null, c);
|
|
1335
|
+
} catch (e) {
|
|
1336
|
+
i(e);
|
|
1337
|
+
}
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
s(e, t, n, r, i, a);
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
key: "reload",
|
|
1347
|
+
value: function() {
|
|
1348
|
+
var e = this, t = this.services, n = t.backendConnector, r = t.languageUtils, i = t.logger, a = n.language;
|
|
1349
|
+
if (!(a && a.toLowerCase() === "cimode")) {
|
|
1350
|
+
var o = [], s = function(e) {
|
|
1351
|
+
r.toResolveHierarchy(e).forEach(function(e) {
|
|
1352
|
+
o.indexOf(e) < 0 && o.push(e);
|
|
1353
|
+
});
|
|
1354
|
+
};
|
|
1355
|
+
s(a), this.allOptions.preload && this.allOptions.preload.forEach(function(e) {
|
|
1356
|
+
return s(e);
|
|
1357
|
+
}), o.forEach(function(t) {
|
|
1358
|
+
e.allOptions.ns.forEach(function(e) {
|
|
1359
|
+
n.read(t, e, "read", null, null, function(r, a) {
|
|
1360
|
+
r && i.warn(`loading namespace ${e} for language ${t} failed`, r), !r && a && i.log(`loaded namespace ${e} for language ${t}`, a), n.loaded(`${t}|${e}`, r, a);
|
|
1361
|
+
});
|
|
1362
|
+
});
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
]);
|
|
1368
|
+
}();
|
|
1369
|
+
xe.type = "backend";
|
|
1370
|
+
//#endregion
|
|
1371
|
+
//#region node_modules/i18next-http-backend/esm/utils.js
|
|
1372
|
+
function W(e) {
|
|
1373
|
+
"@babel/helpers - typeof";
|
|
1374
|
+
return W = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
1375
|
+
return typeof e;
|
|
1376
|
+
} : function(e) {
|
|
1377
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
1378
|
+
}, W(e);
|
|
1379
|
+
}
|
|
1380
|
+
var Se = [];
|
|
1381
|
+
Se.forEach, Se.slice;
|
|
1382
|
+
function Ce() {
|
|
1383
|
+
return typeof XMLHttpRequest == "function" || (typeof XMLHttpRequest > "u" ? "undefined" : W(XMLHttpRequest)) === "object";
|
|
1384
|
+
}
|
|
1385
|
+
function we(e) {
|
|
1386
|
+
return !!e && typeof e.then == "function";
|
|
1387
|
+
}
|
|
1388
|
+
function Te(e) {
|
|
1389
|
+
return we(e) ? e : Promise.resolve(e);
|
|
1390
|
+
}
|
|
1391
|
+
var Ee = /\{\{(.+?)\}\}/g;
|
|
1392
|
+
function De(e, t) {
|
|
1393
|
+
return e.replace(Ee, function(e, n) {
|
|
1394
|
+
return t[n.trim()] ?? e;
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
//#endregion
|
|
1398
|
+
//#region node_modules/i18next-http-backend/esm/request.js
|
|
1399
|
+
function Oe(e, t) {
|
|
1400
|
+
var n = Object.keys(e);
|
|
1401
|
+
if (Object.getOwnPropertySymbols) {
|
|
1402
|
+
var r = Object.getOwnPropertySymbols(e);
|
|
1403
|
+
t && (r = r.filter(function(t) {
|
|
1404
|
+
return Object.getOwnPropertyDescriptor(e, t).enumerable;
|
|
1405
|
+
})), n.push.apply(n, r);
|
|
1406
|
+
}
|
|
1407
|
+
return n;
|
|
1408
|
+
}
|
|
1409
|
+
function ke(e) {
|
|
1410
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
1411
|
+
var n = arguments[t] == null ? {} : arguments[t];
|
|
1412
|
+
t % 2 ? Oe(Object(n), !0).forEach(function(t) {
|
|
1413
|
+
Ae(e, t, n[t]);
|
|
1414
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : Oe(Object(n)).forEach(function(t) {
|
|
1415
|
+
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
return e;
|
|
1419
|
+
}
|
|
1420
|
+
function Ae(e, t, n) {
|
|
1421
|
+
return (t = je(t)) in e ? Object.defineProperty(e, t, {
|
|
1422
|
+
value: n,
|
|
1423
|
+
enumerable: !0,
|
|
1424
|
+
configurable: !0,
|
|
1425
|
+
writable: !0
|
|
1426
|
+
}) : e[t] = n, e;
|
|
1427
|
+
}
|
|
1428
|
+
function je(e) {
|
|
1429
|
+
var t = Me(e, "string");
|
|
1430
|
+
return G(t) == "symbol" ? t : t + "";
|
|
1431
|
+
}
|
|
1432
|
+
function Me(e, t) {
|
|
1433
|
+
if (G(e) != "object" || !e) return e;
|
|
1434
|
+
var n = e[Symbol.toPrimitive];
|
|
1435
|
+
if (n !== void 0) {
|
|
1436
|
+
var r = n.call(e, t || "default");
|
|
1437
|
+
if (G(r) != "object") return r;
|
|
1438
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
1439
|
+
}
|
|
1440
|
+
return (t === "string" ? String : Number)(e);
|
|
1441
|
+
}
|
|
1442
|
+
function G(e) {
|
|
1443
|
+
"@babel/helpers - typeof";
|
|
1444
|
+
return G = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
1445
|
+
return typeof e;
|
|
1446
|
+
} : function(e) {
|
|
1447
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
1448
|
+
}, G(e);
|
|
1449
|
+
}
|
|
1450
|
+
var K = typeof fetch == "function" ? fetch : void 0;
|
|
1451
|
+
typeof global < "u" && global.fetch ? K = global.fetch : typeof window < "u" && window.fetch && (K = window.fetch);
|
|
1452
|
+
var q;
|
|
1453
|
+
Ce() && (typeof global < "u" && global.XMLHttpRequest ? q = global.XMLHttpRequest : typeof window < "u" && window.XMLHttpRequest && (q = window.XMLHttpRequest));
|
|
1454
|
+
var J;
|
|
1455
|
+
if (typeof ActiveXObject == "function" && (typeof global < "u" && global.ActiveXObject ? J = global.ActiveXObject : typeof window < "u" && window.ActiveXObject && (J = window.ActiveXObject)), typeof K != "function" && (K = void 0), !K && !q && !J) try {
|
|
1456
|
+
import("./browser-ponyfill-C-HVh7ck.js").then((t) => /* @__PURE__ */ e(t.default, 1)).then(function(e) {
|
|
1457
|
+
K = e.default;
|
|
1458
|
+
}).catch(function() {});
|
|
1459
|
+
} catch {}
|
|
1460
|
+
var Y = function(e, t) {
|
|
1461
|
+
if (t && G(t) === "object") {
|
|
1462
|
+
var n = "";
|
|
1463
|
+
for (var r in t) n += "&" + encodeURIComponent(r) + "=" + encodeURIComponent(t[r]);
|
|
1464
|
+
if (!n) return e;
|
|
1465
|
+
e = e + (e.indexOf("?") === -1 ? "?" : "&") + n.slice(1);
|
|
1466
|
+
}
|
|
1467
|
+
return e;
|
|
1468
|
+
}, Ne = function(e, t, n, r) {
|
|
1469
|
+
var i = function(e) {
|
|
1470
|
+
if (!e.ok) return n(e.statusText || "Error", { status: e.status });
|
|
1471
|
+
e.text().then(function(t) {
|
|
1472
|
+
n(null, {
|
|
1473
|
+
status: e.status,
|
|
1474
|
+
data: t
|
|
1475
|
+
});
|
|
1476
|
+
}).catch(n);
|
|
1477
|
+
};
|
|
1478
|
+
if (r) {
|
|
1479
|
+
var a = r(e, t);
|
|
1480
|
+
if (a instanceof Promise) {
|
|
1481
|
+
a.then(i).catch(n);
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
typeof fetch == "function" ? fetch(e, t).then(i).catch(n) : K(e, t).then(i).catch(n);
|
|
1486
|
+
}, Pe = !1, Fe = function(e, t, n, r) {
|
|
1487
|
+
e.queryStringParams && (t = Y(t, e.queryStringParams));
|
|
1488
|
+
var i = ke({}, typeof e.customHeaders == "function" ? e.customHeaders() : e.customHeaders);
|
|
1489
|
+
typeof window > "u" && typeof global < "u" && global.process !== void 0 && global.process.versions && global.process.versions.node && (i["User-Agent"] = `i18next-http-backend (node/${global.process.version}; ${global.process.platform} ${global.process.arch})`), n && (i["Content-Type"] = "application/json");
|
|
1490
|
+
var a = typeof e.requestOptions == "function" ? e.requestOptions(n) : e.requestOptions, o = ke({
|
|
1491
|
+
method: n ? "POST" : "GET",
|
|
1492
|
+
body: n ? e.stringify(n) : void 0,
|
|
1493
|
+
headers: i
|
|
1494
|
+
}, Pe ? {} : a), s = typeof e.alternateFetch == "function" && e.alternateFetch.length >= 1 ? e.alternateFetch : void 0;
|
|
1495
|
+
try {
|
|
1496
|
+
Ne(t, o, r, s);
|
|
1497
|
+
} catch (e) {
|
|
1498
|
+
if (!a || Object.keys(a).length === 0 || !e.message || e.message.indexOf("not implemented") < 0) return r(e);
|
|
1499
|
+
try {
|
|
1500
|
+
Object.keys(a).forEach(function(e) {
|
|
1501
|
+
delete o[e];
|
|
1502
|
+
}), Ne(t, o, r, s), Pe = !0;
|
|
1503
|
+
} catch (e) {
|
|
1504
|
+
r(e);
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}, Ie = function(e, t, n, r) {
|
|
1508
|
+
n && G(n) === "object" && (n = Y("", n).slice(1)), e.queryStringParams && (t = Y(t, e.queryStringParams));
|
|
1509
|
+
try {
|
|
1510
|
+
var i = q ? new q() : new J("MSXML2.XMLHTTP.3.0");
|
|
1511
|
+
i.open(n ? "POST" : "GET", t, 1), e.crossDomain || i.setRequestHeader("X-Requested-With", "XMLHttpRequest"), i.withCredentials = !!e.withCredentials, n && i.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), i.overrideMimeType && i.overrideMimeType("application/json");
|
|
1512
|
+
var a = e.customHeaders;
|
|
1513
|
+
if (a = typeof a == "function" ? a() : a, a) for (var o in a) i.setRequestHeader(o, a[o]);
|
|
1514
|
+
i.onreadystatechange = function() {
|
|
1515
|
+
i.readyState > 3 && r(i.status >= 400 ? i.statusText : null, {
|
|
1516
|
+
status: i.status,
|
|
1517
|
+
data: i.responseText
|
|
1518
|
+
});
|
|
1519
|
+
}, i.send(n);
|
|
1520
|
+
} catch (e) {
|
|
1521
|
+
console && console.log(e);
|
|
1522
|
+
}
|
|
1523
|
+
}, Le = function(e, t, n, r) {
|
|
1524
|
+
if (typeof n == "function" && (r = n, n = void 0), r ||= function() {}, K && t.indexOf("file:") !== 0) return Fe(e, t, n, r);
|
|
1525
|
+
if (Ce() || typeof ActiveXObject == "function") return Ie(e, t, n, r);
|
|
1526
|
+
r(/* @__PURE__ */ Error("No fetch and no xhr implementation found!"));
|
|
1527
|
+
};
|
|
1528
|
+
//#endregion
|
|
1529
|
+
//#region node_modules/i18next-http-backend/esm/index.js
|
|
1530
|
+
function X(e) {
|
|
1531
|
+
"@babel/helpers - typeof";
|
|
1532
|
+
return X = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
1533
|
+
return typeof e;
|
|
1534
|
+
} : function(e) {
|
|
1535
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
1536
|
+
}, X(e);
|
|
1537
|
+
}
|
|
1538
|
+
function Re(e, t) {
|
|
1539
|
+
var n = Object.keys(e);
|
|
1540
|
+
if (Object.getOwnPropertySymbols) {
|
|
1541
|
+
var r = Object.getOwnPropertySymbols(e);
|
|
1542
|
+
t && (r = r.filter(function(t) {
|
|
1543
|
+
return Object.getOwnPropertyDescriptor(e, t).enumerable;
|
|
1544
|
+
})), n.push.apply(n, r);
|
|
1545
|
+
}
|
|
1546
|
+
return n;
|
|
1547
|
+
}
|
|
1548
|
+
function Z(e) {
|
|
1549
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
1550
|
+
var n = arguments[t] == null ? {} : arguments[t];
|
|
1551
|
+
t % 2 ? Re(Object(n), !0).forEach(function(t) {
|
|
1552
|
+
He(e, t, n[t]);
|
|
1553
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : Re(Object(n)).forEach(function(t) {
|
|
1554
|
+
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
return e;
|
|
1558
|
+
}
|
|
1559
|
+
function ze(e, t) {
|
|
1560
|
+
if (!(e instanceof t)) throw TypeError("Cannot call a class as a function");
|
|
1561
|
+
}
|
|
1562
|
+
function Be(e, t) {
|
|
1563
|
+
for (var n = 0; n < t.length; n++) {
|
|
1564
|
+
var r = t[n];
|
|
1565
|
+
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, Q(r.key), r);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
function Ve(e, t, n) {
|
|
1569
|
+
return t && Be(e.prototype, t), n && Be(e, n), Object.defineProperty(e, "prototype", { writable: !1 }), e;
|
|
1570
|
+
}
|
|
1571
|
+
function He(e, t, n) {
|
|
1572
|
+
return (t = Q(t)) in e ? Object.defineProperty(e, t, {
|
|
1573
|
+
value: n,
|
|
1574
|
+
enumerable: !0,
|
|
1575
|
+
configurable: !0,
|
|
1576
|
+
writable: !0
|
|
1577
|
+
}) : e[t] = n, e;
|
|
1578
|
+
}
|
|
1579
|
+
function Q(e) {
|
|
1580
|
+
var t = Ue(e, "string");
|
|
1581
|
+
return X(t) == "symbol" ? t : t + "";
|
|
1582
|
+
}
|
|
1583
|
+
function Ue(e, t) {
|
|
1584
|
+
if (X(e) != "object" || !e) return e;
|
|
1585
|
+
var n = e[Symbol.toPrimitive];
|
|
1586
|
+
if (n !== void 0) {
|
|
1587
|
+
var r = n.call(e, t || "default");
|
|
1588
|
+
if (X(r) != "object") return r;
|
|
1589
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
1590
|
+
}
|
|
1591
|
+
return (t === "string" ? String : Number)(e);
|
|
1592
|
+
}
|
|
1593
|
+
var We = function() {
|
|
1594
|
+
return {
|
|
1595
|
+
loadPath: "/locales/{{lng}}/{{ns}}.json",
|
|
1596
|
+
addPath: "/locales/add/{{lng}}/{{ns}}",
|
|
1597
|
+
parse: function(e) {
|
|
1598
|
+
return JSON.parse(e);
|
|
1599
|
+
},
|
|
1600
|
+
stringify: JSON.stringify,
|
|
1601
|
+
parsePayload: function(e, t, n) {
|
|
1602
|
+
return He({}, t, n || "");
|
|
1603
|
+
},
|
|
1604
|
+
parseLoadPayload: function(e, t) {},
|
|
1605
|
+
request: Le,
|
|
1606
|
+
reloadInterval: typeof window < "u" ? !1 : 3600 * 1e3,
|
|
1607
|
+
customHeaders: {},
|
|
1608
|
+
queryStringParams: {},
|
|
1609
|
+
crossDomain: !1,
|
|
1610
|
+
withCredentials: !1,
|
|
1611
|
+
overrideMimeType: !1,
|
|
1612
|
+
requestOptions: {
|
|
1613
|
+
mode: "cors",
|
|
1614
|
+
credentials: "same-origin",
|
|
1615
|
+
cache: "default"
|
|
1616
|
+
}
|
|
1617
|
+
};
|
|
1618
|
+
}, Ge = function() {
|
|
1619
|
+
function e(t) {
|
|
1620
|
+
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1621
|
+
ze(this, e), this.services = t, this.options = n, this.allOptions = r, this.type = "backend", this.init(t, n, r);
|
|
1622
|
+
}
|
|
1623
|
+
return Ve(e, [
|
|
1624
|
+
{
|
|
1625
|
+
key: "init",
|
|
1626
|
+
value: function(e) {
|
|
1627
|
+
var t = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1628
|
+
if (this.services = e, this.options = Z(Z(Z({}, We()), this.options || {}), n), this.allOptions = r, this.services && this.options.reloadInterval) {
|
|
1629
|
+
var i = setInterval(function() {
|
|
1630
|
+
return t.reload();
|
|
1631
|
+
}, this.options.reloadInterval);
|
|
1632
|
+
X(i) === "object" && typeof i.unref == "function" && i.unref();
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
},
|
|
1636
|
+
{
|
|
1637
|
+
key: "readMulti",
|
|
1638
|
+
value: function(e, t, n) {
|
|
1639
|
+
this._readAny(e, e, t, t, n);
|
|
1640
|
+
}
|
|
1641
|
+
},
|
|
1642
|
+
{
|
|
1643
|
+
key: "read",
|
|
1644
|
+
value: function(e, t, n) {
|
|
1645
|
+
this._readAny([e], e, [t], t, n);
|
|
1646
|
+
}
|
|
1647
|
+
},
|
|
1648
|
+
{
|
|
1649
|
+
key: "_readAny",
|
|
1650
|
+
value: function(e, t, n, r, i) {
|
|
1651
|
+
var a = this, o = this.options.loadPath;
|
|
1652
|
+
typeof this.options.loadPath == "function" && (o = this.options.loadPath(e, n)), o = Te(o), o.then(function(o) {
|
|
1653
|
+
if (!o) return i(null, {});
|
|
1654
|
+
var s = De(o, {
|
|
1655
|
+
lng: e.join("+"),
|
|
1656
|
+
ns: n.join("+")
|
|
1657
|
+
});
|
|
1658
|
+
a.loadUrl(s, i, t, r);
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
},
|
|
1662
|
+
{
|
|
1663
|
+
key: "loadUrl",
|
|
1664
|
+
value: function(e, t, n, r) {
|
|
1665
|
+
var i = this, a = typeof n == "string" ? [n] : n, o = typeof r == "string" ? [r] : r, s = this.options.parseLoadPayload(a, o);
|
|
1666
|
+
this.options.request(this.options, e, s, function(a, o) {
|
|
1667
|
+
if (o && (o.status >= 500 && o.status < 600 || !o.status)) return t("failed loading " + e + "; status code: " + o.status, !0);
|
|
1668
|
+
if (o && o.status >= 400 && o.status < 500) return t("failed loading " + e + "; status code: " + o.status, !1);
|
|
1669
|
+
if (!o && a && a.message) {
|
|
1670
|
+
var s = a.message.toLowerCase();
|
|
1671
|
+
if ([
|
|
1672
|
+
"failed",
|
|
1673
|
+
"fetch",
|
|
1674
|
+
"network",
|
|
1675
|
+
"load"
|
|
1676
|
+
].find(function(e) {
|
|
1677
|
+
return s.indexOf(e) > -1;
|
|
1678
|
+
})) return t("failed loading " + e + ": " + a.message, !0);
|
|
1679
|
+
}
|
|
1680
|
+
if (a) return t(a, !1);
|
|
1681
|
+
var c, l;
|
|
1682
|
+
try {
|
|
1683
|
+
c = typeof o.data == "string" ? i.options.parse(o.data, n, r) : o.data;
|
|
1684
|
+
} catch {
|
|
1685
|
+
l = "failed parsing " + e + " to json";
|
|
1686
|
+
}
|
|
1687
|
+
if (l) return t(l, !1);
|
|
1688
|
+
t(null, c);
|
|
1689
|
+
});
|
|
1690
|
+
}
|
|
1691
|
+
},
|
|
1692
|
+
{
|
|
1693
|
+
key: "create",
|
|
1694
|
+
value: function(e, t, n, r, i) {
|
|
1695
|
+
var a = this;
|
|
1696
|
+
if (this.options.addPath) {
|
|
1697
|
+
typeof e == "string" && (e = [e]);
|
|
1698
|
+
var o = this.options.parsePayload(t, n, r), s = 0, c = [], l = [];
|
|
1699
|
+
e.forEach(function(n) {
|
|
1700
|
+
var r = a.options.addPath;
|
|
1701
|
+
typeof a.options.addPath == "function" && (r = a.options.addPath(n, t));
|
|
1702
|
+
var u = De(r, {
|
|
1703
|
+
lng: n,
|
|
1704
|
+
ns: t
|
|
1705
|
+
});
|
|
1706
|
+
a.options.request(a.options, u, o, function(t, n) {
|
|
1707
|
+
s += 1, c.push(t), l.push(n), s === e.length && typeof i == "function" && i(c, l);
|
|
1708
|
+
});
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
},
|
|
1713
|
+
{
|
|
1714
|
+
key: "reload",
|
|
1715
|
+
value: function() {
|
|
1716
|
+
var e = this, t = this.services, n = t.backendConnector, r = t.languageUtils, i = t.logger, a = n.language;
|
|
1717
|
+
if (!(a && a.toLowerCase() === "cimode")) {
|
|
1718
|
+
var o = [], s = function(e) {
|
|
1719
|
+
r.toResolveHierarchy(e).forEach(function(e) {
|
|
1720
|
+
o.indexOf(e) < 0 && o.push(e);
|
|
1721
|
+
});
|
|
1722
|
+
};
|
|
1723
|
+
s(a), this.allOptions.preload && this.allOptions.preload.forEach(function(e) {
|
|
1724
|
+
return s(e);
|
|
1725
|
+
}), o.forEach(function(t) {
|
|
1726
|
+
e.allOptions.ns.forEach(function(e) {
|
|
1727
|
+
n.read(t, e, "read", null, null, function(r, a) {
|
|
1728
|
+
r && i.warn(`loading namespace ${e} for language ${t} failed`, r), !r && a && i.log(`loaded namespace ${e} for language ${t}`, a), n.loaded(`${t}|${e}`, r, a);
|
|
1729
|
+
});
|
|
1730
|
+
});
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
]);
|
|
1736
|
+
}();
|
|
1737
|
+
Ge.type = "backend";
|
|
1738
|
+
//#endregion
|
|
1739
|
+
//#region node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
1740
|
+
function Ke(e, t, n) {
|
|
1741
|
+
return (t = V(t)) in e ? Object.defineProperty(e, t, {
|
|
1742
|
+
value: n,
|
|
1743
|
+
enumerable: !0,
|
|
1744
|
+
configurable: !0,
|
|
1745
|
+
writable: !0
|
|
1746
|
+
}) : e[t] = n, e;
|
|
1747
|
+
}
|
|
1748
|
+
//#endregion
|
|
1749
|
+
//#region node_modules/i18next-localstorage-backend/dist/esm/i18nextLocalStorageBackend.js
|
|
1750
|
+
function qe(e, t) {
|
|
1751
|
+
var n = Object.keys(e);
|
|
1752
|
+
if (Object.getOwnPropertySymbols) {
|
|
1753
|
+
var r = Object.getOwnPropertySymbols(e);
|
|
1754
|
+
t && (r = r.filter(function(t) {
|
|
1755
|
+
return Object.getOwnPropertyDescriptor(e, t).enumerable;
|
|
1756
|
+
})), n.push.apply(n, r);
|
|
1757
|
+
}
|
|
1758
|
+
return n;
|
|
1759
|
+
}
|
|
1760
|
+
function $(e) {
|
|
1761
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
1762
|
+
var n = arguments[t] == null ? {} : arguments[t];
|
|
1763
|
+
t % 2 ? qe(Object(n), !0).forEach(function(t) {
|
|
1764
|
+
Ke(e, t, n[t]);
|
|
1765
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : qe(Object(n)).forEach(function(t) {
|
|
1766
|
+
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
return e;
|
|
1770
|
+
}
|
|
1771
|
+
var Je = /* @__PURE__ */ function() {
|
|
1772
|
+
function e(t) {
|
|
1773
|
+
z(this, e), this.store = t.store;
|
|
1774
|
+
}
|
|
1775
|
+
return U(e, [{
|
|
1776
|
+
key: "setItem",
|
|
1777
|
+
value: function(e, t) {
|
|
1778
|
+
if (this.store) try {
|
|
1779
|
+
this.store.setItem(e, t);
|
|
1780
|
+
} catch {}
|
|
1781
|
+
}
|
|
1782
|
+
}, {
|
|
1783
|
+
key: "getItem",
|
|
1784
|
+
value: function(e, t) {
|
|
1785
|
+
if (this.store) try {
|
|
1786
|
+
return this.store.getItem(e, t);
|
|
1787
|
+
} catch {}
|
|
1788
|
+
}
|
|
1789
|
+
}]);
|
|
1790
|
+
}();
|
|
1791
|
+
function Ye() {
|
|
1792
|
+
var e = null;
|
|
1793
|
+
try {
|
|
1794
|
+
e = window.localStorage;
|
|
1795
|
+
} catch (e) {
|
|
1796
|
+
typeof window < "u" && console.log("Failed to load local storage.", e);
|
|
1797
|
+
}
|
|
1798
|
+
return {
|
|
1799
|
+
prefix: "i18next_res_",
|
|
1800
|
+
expirationTime: 10080 * 60 * 1e3,
|
|
1801
|
+
defaultVersion: void 0,
|
|
1802
|
+
getVersion: void 0,
|
|
1803
|
+
versions: {},
|
|
1804
|
+
store: e
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
var Xe = /* @__PURE__ */ function() {
|
|
1808
|
+
function e(t) {
|
|
1809
|
+
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1810
|
+
z(this, e), this.init(t, n), this.type = "backend";
|
|
1811
|
+
}
|
|
1812
|
+
return U(e, [
|
|
1813
|
+
{
|
|
1814
|
+
key: "init",
|
|
1815
|
+
value: function(e) {
|
|
1816
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1817
|
+
this.services = e, this.options = $($($({}, Ye()), this.options), t), this.storage = new Je(this.options);
|
|
1818
|
+
}
|
|
1819
|
+
},
|
|
1820
|
+
{
|
|
1821
|
+
key: "read",
|
|
1822
|
+
value: function(e, t, n) {
|
|
1823
|
+
var r = Date.now();
|
|
1824
|
+
if (!this.storage.store) return n(null, null);
|
|
1825
|
+
var i = this.storage.getItem(`${this.options.prefix}${e}-${t}`);
|
|
1826
|
+
if (i) {
|
|
1827
|
+
i = JSON.parse(i);
|
|
1828
|
+
var a = this.getVersion(e, t);
|
|
1829
|
+
if (i.i18nStamp && i.i18nStamp + this.options.expirationTime > r && a === i.i18nVersion) {
|
|
1830
|
+
var o = i.i18nStamp;
|
|
1831
|
+
return delete i.i18nVersion, delete i.i18nStamp, n(null, i, o);
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
return n(null, null);
|
|
1835
|
+
}
|
|
1836
|
+
},
|
|
1837
|
+
{
|
|
1838
|
+
key: "save",
|
|
1839
|
+
value: function(e, t, n) {
|
|
1840
|
+
if (this.storage.store) {
|
|
1841
|
+
n.i18nStamp = Date.now();
|
|
1842
|
+
var r = this.getVersion(e, t);
|
|
1843
|
+
r && (n.i18nVersion = r), this.storage.setItem(`${this.options.prefix}${e}-${t}`, JSON.stringify(n));
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
key: "getVersion",
|
|
1849
|
+
value: function(e, t) {
|
|
1850
|
+
var n;
|
|
1851
|
+
return (n = this.options).getVersion?.call(n, e, t) || this.options.versions[e] || this.options.defaultVersion;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
]);
|
|
1855
|
+
}();
|
|
1856
|
+
Xe.type = "backend";
|
|
1857
|
+
//#endregion
|
|
1858
|
+
//#region node_modules/i18next-resources-to-backend/dist/esm/index.js
|
|
1859
|
+
var Ze = function(e) {
|
|
1860
|
+
return {
|
|
1861
|
+
type: "backend",
|
|
1862
|
+
init: function(e, t, n) {},
|
|
1863
|
+
read: function(t, n, r) {
|
|
1864
|
+
if (typeof e == "function") {
|
|
1865
|
+
if (e.length < 3) {
|
|
1866
|
+
try {
|
|
1867
|
+
var i = e(t, n);
|
|
1868
|
+
i && typeof i.then == "function" ? i.then(function(e) {
|
|
1869
|
+
return r(null, e && e.default || e);
|
|
1870
|
+
}).catch(r) : r(null, i);
|
|
1871
|
+
} catch (e) {
|
|
1872
|
+
r(e);
|
|
1873
|
+
}
|
|
1874
|
+
return;
|
|
1875
|
+
}
|
|
1876
|
+
e(t, n, r);
|
|
1877
|
+
return;
|
|
1878
|
+
}
|
|
1879
|
+
r(null, e && e[t] && e[t][n]);
|
|
1880
|
+
}
|
|
1881
|
+
};
|
|
1882
|
+
}, Qe = ({ initReactI18next: e, lang: n, fallbackLang: r, langCacheExpiredTimeMs: i, resources: a, version: o, useBackend: s, withLocalstorageBackend: c = !1, cdnUrl: l = "", debug: u = !1 }) => {
|
|
1883
|
+
let d = [], f = [], p = Object.keys(a);
|
|
1884
|
+
if (s && c) {
|
|
1885
|
+
let e = {};
|
|
1886
|
+
p.forEach((t) => Object.assign(e, { [t]: o })), d.push(Xe), f.push({
|
|
1887
|
+
prefix: "i18next_res_",
|
|
1888
|
+
expirationTime: i,
|
|
1889
|
+
versions: e
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
s && l && (d.push(Ge), f.push({
|
|
1893
|
+
loadPath: `${l}/locales/{{lng}}.json`,
|
|
1894
|
+
queryStringParams: { v: `${o}.${t(i)}` },
|
|
1895
|
+
reloadInterval: i
|
|
1896
|
+
})), s && d.push(Ze(a));
|
|
1897
|
+
let m = {
|
|
1898
|
+
type: "languageDetector",
|
|
1899
|
+
name: "customDetector",
|
|
1900
|
+
async: !1,
|
|
1901
|
+
init: () => {},
|
|
1902
|
+
detect: (e) => n
|
|
1903
|
+
}, h = {
|
|
1904
|
+
debug: u,
|
|
1905
|
+
compatibilityJSON: "v4",
|
|
1906
|
+
ns: ["translation"],
|
|
1907
|
+
defaultNS: "translation",
|
|
1908
|
+
lng: n,
|
|
1909
|
+
fallbackLng: r,
|
|
1910
|
+
load: "currentOnly",
|
|
1911
|
+
keySeparator: !1,
|
|
1912
|
+
nonExplicitSupportedLngs: !0,
|
|
1913
|
+
interpolation: { escapeValue: !1 }
|
|
1914
|
+
};
|
|
1915
|
+
if (h = s ? {
|
|
1916
|
+
...h,
|
|
1917
|
+
backend: {
|
|
1918
|
+
backends: d,
|
|
1919
|
+
backendOptions: f,
|
|
1920
|
+
cacheHitMode: "refreshAndUpdateStore",
|
|
1921
|
+
reloadInterval: i,
|
|
1922
|
+
refreshExpirationTime: i
|
|
1923
|
+
},
|
|
1924
|
+
react: { bindI18nStore: "added" }
|
|
1925
|
+
} : {
|
|
1926
|
+
...h,
|
|
1927
|
+
resources: a
|
|
1928
|
+
}, !R.isInitialized) {
|
|
1929
|
+
let t = R;
|
|
1930
|
+
s && (t = t.use(xe)), t.use(m).use(e).init(h, (e, t) => {
|
|
1931
|
+
if (e) {
|
|
1932
|
+
console.error("Error when i18n init", e);
|
|
1933
|
+
return;
|
|
1934
|
+
}
|
|
1935
|
+
});
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
//#endregion
|
|
1939
|
+
export { Qe as t };
|
|
1940
|
+
|
|
1941
|
+
//# sourceMappingURL=i18n-D1jKJPI0.js.map
|