@deriv-com/translations 1.4.0 → 1.4.2

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.
Files changed (42) hide show
  1. package/dist/chunk-DeC0fbbY.js +23 -0
  2. package/dist/components/index.js +2 -4
  3. package/dist/components/localize.js +2 -386
  4. package/dist/hooks/index.js +2 -4
  5. package/dist/hooks/use-translations.js +22 -20
  6. package/dist/i18next-DzZwHOzH.js +1202 -0
  7. package/dist/index.js +9 -16
  8. package/dist/initReactI18next-AIGy7ACI.js +52 -0
  9. package/dist/jsx-runtime-BJITdUlL.js +193 -0
  10. package/dist/localize-CZ6EZTCG.js +366 -0
  11. package/dist/provider/index.js +2 -5
  12. package/dist/provider/translation-provider.js +2 -47
  13. package/dist/{components → src/components}/localize.d.ts +2 -1
  14. package/dist/src/index.d.ts +4 -0
  15. package/dist/{provider → src/provider}/translation-provider.d.ts +1 -1
  16. package/dist/{utils → src/utils}/lang-utils.d.ts +1 -1
  17. package/dist/translation-provider-DouO5SpQ.js +34 -0
  18. package/dist/useTranslation-Ws-GUPE_.js +221 -0
  19. package/dist/utils/constants.js +34 -6
  20. package/dist/utils/index.js +5 -14
  21. package/dist/utils/initialize-i18n.js +2 -34
  22. package/dist/utils/lang-utils.js +2 -31
  23. package/dist/utils/localize.js +48 -9
  24. package/dist/utils/otasdk.js +19 -20
  25. package/dist/utils-17GMfKvo.js +50 -0
  26. package/package.json +28 -28
  27. package/dist/constants-HKuDWVkt.js +0 -37
  28. package/dist/crc32-BeCcwohL.js +0 -1556
  29. package/dist/i18nInstance-D3STmr24.js +0 -55
  30. package/dist/index.d.ts +0 -4
  31. package/dist/jsx-runtime-oIKL5WiM.js +0 -634
  32. package/dist/useTranslation-CZfO55Z-.js +0 -129
  33. /package/dist/{components → src/components}/index.d.ts +0 -0
  34. /package/dist/{hooks → src/hooks}/index.d.ts +0 -0
  35. /package/dist/{hooks → src/hooks}/use-translations.d.ts +0 -0
  36. /package/dist/{provider → src/provider}/index.d.ts +0 -0
  37. /package/dist/{utils → src/utils}/__tests__/lang-utils.spec.d.ts +0 -0
  38. /package/dist/{utils → src/utils}/constants.d.ts +0 -0
  39. /package/dist/{utils → src/utils}/index.d.ts +0 -0
  40. /package/dist/{utils → src/utils}/initialize-i18n.d.ts +0 -0
  41. /package/dist/{utils → src/utils}/localize.d.ts +0 -0
  42. /package/dist/{utils → src/utils}/otasdk.d.ts +0 -0
@@ -1,1556 +0,0 @@
1
- const ge = {
2
- type: "logger",
3
- log(i) {
4
- this.output("log", i);
5
- },
6
- warn(i) {
7
- this.output("warn", i);
8
- },
9
- error(i) {
10
- this.output("error", i);
11
- },
12
- output(i, e) {
13
- console && console[i] && console[i].apply(console, e);
14
- }
15
- };
16
- class M {
17
- constructor(e) {
18
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
19
- this.init(e, t);
20
- }
21
- init(e) {
22
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
23
- this.prefix = t.prefix || "i18next:", this.logger = e || ge, this.options = t, this.debug = t.debug;
24
- }
25
- log() {
26
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
27
- t[n] = arguments[n];
28
- return this.forward(t, "log", "", !0);
29
- }
30
- warn() {
31
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
32
- t[n] = arguments[n];
33
- return this.forward(t, "warn", "", !0);
34
- }
35
- error() {
36
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
37
- t[n] = arguments[n];
38
- return this.forward(t, "error", "");
39
- }
40
- deprecate() {
41
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
42
- t[n] = arguments[n];
43
- return this.forward(t, "warn", "WARNING DEPRECATED: ", !0);
44
- }
45
- forward(e, t, n, s) {
46
- return s && !this.debug ? null : (typeof e[0] == "string" && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[t](e));
47
- }
48
- create(e) {
49
- return new M(this.logger, {
50
- prefix: `${this.prefix}:${e}:`,
51
- ...this.options
52
- });
53
- }
54
- clone(e) {
55
- return e = e || this.options, e.prefix = e.prefix || this.prefix, new M(this.logger, e);
56
- }
57
- }
58
- var k = new M();
59
- class Y {
60
- constructor() {
61
- this.observers = {};
62
- }
63
- on(e, t) {
64
- return e.split(" ").forEach((n) => {
65
- this.observers[n] = this.observers[n] || [], this.observers[n].push(t);
66
- }), this;
67
- }
68
- off(e, t) {
69
- if (this.observers[e]) {
70
- if (!t) {
71
- delete this.observers[e];
72
- return;
73
- }
74
- this.observers[e] = this.observers[e].filter((n) => n !== t);
75
- }
76
- }
77
- emit(e) {
78
- for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), s = 1; s < t; s++)
79
- n[s - 1] = arguments[s];
80
- this.observers[e] && [].concat(this.observers[e]).forEach((a) => {
81
- a(...n);
82
- }), this.observers["*"] && [].concat(this.observers["*"]).forEach((a) => {
83
- a.apply(a, [e, ...n]);
84
- });
85
- }
86
- }
87
- function D() {
88
- let i, e;
89
- const t = new Promise((n, s) => {
90
- i = n, e = s;
91
- });
92
- return t.resolve = i, t.reject = e, t;
93
- }
94
- function _(i) {
95
- return i == null ? "" : "" + i;
96
- }
97
- function he(i, e, t) {
98
- i.forEach((n) => {
99
- e[n] && (t[n] = e[n]);
100
- });
101
- }
102
- function Q(i, e, t) {
103
- function n(a) {
104
- return a && a.indexOf("###") > -1 ? a.replace(/###/g, ".") : a;
105
- }
106
- function s() {
107
- return !i || typeof i == "string";
108
- }
109
- const r = typeof e != "string" ? [].concat(e) : e.split(".");
110
- for (; r.length > 1; ) {
111
- if (s()) return {};
112
- const a = n(r.shift());
113
- !i[a] && t && (i[a] = new t()), Object.prototype.hasOwnProperty.call(i, a) ? i = i[a] : i = {};
114
- }
115
- return s() ? {} : {
116
- obj: i,
117
- k: n(r.shift())
118
- };
119
- }
120
- function ee(i, e, t) {
121
- const {
122
- obj: n,
123
- k: s
124
- } = Q(i, e, Object);
125
- n[s] = t;
126
- }
127
- function ce(i, e, t, n) {
128
- const {
129
- obj: s,
130
- k: r
131
- } = Q(i, e, Object);
132
- s[r] = s[r] || [], s[r].push(t);
133
- }
134
- function H(i, e) {
135
- const {
136
- obj: t,
137
- k: n
138
- } = Q(i, e);
139
- if (t)
140
- return t[n];
141
- }
142
- function de(i, e, t) {
143
- const n = H(i, t);
144
- return n !== void 0 ? n : H(e, t);
145
- }
146
- function ue(i, e, t) {
147
- for (const n in e)
148
- n !== "__proto__" && n !== "constructor" && (n in i ? typeof i[n] == "string" || i[n] instanceof String || typeof e[n] == "string" || e[n] instanceof String ? t && (i[n] = e[n]) : ue(i[n], e[n], t) : i[n] = e[n]);
149
- return i;
150
- }
151
- function I(i) {
152
- return i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
153
- }
154
- var pe = {
155
- "&": "&amp;",
156
- "<": "&lt;",
157
- ">": "&gt;",
158
- '"': "&quot;",
159
- "'": "&#39;",
160
- "/": "&#x2F;"
161
- };
162
- function me(i) {
163
- return typeof i == "string" ? i.replace(/[&<>"'\/]/g, (e) => pe[e]) : i;
164
- }
165
- const ye = [" ", ",", "?", "!", ";"];
166
- function be(i, e, t) {
167
- e = e || "", t = t || "";
168
- const n = ye.filter((a) => e.indexOf(a) < 0 && t.indexOf(a) < 0);
169
- if (n.length === 0) return !0;
170
- const s = new RegExp(`(${n.map((a) => a === "?" ? "\\?" : a).join("|")})`);
171
- let r = !s.test(i);
172
- if (!r) {
173
- const a = i.indexOf(t);
174
- a > 0 && !s.test(i.substring(0, a)) && (r = !0);
175
- }
176
- return r;
177
- }
178
- function J(i, e) {
179
- let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
180
- if (!i) return;
181
- if (i[e]) return i[e];
182
- const n = e.split(t);
183
- let s = i;
184
- for (let r = 0; r < n.length; ++r) {
185
- if (!s || typeof s[n[r]] == "string" && r + 1 < n.length)
186
- return;
187
- if (s[n[r]] === void 0) {
188
- let a = 2, l = n.slice(r, r + a).join(t), o = s[l];
189
- for (; o === void 0 && n.length > r + a; )
190
- a++, l = n.slice(r, r + a).join(t), o = s[l];
191
- if (o === void 0) return;
192
- if (o === null) return null;
193
- if (e.endsWith(l)) {
194
- if (typeof o == "string") return o;
195
- if (l && typeof o[l] == "string") return o[l];
196
- }
197
- const f = n.slice(r + a).join(t);
198
- return f ? J(o, f, t) : void 0;
199
- }
200
- s = s[n[r]];
201
- }
202
- return s;
203
- }
204
- function z(i) {
205
- return i && i.indexOf("_") > 0 ? i.replace("_", "-") : i;
206
- }
207
- class te extends Y {
208
- constructor(e) {
209
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
210
- ns: ["translation"],
211
- defaultNS: "translation"
212
- };
213
- super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
214
- }
215
- addNamespaces(e) {
216
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
217
- }
218
- removeNamespaces(e) {
219
- const t = this.options.ns.indexOf(e);
220
- t > -1 && this.options.ns.splice(t, 1);
221
- }
222
- getResource(e, t, n) {
223
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
224
- const r = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, a = s.ignoreJSONStructure !== void 0 ? s.ignoreJSONStructure : this.options.ignoreJSONStructure;
225
- let l = [e, t];
226
- n && typeof n != "string" && (l = l.concat(n)), n && typeof n == "string" && (l = l.concat(r ? n.split(r) : n)), e.indexOf(".") > -1 && (l = e.split("."));
227
- const o = H(this.data, l);
228
- return o || !a || typeof n != "string" ? o : J(this.data && this.data[e] && this.data[e][t], n, r);
229
- }
230
- addResource(e, t, n, s) {
231
- let r = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
232
- silent: !1
233
- };
234
- const a = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator;
235
- let l = [e, t];
236
- n && (l = l.concat(a ? n.split(a) : n)), e.indexOf(".") > -1 && (l = e.split("."), s = t, t = l[1]), this.addNamespaces(t), ee(this.data, l, s), r.silent || this.emit("added", e, t, n, s);
237
- }
238
- addResources(e, t, n) {
239
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
240
- silent: !1
241
- };
242
- for (const r in n)
243
- (typeof n[r] == "string" || Object.prototype.toString.apply(n[r]) === "[object Array]") && this.addResource(e, t, r, n[r], {
244
- silent: !0
245
- });
246
- s.silent || this.emit("added", e, t, n);
247
- }
248
- addResourceBundle(e, t, n, s, r) {
249
- let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
250
- silent: !1
251
- }, l = [e, t];
252
- e.indexOf(".") > -1 && (l = e.split("."), s = n, n = t, t = l[1]), this.addNamespaces(t);
253
- let o = H(this.data, l) || {};
254
- s ? ue(o, n, r) : o = {
255
- ...o,
256
- ...n
257
- }, ee(this.data, l, o), a.silent || this.emit("added", e, t, n);
258
- }
259
- removeResourceBundle(e, t) {
260
- this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
261
- }
262
- hasResourceBundle(e, t) {
263
- return this.getResource(e, t) !== void 0;
264
- }
265
- getResourceBundle(e, t) {
266
- return t || (t = this.options.defaultNS), this.options.compatibilityAPI === "v1" ? {
267
- ...this.getResource(e, t)
268
- } : this.getResource(e, t);
269
- }
270
- getDataByLanguage(e) {
271
- return this.data[e];
272
- }
273
- hasLanguageSomeTranslations(e) {
274
- const t = this.getDataByLanguage(e);
275
- return !!(t && Object.keys(t) || []).find((s) => t[s] && Object.keys(t[s]).length > 0);
276
- }
277
- toJSON() {
278
- return this.data;
279
- }
280
- }
281
- var fe = {
282
- processors: {},
283
- addPostProcessor(i) {
284
- this.processors[i.name] = i;
285
- },
286
- handle(i, e, t, n, s) {
287
- return i.forEach((r) => {
288
- this.processors[r] && (e = this.processors[r].process(e, t, n, s));
289
- }), e;
290
- }
291
- };
292
- const ne = {};
293
- class W extends Y {
294
- constructor(e) {
295
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
296
- super(), he(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = k.create("translator");
297
- }
298
- changeLanguage(e) {
299
- e && (this.language = e);
300
- }
301
- exists(e) {
302
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
303
- interpolation: {}
304
- };
305
- if (e == null)
306
- return !1;
307
- const n = this.resolve(e, t);
308
- return n && n.res !== void 0;
309
- }
310
- extractFromKey(e, t) {
311
- let n = t.nsSeparator !== void 0 ? t.nsSeparator : this.options.nsSeparator;
312
- n === void 0 && (n = ":");
313
- const s = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
314
- let r = t.ns || this.options.defaultNS || [];
315
- const a = n && e.indexOf(n) > -1, l = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !be(e, n, s);
316
- if (a && !l) {
317
- const o = e.match(this.interpolator.nestingRegexp);
318
- if (o && o.length > 0)
319
- return {
320
- key: e,
321
- namespaces: r
322
- };
323
- const f = e.split(n);
324
- (n !== s || n === s && this.options.ns.indexOf(f[0]) > -1) && (r = f.shift()), e = f.join(s);
325
- }
326
- return typeof r == "string" && (r = [r]), {
327
- key: e,
328
- namespaces: r
329
- };
330
- }
331
- translate(e, t, n) {
332
- if (typeof t != "object" && this.options.overloadTranslationOptionHandler && (t = this.options.overloadTranslationOptionHandler(arguments)), typeof t == "object" && (t = {
333
- ...t
334
- }), t || (t = {}), e == null) return "";
335
- Array.isArray(e) || (e = [String(e)]);
336
- const s = t.returnDetails !== void 0 ? t.returnDetails : this.options.returnDetails, r = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator, {
337
- key: a,
338
- namespaces: l
339
- } = this.extractFromKey(e[e.length - 1], t), o = l[l.length - 1], f = t.lng || this.language, g = t.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
340
- if (f && f.toLowerCase() === "cimode") {
341
- if (g) {
342
- const L = t.nsSeparator || this.options.nsSeparator;
343
- return s ? {
344
- res: `${o}${L}${a}`,
345
- usedKey: a,
346
- exactUsedKey: a,
347
- usedLng: f,
348
- usedNS: o,
349
- usedParams: this.getUsedParamsDetails(t)
350
- } : `${o}${L}${a}`;
351
- }
352
- return s ? {
353
- res: a,
354
- usedKey: a,
355
- exactUsedKey: a,
356
- usedLng: f,
357
- usedNS: o,
358
- usedParams: this.getUsedParamsDetails(t)
359
- } : a;
360
- }
361
- const c = this.resolve(e, t);
362
- let u = c && c.res;
363
- const m = c && c.usedKey || a, p = c && c.exactUsedKey || a, x = Object.prototype.toString.apply(u), v = ["[object Number]", "[object Function]", "[object RegExp]"], P = t.joinArrays !== void 0 ? t.joinArrays : this.options.joinArrays, O = !this.i18nFormat || this.i18nFormat.handleAsObject;
364
- if (O && u && (typeof u != "string" && typeof u != "boolean" && typeof u != "number") && v.indexOf(x) < 0 && !(typeof P == "string" && x === "[object Array]")) {
365
- if (!t.returnObjects && !this.options.returnObjects) {
366
- this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
367
- const L = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(m, u, {
368
- ...t,
369
- ns: l
370
- }) : `key '${a} (${this.language})' returned an object instead of string.`;
371
- return s ? (c.res = L, c.usedParams = this.getUsedParamsDetails(t), c) : L;
372
- }
373
- if (r) {
374
- const L = x === "[object Array]", R = L ? [] : {}, $ = L ? p : m;
375
- for (const w in u)
376
- if (Object.prototype.hasOwnProperty.call(u, w)) {
377
- const h = `${$}${r}${w}`;
378
- R[w] = this.translate(h, {
379
- ...t,
380
- joinArrays: !1,
381
- ns: l
382
- }), R[w] === h && (R[w] = u[w]);
383
- }
384
- u = R;
385
- }
386
- } else if (O && typeof P == "string" && x === "[object Array]")
387
- u = u.join(P), u && (u = this.extendTranslation(u, e, t, n));
388
- else {
389
- let L = !1, R = !1;
390
- const $ = t.count !== void 0 && typeof t.count != "string", w = W.hasDefaultValue(t), h = $ ? this.pluralResolver.getSuffix(f, t.count, t) : "", N = t.ordinal && $ ? this.pluralResolver.getSuffix(f, t.count, {
391
- ordinal: !1
392
- }) : "", d = t[`defaultValue${h}`] || t[`defaultValue${N}`] || t.defaultValue;
393
- !this.isValidLookup(u) && w && (L = !0, u = d), this.isValidLookup(u) || (R = !0, u = a);
394
- const b = (t.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && R ? void 0 : u, S = w && d !== u && this.options.updateMissing;
395
- if (R || L || S) {
396
- if (this.logger.log(S ? "updateKey" : "missingKey", f, o, a, S ? d : u), r) {
397
- const F = this.resolve(a, {
398
- ...t,
399
- keySeparator: !1
400
- });
401
- F && F.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.");
402
- }
403
- let j = [];
404
- const K = this.languageUtils.getFallbackCodes(this.options.fallbackLng, t.lng || this.language);
405
- if (this.options.saveMissingTo === "fallback" && K && K[0])
406
- for (let F = 0; F < K.length; F++)
407
- j.push(K[F]);
408
- else this.options.saveMissingTo === "all" ? j = this.languageUtils.toResolveHierarchy(t.lng || this.language) : j.push(t.lng || this.language);
409
- const q = (F, E, X) => {
410
- const Z = w && X !== u ? X : b;
411
- this.options.missingKeyHandler ? this.options.missingKeyHandler(F, o, E, Z, S, t) : this.backendConnector && this.backendConnector.saveMissing && this.backendConnector.saveMissing(F, o, E, Z, S, t), this.emit("missingKey", F, o, E, u);
412
- };
413
- this.options.saveMissing && (this.options.saveMissingPlurals && $ ? j.forEach((F) => {
414
- this.pluralResolver.getSuffixes(F, t).forEach((E) => {
415
- q([F], a + E, t[`defaultValue${E}`] || d);
416
- });
417
- }) : q(j, a, d));
418
- }
419
- u = this.extendTranslation(u, e, t, c, n), R && u === a && this.options.appendNamespaceToMissingKey && (u = `${o}:${a}`), (R || L) && this.options.parseMissingKeyHandler && (this.options.compatibilityAPI !== "v1" ? u = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${o}:${a}` : a, L ? u : void 0) : u = this.options.parseMissingKeyHandler(u));
420
- }
421
- return s ? (c.res = u, c.usedParams = this.getUsedParamsDetails(t), c) : u;
422
- }
423
- extendTranslation(e, t, n, s, r) {
424
- var a = this;
425
- if (this.i18nFormat && this.i18nFormat.parse)
426
- e = this.i18nFormat.parse(e, {
427
- ...this.options.interpolation.defaultVariables,
428
- ...n
429
- }, n.lng || this.language || s.usedLng, s.usedNS, s.usedKey, {
430
- resolved: s
431
- });
432
- else if (!n.skipInterpolation) {
433
- n.interpolation && this.interpolator.init({
434
- ...n,
435
- interpolation: {
436
- ...this.options.interpolation,
437
- ...n.interpolation
438
- }
439
- });
440
- const f = typeof e == "string" && (n && n.interpolation && n.interpolation.skipOnVariables !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
441
- let g;
442
- if (f) {
443
- const u = e.match(this.interpolator.nestingRegexp);
444
- g = u && u.length;
445
- }
446
- let c = n.replace && typeof n.replace != "string" ? n.replace : n;
447
- if (this.options.interpolation.defaultVariables && (c = {
448
- ...this.options.interpolation.defaultVariables,
449
- ...c
450
- }), e = this.interpolator.interpolate(e, c, n.lng || this.language, n), f) {
451
- const u = e.match(this.interpolator.nestingRegexp), m = u && u.length;
452
- g < m && (n.nest = !1);
453
- }
454
- !n.lng && this.options.compatibilityAPI !== "v1" && s && s.res && (n.lng = s.usedLng), n.nest !== !1 && (e = this.interpolator.nest(e, function() {
455
- for (var u = arguments.length, m = new Array(u), p = 0; p < u; p++)
456
- m[p] = arguments[p];
457
- return r && r[0] === m[0] && !n.context ? (a.logger.warn(`It seems you are nesting recursively key: ${m[0]} in key: ${t[0]}`), null) : a.translate(...m, t);
458
- }, n)), n.interpolation && this.interpolator.reset();
459
- }
460
- const l = n.postProcess || this.options.postProcess, o = typeof l == "string" ? [l] : l;
461
- return e != null && o && o.length && n.applyPostProcessor !== !1 && (e = fe.handle(o, e, t, this.options && this.options.postProcessPassResolved ? {
462
- i18nResolved: {
463
- ...s,
464
- usedParams: this.getUsedParamsDetails(n)
465
- },
466
- ...n
467
- } : n, this)), e;
468
- }
469
- resolve(e) {
470
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n, s, r, a, l;
471
- return typeof e == "string" && (e = [e]), e.forEach((o) => {
472
- if (this.isValidLookup(n)) return;
473
- const f = this.extractFromKey(o, t), g = f.key;
474
- s = g;
475
- let c = f.namespaces;
476
- this.options.fallbackNS && (c = c.concat(this.options.fallbackNS));
477
- const u = t.count !== void 0 && typeof t.count != "string", m = u && !t.ordinal && t.count === 0 && this.pluralResolver.shouldUseIntlApi(), p = t.context !== void 0 && (typeof t.context == "string" || typeof t.context == "number") && t.context !== "", x = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
478
- c.forEach((v) => {
479
- this.isValidLookup(n) || (l = v, !ne[`${x[0]}-${v}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(l) && (ne[`${x[0]}-${v}`] = !0, this.logger.warn(`key "${s}" for languages "${x.join(", ")}" won't get resolved as namespace "${l}" 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!!!")), x.forEach((P) => {
480
- if (this.isValidLookup(n)) return;
481
- a = P;
482
- const O = [g];
483
- if (this.i18nFormat && this.i18nFormat.addLookupKeys)
484
- this.i18nFormat.addLookupKeys(O, g, P, v, t);
485
- else {
486
- let L;
487
- u && (L = this.pluralResolver.getSuffix(P, t.count, t));
488
- const R = `${this.options.pluralSeparator}zero`, $ = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
489
- if (u && (O.push(g + L), t.ordinal && L.indexOf($) === 0 && O.push(g + L.replace($, this.options.pluralSeparator)), m && O.push(g + R)), p) {
490
- const w = `${g}${this.options.contextSeparator}${t.context}`;
491
- O.push(w), u && (O.push(w + L), t.ordinal && L.indexOf($) === 0 && O.push(w + L.replace($, this.options.pluralSeparator)), m && O.push(w + R));
492
- }
493
- }
494
- let T;
495
- for (; T = O.pop(); )
496
- this.isValidLookup(n) || (r = T, n = this.getResource(P, v, T, t));
497
- }));
498
- });
499
- }), {
500
- res: n,
501
- usedKey: s,
502
- exactUsedKey: r,
503
- usedLng: a,
504
- usedNS: l
505
- };
506
- }
507
- isValidLookup(e) {
508
- return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
509
- }
510
- getResource(e, t, n) {
511
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
512
- return this.i18nFormat && this.i18nFormat.getResource ? this.i18nFormat.getResource(e, t, n, s) : this.resourceStore.getResource(e, t, n, s);
513
- }
514
- getUsedParamsDetails() {
515
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
516
- const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], n = e.replace && typeof e.replace != "string";
517
- let s = n ? e.replace : e;
518
- if (n && typeof e.count < "u" && (s.count = e.count), this.options.interpolation.defaultVariables && (s = {
519
- ...this.options.interpolation.defaultVariables,
520
- ...s
521
- }), !n) {
522
- s = {
523
- ...s
524
- };
525
- for (const r of t)
526
- delete s[r];
527
- }
528
- return s;
529
- }
530
- static hasDefaultValue(e) {
531
- const t = "defaultValue";
532
- for (const n in e)
533
- if (Object.prototype.hasOwnProperty.call(e, n) && t === n.substring(0, t.length) && e[n] !== void 0)
534
- return !0;
535
- return !1;
536
- }
537
- }
538
- function B(i) {
539
- return i.charAt(0).toUpperCase() + i.slice(1);
540
- }
541
- class se {
542
- constructor(e) {
543
- this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = k.create("languageUtils");
544
- }
545
- getScriptPartFromCode(e) {
546
- if (e = z(e), !e || e.indexOf("-") < 0) return null;
547
- const t = e.split("-");
548
- return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
549
- }
550
- getLanguagePartFromCode(e) {
551
- if (e = z(e), !e || e.indexOf("-") < 0) return e;
552
- const t = e.split("-");
553
- return this.formatLanguageCode(t[0]);
554
- }
555
- formatLanguageCode(e) {
556
- if (typeof e == "string" && e.indexOf("-") > -1) {
557
- const t = ["hans", "hant", "latn", "cyrl", "cans", "mong", "arab"];
558
- let n = e.split("-");
559
- return this.options.lowerCaseLng ? n = n.map((s) => s.toLowerCase()) : n.length === 2 ? (n[0] = n[0].toLowerCase(), n[1] = n[1].toUpperCase(), t.indexOf(n[1].toLowerCase()) > -1 && (n[1] = B(n[1].toLowerCase()))) : n.length === 3 && (n[0] = n[0].toLowerCase(), n[1].length === 2 && (n[1] = n[1].toUpperCase()), n[0] !== "sgn" && n[2].length === 2 && (n[2] = n[2].toUpperCase()), t.indexOf(n[1].toLowerCase()) > -1 && (n[1] = B(n[1].toLowerCase())), t.indexOf(n[2].toLowerCase()) > -1 && (n[2] = B(n[2].toLowerCase()))), n.join("-");
560
- }
561
- return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
562
- }
563
- isSupportedCode(e) {
564
- return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
565
- }
566
- getBestMatchFromCodes(e) {
567
- if (!e) return null;
568
- let t;
569
- return e.forEach((n) => {
570
- if (t) return;
571
- const s = this.formatLanguageCode(n);
572
- (!this.options.supportedLngs || this.isSupportedCode(s)) && (t = s);
573
- }), !t && this.options.supportedLngs && e.forEach((n) => {
574
- if (t) return;
575
- const s = this.getLanguagePartFromCode(n);
576
- if (this.isSupportedCode(s)) return t = s;
577
- t = this.options.supportedLngs.find((r) => {
578
- if (r === s) return r;
579
- if (!(r.indexOf("-") < 0 && s.indexOf("-") < 0) && r.indexOf(s) === 0)
580
- return r;
581
- });
582
- }), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
583
- }
584
- getFallbackCodes(e, t) {
585
- if (!e) return [];
586
- if (typeof e == "function" && (e = e(t)), typeof e == "string" && (e = [e]), Object.prototype.toString.apply(e) === "[object Array]") return e;
587
- if (!t) return e.default || [];
588
- let n = e[t];
589
- return n || (n = e[this.getScriptPartFromCode(t)]), n || (n = e[this.formatLanguageCode(t)]), n || (n = e[this.getLanguagePartFromCode(t)]), n || (n = e.default), n || [];
590
- }
591
- toResolveHierarchy(e, t) {
592
- const n = this.getFallbackCodes(t || this.options.fallbackLng || [], e), s = [], r = (a) => {
593
- a && (this.isSupportedCode(a) ? s.push(a) : this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`));
594
- };
595
- return typeof e == "string" && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && r(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && r(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && r(this.getLanguagePartFromCode(e))) : typeof e == "string" && r(this.formatLanguageCode(e)), n.forEach((a) => {
596
- s.indexOf(a) < 0 && r(this.formatLanguageCode(a));
597
- }), s;
598
- }
599
- }
600
- let xe = [{
601
- lngs: ["ach", "ak", "am", "arn", "br", "fil", "gun", "ln", "mfe", "mg", "mi", "oc", "pt", "pt-BR", "tg", "tl", "ti", "tr", "uz", "wa"],
602
- nr: [1, 2],
603
- fc: 1
604
- }, {
605
- lngs: ["af", "an", "ast", "az", "bg", "bn", "ca", "da", "de", "dev", "el", "en", "eo", "es", "et", "eu", "fi", "fo", "fur", "fy", "gl", "gu", "ha", "hi", "hu", "hy", "ia", "it", "kk", "kn", "ku", "lb", "mai", "ml", "mn", "mr", "nah", "nap", "nb", "ne", "nl", "nn", "no", "nso", "pa", "pap", "pms", "ps", "pt-PT", "rm", "sco", "se", "si", "so", "son", "sq", "sv", "sw", "ta", "te", "tk", "ur", "yo"],
606
- nr: [1, 2],
607
- fc: 2
608
- }, {
609
- lngs: ["ay", "bo", "cgg", "fa", "ht", "id", "ja", "jbo", "ka", "km", "ko", "ky", "lo", "ms", "sah", "su", "th", "tt", "ug", "vi", "wo", "zh"],
610
- nr: [1],
611
- fc: 3
612
- }, {
613
- lngs: ["be", "bs", "cnr", "dz", "hr", "ru", "sr", "uk"],
614
- nr: [1, 2, 5],
615
- fc: 4
616
- }, {
617
- lngs: ["ar"],
618
- nr: [0, 1, 2, 3, 11, 100],
619
- fc: 5
620
- }, {
621
- lngs: ["cs", "sk"],
622
- nr: [1, 2, 5],
623
- fc: 6
624
- }, {
625
- lngs: ["csb", "pl"],
626
- nr: [1, 2, 5],
627
- fc: 7
628
- }, {
629
- lngs: ["cy"],
630
- nr: [1, 2, 3, 8],
631
- fc: 8
632
- }, {
633
- lngs: ["fr"],
634
- nr: [1, 2],
635
- fc: 9
636
- }, {
637
- lngs: ["ga"],
638
- nr: [1, 2, 3, 7, 11],
639
- fc: 10
640
- }, {
641
- lngs: ["gd"],
642
- nr: [1, 2, 3, 20],
643
- fc: 11
644
- }, {
645
- lngs: ["is"],
646
- nr: [1, 2],
647
- fc: 12
648
- }, {
649
- lngs: ["jv"],
650
- nr: [0, 1],
651
- fc: 13
652
- }, {
653
- lngs: ["kw"],
654
- nr: [1, 2, 3, 4],
655
- fc: 14
656
- }, {
657
- lngs: ["lt"],
658
- nr: [1, 2, 10],
659
- fc: 15
660
- }, {
661
- lngs: ["lv"],
662
- nr: [1, 2, 0],
663
- fc: 16
664
- }, {
665
- lngs: ["mk"],
666
- nr: [1, 2],
667
- fc: 17
668
- }, {
669
- lngs: ["mnk"],
670
- nr: [0, 1, 2],
671
- fc: 18
672
- }, {
673
- lngs: ["mt"],
674
- nr: [1, 2, 11, 20],
675
- fc: 19
676
- }, {
677
- lngs: ["or"],
678
- nr: [2, 1],
679
- fc: 2
680
- }, {
681
- lngs: ["ro"],
682
- nr: [1, 2, 20],
683
- fc: 20
684
- }, {
685
- lngs: ["sl"],
686
- nr: [5, 1, 2, 3],
687
- fc: 21
688
- }, {
689
- lngs: ["he", "iw"],
690
- nr: [1, 2, 20, 21],
691
- fc: 22
692
- }], Se = {
693
- 1: function(i) {
694
- return +(i > 1);
695
- },
696
- 2: function(i) {
697
- return +(i != 1);
698
- },
699
- 3: function(i) {
700
- return 0;
701
- },
702
- 4: function(i) {
703
- return i % 10 == 1 && i % 100 != 11 ? 0 : i % 10 >= 2 && i % 10 <= 4 && (i % 100 < 10 || i % 100 >= 20) ? 1 : 2;
704
- },
705
- 5: function(i) {
706
- return i == 0 ? 0 : i == 1 ? 1 : i == 2 ? 2 : i % 100 >= 3 && i % 100 <= 10 ? 3 : i % 100 >= 11 ? 4 : 5;
707
- },
708
- 6: function(i) {
709
- return i == 1 ? 0 : i >= 2 && i <= 4 ? 1 : 2;
710
- },
711
- 7: function(i) {
712
- return i == 1 ? 0 : i % 10 >= 2 && i % 10 <= 4 && (i % 100 < 10 || i % 100 >= 20) ? 1 : 2;
713
- },
714
- 8: function(i) {
715
- return i == 1 ? 0 : i == 2 ? 1 : i != 8 && i != 11 ? 2 : 3;
716
- },
717
- 9: function(i) {
718
- return +(i >= 2);
719
- },
720
- 10: function(i) {
721
- return i == 1 ? 0 : i == 2 ? 1 : i < 7 ? 2 : i < 11 ? 3 : 4;
722
- },
723
- 11: function(i) {
724
- return i == 1 || i == 11 ? 0 : i == 2 || i == 12 ? 1 : i > 2 && i < 20 ? 2 : 3;
725
- },
726
- 12: function(i) {
727
- return +(i % 10 != 1 || i % 100 == 11);
728
- },
729
- 13: function(i) {
730
- return +(i !== 0);
731
- },
732
- 14: function(i) {
733
- return i == 1 ? 0 : i == 2 ? 1 : i == 3 ? 2 : 3;
734
- },
735
- 15: function(i) {
736
- return i % 10 == 1 && i % 100 != 11 ? 0 : i % 10 >= 2 && (i % 100 < 10 || i % 100 >= 20) ? 1 : 2;
737
- },
738
- 16: function(i) {
739
- return i % 10 == 1 && i % 100 != 11 ? 0 : i !== 0 ? 1 : 2;
740
- },
741
- 17: function(i) {
742
- return i == 1 || i % 10 == 1 && i % 100 != 11 ? 0 : 1;
743
- },
744
- 18: function(i) {
745
- return i == 0 ? 0 : i == 1 ? 1 : 2;
746
- },
747
- 19: function(i) {
748
- return i == 1 ? 0 : i == 0 || i % 100 > 1 && i % 100 < 11 ? 1 : i % 100 > 10 && i % 100 < 20 ? 2 : 3;
749
- },
750
- 20: function(i) {
751
- return i == 1 ? 0 : i == 0 || i % 100 > 0 && i % 100 < 20 ? 1 : 2;
752
- },
753
- 21: function(i) {
754
- return i % 100 == 1 ? 1 : i % 100 == 2 ? 2 : i % 100 == 3 || i % 100 == 4 ? 3 : 0;
755
- },
756
- 22: function(i) {
757
- return i == 1 ? 0 : i == 2 ? 1 : (i < 0 || i > 10) && i % 10 == 0 ? 2 : 3;
758
- }
759
- };
760
- const ve = ["v1", "v2", "v3"], Le = ["v4"], ie = {
761
- zero: 0,
762
- one: 1,
763
- two: 2,
764
- few: 3,
765
- many: 4,
766
- other: 5
767
- };
768
- function Oe() {
769
- const i = {};
770
- return xe.forEach((e) => {
771
- e.lngs.forEach((t) => {
772
- i[t] = {
773
- numbers: e.nr,
774
- plurals: Se[e.fc]
775
- };
776
- });
777
- }), i;
778
- }
779
- class we {
780
- constructor(e) {
781
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
782
- this.languageUtils = e, this.options = t, this.logger = k.create("pluralResolver"), (!this.options.compatibilityJSON || Le.includes(this.options.compatibilityJSON)) && (typeof Intl > "u" || !Intl.PluralRules) && (this.options.compatibilityJSON = "v3", this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")), this.rules = Oe();
783
- }
784
- addRule(e, t) {
785
- this.rules[e] = t;
786
- }
787
- getRule(e) {
788
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
789
- if (this.shouldUseIntlApi())
790
- try {
791
- return new Intl.PluralRules(z(e), {
792
- type: t.ordinal ? "ordinal" : "cardinal"
793
- });
794
- } catch {
795
- return;
796
- }
797
- return this.rules[e] || this.rules[this.languageUtils.getLanguagePartFromCode(e)];
798
- }
799
- needsPlural(e) {
800
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
801
- const n = this.getRule(e, t);
802
- return this.shouldUseIntlApi() ? n && n.resolvedOptions().pluralCategories.length > 1 : n && n.numbers.length > 1;
803
- }
804
- getPluralFormsOfKey(e, t) {
805
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
806
- return this.getSuffixes(e, n).map((s) => `${t}${s}`);
807
- }
808
- getSuffixes(e) {
809
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
810
- const n = this.getRule(e, t);
811
- return n ? this.shouldUseIntlApi() ? n.resolvedOptions().pluralCategories.sort((s, r) => ie[s] - ie[r]).map((s) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${s}`) : n.numbers.map((s) => this.getSuffix(e, s, t)) : [];
812
- }
813
- getSuffix(e, t) {
814
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
815
- const s = this.getRule(e, n);
816
- return s ? this.shouldUseIntlApi() ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${s.select(t)}` : this.getSuffixRetroCompatible(s, t) : (this.logger.warn(`no plural rule found for: ${e}`), "");
817
- }
818
- getSuffixRetroCompatible(e, t) {
819
- const n = e.noAbs ? e.plurals(t) : e.plurals(Math.abs(t));
820
- let s = e.numbers[n];
821
- this.options.simplifyPluralSuffix && e.numbers.length === 2 && e.numbers[0] === 1 && (s === 2 ? s = "plural" : s === 1 && (s = ""));
822
- const r = () => this.options.prepend && s.toString() ? this.options.prepend + s.toString() : s.toString();
823
- return this.options.compatibilityJSON === "v1" ? s === 1 ? "" : typeof s == "number" ? `_plural_${s.toString()}` : r() : this.options.compatibilityJSON === "v2" || this.options.simplifyPluralSuffix && e.numbers.length === 2 && e.numbers[0] === 1 ? r() : this.options.prepend && n.toString() ? this.options.prepend + n.toString() : n.toString();
824
- }
825
- shouldUseIntlApi() {
826
- return !ve.includes(this.options.compatibilityJSON);
827
- }
828
- }
829
- function re(i, e, t) {
830
- let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".", s = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, r = de(i, e, t);
831
- return !r && s && typeof t == "string" && (r = J(i, t, n), r === void 0 && (r = J(e, t, n))), r;
832
- }
833
- class Ne {
834
- constructor() {
835
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
836
- this.logger = k.create("interpolator"), this.options = e, this.format = e.interpolation && e.interpolation.format || ((t) => t), this.init(e);
837
- }
838
- init() {
839
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
840
- e.interpolation || (e.interpolation = {
841
- escapeValue: !0
842
- });
843
- const t = e.interpolation;
844
- this.escape = t.escape !== void 0 ? t.escape : me, this.escapeValue = t.escapeValue !== void 0 ? t.escapeValue : !0, this.useRawValueToEscape = t.useRawValueToEscape !== void 0 ? t.useRawValueToEscape : !1, this.prefix = t.prefix ? I(t.prefix) : t.prefixEscaped || "{{", this.suffix = t.suffix ? I(t.suffix) : t.suffixEscaped || "}}", this.formatSeparator = t.formatSeparator ? t.formatSeparator : t.formatSeparator || ",", this.unescapePrefix = t.unescapeSuffix ? "" : t.unescapePrefix || "-", this.unescapeSuffix = this.unescapePrefix ? "" : t.unescapeSuffix || "", this.nestingPrefix = t.nestingPrefix ? I(t.nestingPrefix) : t.nestingPrefixEscaped || I("$t("), this.nestingSuffix = t.nestingSuffix ? I(t.nestingSuffix) : t.nestingSuffixEscaped || I(")"), this.nestingOptionsSeparator = t.nestingOptionsSeparator ? t.nestingOptionsSeparator : t.nestingOptionsSeparator || ",", this.maxReplaces = t.maxReplaces ? t.maxReplaces : 1e3, this.alwaysFormat = t.alwaysFormat !== void 0 ? t.alwaysFormat : !1, this.resetRegExp();
845
- }
846
- reset() {
847
- this.options && this.init(this.options);
848
- }
849
- resetRegExp() {
850
- const e = `${this.prefix}(.+?)${this.suffix}`;
851
- this.regexp = new RegExp(e, "g");
852
- const t = `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;
853
- this.regexpUnescape = new RegExp(t, "g");
854
- const n = `${this.nestingPrefix}(.+?)${this.nestingSuffix}`;
855
- this.nestingRegexp = new RegExp(n, "g");
856
- }
857
- interpolate(e, t, n, s) {
858
- let r, a, l;
859
- const o = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
860
- function f(p) {
861
- return p.replace(/\$/g, "$$$$");
862
- }
863
- const g = (p) => {
864
- if (p.indexOf(this.formatSeparator) < 0) {
865
- const O = re(t, o, p, this.options.keySeparator, this.options.ignoreJSONStructure);
866
- return this.alwaysFormat ? this.format(O, void 0, n, {
867
- ...s,
868
- ...t,
869
- interpolationkey: p
870
- }) : O;
871
- }
872
- const x = p.split(this.formatSeparator), v = x.shift().trim(), P = x.join(this.formatSeparator).trim();
873
- return this.format(re(t, o, v, this.options.keySeparator, this.options.ignoreJSONStructure), P, n, {
874
- ...s,
875
- ...t,
876
- interpolationkey: v
877
- });
878
- };
879
- this.resetRegExp();
880
- const c = s && s.missingInterpolationHandler || this.options.missingInterpolationHandler, u = s && s.interpolation && s.interpolation.skipOnVariables !== void 0 ? s.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
881
- return [{
882
- regex: this.regexpUnescape,
883
- safeValue: (p) => f(p)
884
- }, {
885
- regex: this.regexp,
886
- safeValue: (p) => this.escapeValue ? f(this.escape(p)) : f(p)
887
- }].forEach((p) => {
888
- for (l = 0; r = p.regex.exec(e); ) {
889
- const x = r[1].trim();
890
- if (a = g(x), a === void 0)
891
- if (typeof c == "function") {
892
- const P = c(e, r, s);
893
- a = typeof P == "string" ? P : "";
894
- } else if (s && Object.prototype.hasOwnProperty.call(s, x))
895
- a = "";
896
- else if (u) {
897
- a = r[0];
898
- continue;
899
- } else
900
- this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`), a = "";
901
- else typeof a != "string" && !this.useRawValueToEscape && (a = _(a));
902
- const v = p.safeValue(a);
903
- if (e = e.replace(r[0], v), u ? (p.regex.lastIndex += a.length, p.regex.lastIndex -= r[0].length) : p.regex.lastIndex = 0, l++, l >= this.maxReplaces)
904
- break;
905
- }
906
- }), e;
907
- }
908
- nest(e, t) {
909
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, s, r, a;
910
- function l(o, f) {
911
- const g = this.nestingOptionsSeparator;
912
- if (o.indexOf(g) < 0) return o;
913
- const c = o.split(new RegExp(`${g}[ ]*{`));
914
- let u = `{${c[1]}`;
915
- o = c[0], u = this.interpolate(u, a);
916
- const m = u.match(/'/g), p = u.match(/"/g);
917
- (m && m.length % 2 === 0 && !p || p.length % 2 !== 0) && (u = u.replace(/'/g, '"'));
918
- try {
919
- a = JSON.parse(u), f && (a = {
920
- ...f,
921
- ...a
922
- });
923
- } catch (x) {
924
- return this.logger.warn(`failed parsing options string in nesting for key ${o}`, x), `${o}${g}${u}`;
925
- }
926
- return delete a.defaultValue, o;
927
- }
928
- for (; s = this.nestingRegexp.exec(e); ) {
929
- let o = [];
930
- a = {
931
- ...n
932
- }, a = a.replace && typeof a.replace != "string" ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue;
933
- let f = !1;
934
- if (s[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(s[1])) {
935
- const g = s[1].split(this.formatSeparator).map((c) => c.trim());
936
- s[1] = g.shift(), o = g, f = !0;
937
- }
938
- if (r = t(l.call(this, s[1].trim(), a), a), r && s[0] === e && typeof r != "string") return r;
939
- typeof r != "string" && (r = _(r)), r || (this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`), r = ""), f && (r = o.reduce((g, c) => this.format(g, c, n.lng, {
940
- ...n,
941
- interpolationkey: s[1].trim()
942
- }), r.trim())), e = e.replace(s[0], r), this.regexp.lastIndex = 0;
943
- }
944
- return e;
945
- }
946
- }
947
- function Pe(i) {
948
- let e = i.toLowerCase().trim();
949
- const t = {};
950
- if (i.indexOf("(") > -1) {
951
- const n = i.split("(");
952
- e = n[0].toLowerCase().trim();
953
- const s = n[1].substring(0, n[1].length - 1);
954
- e === "currency" && s.indexOf(":") < 0 ? t.currency || (t.currency = s.trim()) : e === "relativetime" && s.indexOf(":") < 0 ? t.range || (t.range = s.trim()) : s.split(";").forEach((a) => {
955
- if (!a) return;
956
- const [l, ...o] = a.split(":"), f = o.join(":").trim().replace(/^'+|'+$/g, "");
957
- t[l.trim()] || (t[l.trim()] = f), f === "false" && (t[l.trim()] = !1), f === "true" && (t[l.trim()] = !0), isNaN(f) || (t[l.trim()] = parseInt(f, 10));
958
- });
959
- }
960
- return {
961
- formatName: e,
962
- formatOptions: t
963
- };
964
- }
965
- function A(i) {
966
- const e = {};
967
- return function(n, s, r) {
968
- const a = s + JSON.stringify(r);
969
- let l = e[a];
970
- return l || (l = i(z(s), r), e[a] = l), l(n);
971
- };
972
- }
973
- class Re {
974
- constructor() {
975
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
976
- this.logger = k.create("formatter"), this.options = e, this.formats = {
977
- number: A((t, n) => {
978
- const s = new Intl.NumberFormat(t, {
979
- ...n
980
- });
981
- return (r) => s.format(r);
982
- }),
983
- currency: A((t, n) => {
984
- const s = new Intl.NumberFormat(t, {
985
- ...n,
986
- style: "currency"
987
- });
988
- return (r) => s.format(r);
989
- }),
990
- datetime: A((t, n) => {
991
- const s = new Intl.DateTimeFormat(t, {
992
- ...n
993
- });
994
- return (r) => s.format(r);
995
- }),
996
- relativetime: A((t, n) => {
997
- const s = new Intl.RelativeTimeFormat(t, {
998
- ...n
999
- });
1000
- return (r) => s.format(r, n.range || "day");
1001
- }),
1002
- list: A((t, n) => {
1003
- const s = new Intl.ListFormat(t, {
1004
- ...n
1005
- });
1006
- return (r) => s.format(r);
1007
- })
1008
- }, this.init(e);
1009
- }
1010
- init(e) {
1011
- const n = (arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
1012
- interpolation: {}
1013
- }).interpolation;
1014
- this.formatSeparator = n.formatSeparator ? n.formatSeparator : n.formatSeparator || ",";
1015
- }
1016
- add(e, t) {
1017
- this.formats[e.toLowerCase().trim()] = t;
1018
- }
1019
- addCached(e, t) {
1020
- this.formats[e.toLowerCase().trim()] = A(t);
1021
- }
1022
- format(e, t, n) {
1023
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
1024
- return t.split(this.formatSeparator).reduce((l, o) => {
1025
- const {
1026
- formatName: f,
1027
- formatOptions: g
1028
- } = Pe(o);
1029
- if (this.formats[f]) {
1030
- let c = l;
1031
- try {
1032
- const u = s && s.formatParams && s.formatParams[s.interpolationkey] || {}, m = u.locale || u.lng || s.locale || s.lng || n;
1033
- c = this.formats[f](l, m, {
1034
- ...g,
1035
- ...s,
1036
- ...u
1037
- });
1038
- } catch (u) {
1039
- this.logger.warn(u);
1040
- }
1041
- return c;
1042
- } else
1043
- this.logger.warn(`there was no format function for ${f}`);
1044
- return l;
1045
- }, e);
1046
- }
1047
- }
1048
- function Ce(i, e) {
1049
- i.pending[e] !== void 0 && (delete i.pending[e], i.pendingCount--);
1050
- }
1051
- class Fe extends Y {
1052
- constructor(e, t, n) {
1053
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
1054
- super(), this.backend = e, this.store = t, this.services = n, this.languageUtils = n.languageUtils, this.options = s, this.logger = k.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = s.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = s.maxRetries >= 0 ? s.maxRetries : 5, this.retryTimeout = s.retryTimeout >= 1 ? s.retryTimeout : 350, this.state = {}, this.queue = [], this.backend && this.backend.init && this.backend.init(n, s.backend, s);
1055
- }
1056
- queueLoad(e, t, n, s) {
1057
- const r = {}, a = {}, l = {}, o = {};
1058
- return e.forEach((f) => {
1059
- let g = !0;
1060
- t.forEach((c) => {
1061
- const u = `${f}|${c}`;
1062
- !n.reload && this.store.hasResourceBundle(f, c) ? this.state[u] = 2 : this.state[u] < 0 || (this.state[u] === 1 ? a[u] === void 0 && (a[u] = !0) : (this.state[u] = 1, g = !1, a[u] === void 0 && (a[u] = !0), r[u] === void 0 && (r[u] = !0), o[c] === void 0 && (o[c] = !0)));
1063
- }), g || (l[f] = !0);
1064
- }), (Object.keys(r).length || Object.keys(a).length) && this.queue.push({
1065
- pending: a,
1066
- pendingCount: Object.keys(a).length,
1067
- loaded: {},
1068
- errors: [],
1069
- callback: s
1070
- }), {
1071
- toLoad: Object.keys(r),
1072
- pending: Object.keys(a),
1073
- toLoadLanguages: Object.keys(l),
1074
- toLoadNamespaces: Object.keys(o)
1075
- };
1076
- }
1077
- loaded(e, t, n) {
1078
- const s = e.split("|"), r = s[0], a = s[1];
1079
- t && this.emit("failedLoading", r, a, t), n && this.store.addResourceBundle(r, a, n), this.state[e] = t ? -1 : 2;
1080
- const l = {};
1081
- this.queue.forEach((o) => {
1082
- ce(o.loaded, [r], a), Ce(o, e), t && o.errors.push(t), o.pendingCount === 0 && !o.done && (Object.keys(o.loaded).forEach((f) => {
1083
- l[f] || (l[f] = {});
1084
- const g = o.loaded[f];
1085
- g.length && g.forEach((c) => {
1086
- l[f][c] === void 0 && (l[f][c] = !0);
1087
- });
1088
- }), o.done = !0, o.errors.length ? o.callback(o.errors) : o.callback());
1089
- }), this.emit("loaded", l), this.queue = this.queue.filter((o) => !o.done);
1090
- }
1091
- read(e, t, n) {
1092
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0, r = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout, a = arguments.length > 5 ? arguments[5] : void 0;
1093
- if (!e.length) return a(null, {});
1094
- if (this.readingCalls >= this.maxParallelReads) {
1095
- this.waitingReads.push({
1096
- lng: e,
1097
- ns: t,
1098
- fcName: n,
1099
- tried: s,
1100
- wait: r,
1101
- callback: a
1102
- });
1103
- return;
1104
- }
1105
- this.readingCalls++;
1106
- const l = (f, g) => {
1107
- if (this.readingCalls--, this.waitingReads.length > 0) {
1108
- const c = this.waitingReads.shift();
1109
- this.read(c.lng, c.ns, c.fcName, c.tried, c.wait, c.callback);
1110
- }
1111
- if (f && g && s < this.maxRetries) {
1112
- setTimeout(() => {
1113
- this.read.call(this, e, t, n, s + 1, r * 2, a);
1114
- }, r);
1115
- return;
1116
- }
1117
- a(f, g);
1118
- }, o = this.backend[n].bind(this.backend);
1119
- if (o.length === 2) {
1120
- try {
1121
- const f = o(e, t);
1122
- f && typeof f.then == "function" ? f.then((g) => l(null, g)).catch(l) : l(null, f);
1123
- } catch (f) {
1124
- l(f);
1125
- }
1126
- return;
1127
- }
1128
- return o(e, t, l);
1129
- }
1130
- prepareLoading(e, t) {
1131
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, s = arguments.length > 3 ? arguments[3] : void 0;
1132
- if (!this.backend)
1133
- return this.logger.warn("No backend was added via i18next.use. Will not load resources."), s && s();
1134
- typeof e == "string" && (e = this.languageUtils.toResolveHierarchy(e)), typeof t == "string" && (t = [t]);
1135
- const r = this.queueLoad(e, t, n, s);
1136
- if (!r.toLoad.length)
1137
- return r.pending.length || s(), null;
1138
- r.toLoad.forEach((a) => {
1139
- this.loadOne(a);
1140
- });
1141
- }
1142
- load(e, t, n) {
1143
- this.prepareLoading(e, t, {}, n);
1144
- }
1145
- reload(e, t, n) {
1146
- this.prepareLoading(e, t, {
1147
- reload: !0
1148
- }, n);
1149
- }
1150
- loadOne(e) {
1151
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
1152
- const n = e.split("|"), s = n[0], r = n[1];
1153
- this.read(s, r, "read", void 0, void 0, (a, l) => {
1154
- a && this.logger.warn(`${t}loading namespace ${r} for language ${s} failed`, a), !a && l && this.logger.log(`${t}loaded namespace ${r} for language ${s}`, l), this.loaded(e, a, l);
1155
- });
1156
- }
1157
- saveMissing(e, t, n, s, r) {
1158
- let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {}, l = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
1159
- };
1160
- if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(t)) {
1161
- 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!!!");
1162
- return;
1163
- }
1164
- if (!(n == null || n === "")) {
1165
- if (this.backend && this.backend.create) {
1166
- const o = {
1167
- ...a,
1168
- isUpdate: r
1169
- }, f = this.backend.create.bind(this.backend);
1170
- if (f.length < 6)
1171
- try {
1172
- let g;
1173
- f.length === 5 ? g = f(e, t, n, s, o) : g = f(e, t, n, s), g && typeof g.then == "function" ? g.then((c) => l(null, c)).catch(l) : l(null, g);
1174
- } catch (g) {
1175
- l(g);
1176
- }
1177
- else
1178
- f(e, t, n, s, l, o);
1179
- }
1180
- !e || !e[0] || this.store.addResource(e[0], t, n, s);
1181
- }
1182
- }
1183
- }
1184
- function ae() {
1185
- return {
1186
- debug: !1,
1187
- initImmediate: !0,
1188
- ns: ["translation"],
1189
- defaultNS: ["translation"],
1190
- fallbackLng: ["dev"],
1191
- fallbackNS: !1,
1192
- supportedLngs: !1,
1193
- nonExplicitSupportedLngs: !1,
1194
- load: "all",
1195
- preload: !1,
1196
- simplifyPluralSuffix: !0,
1197
- keySeparator: ".",
1198
- nsSeparator: ":",
1199
- pluralSeparator: "_",
1200
- contextSeparator: "_",
1201
- partialBundledLanguages: !1,
1202
- saveMissing: !1,
1203
- updateMissing: !1,
1204
- saveMissingTo: "fallback",
1205
- saveMissingPlurals: !0,
1206
- missingKeyHandler: !1,
1207
- missingInterpolationHandler: !1,
1208
- postProcess: !1,
1209
- postProcessPassResolved: !1,
1210
- returnNull: !1,
1211
- returnEmptyString: !0,
1212
- returnObjects: !1,
1213
- joinArrays: !1,
1214
- returnedObjectHandler: !1,
1215
- parseMissingKeyHandler: !1,
1216
- appendNamespaceToMissingKey: !1,
1217
- appendNamespaceToCIMode: !1,
1218
- overloadTranslationOptionHandler: function(e) {
1219
- let t = {};
1220
- if (typeof e[1] == "object" && (t = e[1]), typeof e[1] == "string" && (t.defaultValue = e[1]), typeof e[2] == "string" && (t.tDescription = e[2]), typeof e[2] == "object" || typeof e[3] == "object") {
1221
- const n = e[3] || e[2];
1222
- Object.keys(n).forEach((s) => {
1223
- t[s] = n[s];
1224
- });
1225
- }
1226
- return t;
1227
- },
1228
- interpolation: {
1229
- escapeValue: !0,
1230
- format: (i) => i,
1231
- prefix: "{{",
1232
- suffix: "}}",
1233
- formatSeparator: ",",
1234
- unescapePrefix: "-",
1235
- nestingPrefix: "$t(",
1236
- nestingSuffix: ")",
1237
- nestingOptionsSeparator: ",",
1238
- maxReplaces: 1e3,
1239
- skipOnVariables: !0
1240
- }
1241
- };
1242
- }
1243
- function oe(i) {
1244
- return typeof i.ns == "string" && (i.ns = [i.ns]), typeof i.fallbackLng == "string" && (i.fallbackLng = [i.fallbackLng]), typeof i.fallbackNS == "string" && (i.fallbackNS = [i.fallbackNS]), i.supportedLngs && i.supportedLngs.indexOf("cimode") < 0 && (i.supportedLngs = i.supportedLngs.concat(["cimode"])), i;
1245
- }
1246
- function U() {
1247
- }
1248
- function $e(i) {
1249
- Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((t) => {
1250
- typeof i[t] == "function" && (i[t] = i[t].bind(i));
1251
- });
1252
- }
1253
- class V extends Y {
1254
- constructor() {
1255
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 ? arguments[1] : void 0;
1256
- if (super(), this.options = oe(e), this.services = {}, this.logger = k, this.modules = {
1257
- external: []
1258
- }, $e(this), t && !this.isInitialized && !e.isClone) {
1259
- if (!this.options.initImmediate)
1260
- return this.init(e, t), this;
1261
- setTimeout(() => {
1262
- this.init(e, t);
1263
- }, 0);
1264
- }
1265
- }
1266
- init() {
1267
- var e = this;
1268
- let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = arguments.length > 1 ? arguments[1] : void 0;
1269
- typeof t == "function" && (n = t, t = {}), !t.defaultNS && t.defaultNS !== !1 && t.ns && (typeof t.ns == "string" ? t.defaultNS = t.ns : t.ns.indexOf("translation") < 0 && (t.defaultNS = t.ns[0]));
1270
- const s = ae();
1271
- this.options = {
1272
- ...s,
1273
- ...this.options,
1274
- ...oe(t)
1275
- }, this.options.compatibilityAPI !== "v1" && (this.options.interpolation = {
1276
- ...s.interpolation,
1277
- ...this.options.interpolation
1278
- }), t.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = t.keySeparator), t.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = t.nsSeparator);
1279
- function r(g) {
1280
- return g ? typeof g == "function" ? new g() : g : null;
1281
- }
1282
- if (!this.options.isClone) {
1283
- this.modules.logger ? k.init(r(this.modules.logger), this.options) : k.init(null, this.options);
1284
- let g;
1285
- this.modules.formatter ? g = this.modules.formatter : typeof Intl < "u" && (g = Re);
1286
- const c = new se(this.options);
1287
- this.store = new te(this.options.resources, this.options);
1288
- const u = this.services;
1289
- u.logger = k, u.resourceStore = this.store, u.languageUtils = c, u.pluralResolver = new we(c, {
1290
- prepend: this.options.pluralSeparator,
1291
- compatibilityJSON: this.options.compatibilityJSON,
1292
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1293
- }), g && (!this.options.interpolation.format || this.options.interpolation.format === s.interpolation.format) && (u.formatter = r(g), u.formatter.init(u, this.options), this.options.interpolation.format = u.formatter.format.bind(u.formatter)), u.interpolator = new Ne(this.options), u.utils = {
1294
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1295
- }, u.backendConnector = new Fe(r(this.modules.backend), u.resourceStore, u, this.options), u.backendConnector.on("*", function(m) {
1296
- for (var p = arguments.length, x = new Array(p > 1 ? p - 1 : 0), v = 1; v < p; v++)
1297
- x[v - 1] = arguments[v];
1298
- e.emit(m, ...x);
1299
- }), this.modules.languageDetector && (u.languageDetector = r(this.modules.languageDetector), u.languageDetector.init && u.languageDetector.init(u, this.options.detection, this.options)), this.modules.i18nFormat && (u.i18nFormat = r(this.modules.i18nFormat), u.i18nFormat.init && u.i18nFormat.init(this)), this.translator = new W(this.services, this.options), this.translator.on("*", function(m) {
1300
- for (var p = arguments.length, x = new Array(p > 1 ? p - 1 : 0), v = 1; v < p; v++)
1301
- x[v - 1] = arguments[v];
1302
- e.emit(m, ...x);
1303
- }), this.modules.external.forEach((m) => {
1304
- m.init && m.init(this);
1305
- });
1306
- }
1307
- if (this.format = this.options.interpolation.format, n || (n = U), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1308
- const g = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1309
- g.length > 0 && g[0] !== "dev" && (this.options.lng = g[0]);
1310
- }
1311
- !this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((g) => {
1312
- this[g] = function() {
1313
- return e.store[g](...arguments);
1314
- };
1315
- }), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((g) => {
1316
- this[g] = function() {
1317
- return e.store[g](...arguments), e;
1318
- };
1319
- });
1320
- const o = D(), f = () => {
1321
- const g = (c, u) => {
1322
- 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(u), n(c, u);
1323
- };
1324
- if (this.languages && this.options.compatibilityAPI !== "v1" && !this.isInitialized) return g(null, this.t.bind(this));
1325
- this.changeLanguage(this.options.lng, g);
1326
- };
1327
- return this.options.resources || !this.options.initImmediate ? f() : setTimeout(f, 0), o;
1328
- }
1329
- loadResources(e) {
1330
- let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : U;
1331
- const s = typeof e == "string" ? e : this.language;
1332
- if (typeof e == "function" && (n = e), !this.options.resources || this.options.partialBundledLanguages) {
1333
- if (s && s.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return n();
1334
- const r = [], a = (l) => {
1335
- if (!l || l === "cimode") return;
1336
- this.services.languageUtils.toResolveHierarchy(l).forEach((f) => {
1337
- f !== "cimode" && r.indexOf(f) < 0 && r.push(f);
1338
- });
1339
- };
1340
- s ? a(s) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((o) => a(o)), this.options.preload && this.options.preload.forEach((l) => a(l)), this.services.backendConnector.load(r, this.options.ns, (l) => {
1341
- !l && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), n(l);
1342
- });
1343
- } else
1344
- n(null);
1345
- }
1346
- reloadResources(e, t, n) {
1347
- const s = D();
1348
- return e || (e = this.languages), t || (t = this.options.ns), n || (n = U), this.services.backendConnector.reload(e, t, (r) => {
1349
- s.resolve(), n(r);
1350
- }), s;
1351
- }
1352
- use(e) {
1353
- if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1354
- if (!e.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1355
- 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" && fe.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
1356
- }
1357
- setResolvedLanguage(e) {
1358
- if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1))
1359
- for (let t = 0; t < this.languages.length; t++) {
1360
- const n = this.languages[t];
1361
- if (!(["cimode", "dev"].indexOf(n) > -1) && this.store.hasLanguageSomeTranslations(n)) {
1362
- this.resolvedLanguage = n;
1363
- break;
1364
- }
1365
- }
1366
- }
1367
- changeLanguage(e, t) {
1368
- var n = this;
1369
- this.isLanguageChangingTo = e;
1370
- const s = D();
1371
- this.emit("languageChanging", e);
1372
- const r = (o) => {
1373
- this.language = o, this.languages = this.services.languageUtils.toResolveHierarchy(o), this.resolvedLanguage = void 0, this.setResolvedLanguage(o);
1374
- }, a = (o, f) => {
1375
- f ? (r(f), this.translator.changeLanguage(f), this.isLanguageChangingTo = void 0, this.emit("languageChanged", f), this.logger.log("languageChanged", f)) : this.isLanguageChangingTo = void 0, s.resolve(function() {
1376
- return n.t(...arguments);
1377
- }), t && t(o, function() {
1378
- return n.t(...arguments);
1379
- });
1380
- }, l = (o) => {
1381
- !e && !o && this.services.languageDetector && (o = []);
1382
- const f = typeof o == "string" ? o : this.services.languageUtils.getBestMatchFromCodes(o);
1383
- f && (this.language || r(f), this.translator.language || this.translator.changeLanguage(f), this.services.languageDetector && this.services.languageDetector.cacheUserLanguage && this.services.languageDetector.cacheUserLanguage(f)), this.loadResources(f, (g) => {
1384
- a(g, f);
1385
- });
1386
- };
1387
- return !e && this.services.languageDetector && !this.services.languageDetector.async ? l(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(l) : this.services.languageDetector.detect(l) : l(e), s;
1388
- }
1389
- getFixedT(e, t, n) {
1390
- var s = this;
1391
- const r = function(a, l) {
1392
- let o;
1393
- if (typeof l != "object") {
1394
- for (var f = arguments.length, g = new Array(f > 2 ? f - 2 : 0), c = 2; c < f; c++)
1395
- g[c - 2] = arguments[c];
1396
- o = s.options.overloadTranslationOptionHandler([a, l].concat(g));
1397
- } else
1398
- o = {
1399
- ...l
1400
- };
1401
- o.lng = o.lng || r.lng, o.lngs = o.lngs || r.lngs, o.ns = o.ns || r.ns, o.keyPrefix = o.keyPrefix || n || r.keyPrefix;
1402
- const u = s.options.keySeparator || ".";
1403
- let m;
1404
- return o.keyPrefix && Array.isArray(a) ? m = a.map((p) => `${o.keyPrefix}${u}${p}`) : m = o.keyPrefix ? `${o.keyPrefix}${u}${a}` : a, s.t(m, o);
1405
- };
1406
- return typeof e == "string" ? r.lng = e : r.lngs = e, r.ns = t, r.keyPrefix = n, r;
1407
- }
1408
- t() {
1409
- return this.translator && this.translator.translate(...arguments);
1410
- }
1411
- exists() {
1412
- return this.translator && this.translator.exists(...arguments);
1413
- }
1414
- setDefaultNamespace(e) {
1415
- this.options.defaultNS = e;
1416
- }
1417
- hasLoadedNamespace(e) {
1418
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1419
- if (!this.isInitialized)
1420
- return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
1421
- if (!this.languages || !this.languages.length)
1422
- return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
1423
- const n = t.lng || this.resolvedLanguage || this.languages[0], s = this.options ? this.options.fallbackLng : !1, r = this.languages[this.languages.length - 1];
1424
- if (n.toLowerCase() === "cimode") return !0;
1425
- const a = (l, o) => {
1426
- const f = this.services.backendConnector.state[`${l}|${o}`];
1427
- return f === -1 || f === 2;
1428
- };
1429
- if (t.precheck) {
1430
- const l = t.precheck(this, a);
1431
- if (l !== void 0) return l;
1432
- }
1433
- return !!(this.hasResourceBundle(n, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(n, e) && (!s || a(r, e)));
1434
- }
1435
- loadNamespaces(e, t) {
1436
- const n = D();
1437
- return this.options.ns ? (typeof e == "string" && (e = [e]), e.forEach((s) => {
1438
- this.options.ns.indexOf(s) < 0 && this.options.ns.push(s);
1439
- }), this.loadResources((s) => {
1440
- n.resolve(), t && t(s);
1441
- }), n) : (t && t(), Promise.resolve());
1442
- }
1443
- loadLanguages(e, t) {
1444
- const n = D();
1445
- typeof e == "string" && (e = [e]);
1446
- const s = this.options.preload || [], r = e.filter((a) => s.indexOf(a) < 0);
1447
- return r.length ? (this.options.preload = s.concat(r), this.loadResources((a) => {
1448
- n.resolve(), t && t(a);
1449
- }), n) : (t && t(), Promise.resolve());
1450
- }
1451
- dir(e) {
1452
- if (e || (e = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language)), !e) return "rtl";
1453
- const t = ["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"], n = this.services && this.services.languageUtils || new se(ae());
1454
- return t.indexOf(n.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1455
- }
1456
- static createInstance() {
1457
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 ? arguments[1] : void 0;
1458
- return new V(e, t);
1459
- }
1460
- cloneInstance() {
1461
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : U;
1462
- const n = e.forkResourceStore;
1463
- n && delete e.forkResourceStore;
1464
- const s = {
1465
- ...this.options,
1466
- ...e,
1467
- isClone: !0
1468
- }, r = new V(s);
1469
- return (e.debug !== void 0 || e.prefix !== void 0) && (r.logger = r.logger.clone(e)), ["store", "services", "language"].forEach((l) => {
1470
- r[l] = this[l];
1471
- }), r.services = {
1472
- ...this.services
1473
- }, r.services.utils = {
1474
- hasLoadedNamespace: r.hasLoadedNamespace.bind(r)
1475
- }, n && (r.store = new te(this.store.data, s), r.services.resourceStore = r.store), r.translator = new W(r.services, s), r.translator.on("*", function(l) {
1476
- for (var o = arguments.length, f = new Array(o > 1 ? o - 1 : 0), g = 1; g < o; g++)
1477
- f[g - 1] = arguments[g];
1478
- r.emit(l, ...f);
1479
- }), r.init(s, t), r.translator.options = s, r.translator.backendConnector.services.utils = {
1480
- hasLoadedNamespace: r.hasLoadedNamespace.bind(r)
1481
- }, r;
1482
- }
1483
- toJSON() {
1484
- return {
1485
- options: this.options,
1486
- store: this.store,
1487
- language: this.language,
1488
- languages: this.languages,
1489
- resolvedLanguage: this.resolvedLanguage
1490
- };
1491
- }
1492
- }
1493
- const C = V.createInstance();
1494
- C.createInstance = V.createInstance;
1495
- C.createInstance;
1496
- C.dir;
1497
- C.init;
1498
- C.loadResources;
1499
- C.reloadResources;
1500
- C.use;
1501
- C.changeLanguage;
1502
- C.getFixedT;
1503
- C.t;
1504
- C.exists;
1505
- C.setDefaultNamespace;
1506
- C.hasLoadedNamespace;
1507
- C.loadNamespaces;
1508
- C.loadLanguages;
1509
- var G = {};
1510
- /*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
1511
- var le;
1512
- function ke() {
1513
- return le || (le = 1, function(i) {
1514
- (function(e) {
1515
- e(typeof DO_NOT_EXPORT_CRC > "u" ? i : {});
1516
- })(function(e) {
1517
- e.version = "1.2.2";
1518
- function t() {
1519
- for (var h = 0, N = new Array(256), d = 0; d != 256; ++d)
1520
- h = d, h = h & 1 ? -306674912 ^ h >>> 1 : h >>> 1, h = h & 1 ? -306674912 ^ h >>> 1 : h >>> 1, h = h & 1 ? -306674912 ^ h >>> 1 : h >>> 1, h = h & 1 ? -306674912 ^ h >>> 1 : h >>> 1, h = h & 1 ? -306674912 ^ h >>> 1 : h >>> 1, h = h & 1 ? -306674912 ^ h >>> 1 : h >>> 1, h = h & 1 ? -306674912 ^ h >>> 1 : h >>> 1, h = h & 1 ? -306674912 ^ h >>> 1 : h >>> 1, N[d] = h;
1521
- return typeof Int32Array < "u" ? new Int32Array(N) : N;
1522
- }
1523
- var n = t();
1524
- function s(h) {
1525
- var N = 0, d = 0, y = 0, b = typeof Int32Array < "u" ? new Int32Array(4096) : new Array(4096);
1526
- for (y = 0; y != 256; ++y) b[y] = h[y];
1527
- for (y = 0; y != 256; ++y)
1528
- for (d = h[y], N = 256 + y; N < 4096; N += 256) d = b[N] = d >>> 8 ^ h[d & 255];
1529
- var S = [];
1530
- for (y = 1; y != 16; ++y) S[y - 1] = typeof Int32Array < "u" ? b.subarray(y * 256, y * 256 + 256) : b.slice(y * 256, y * 256 + 256);
1531
- return S;
1532
- }
1533
- var r = s(n), a = r[0], l = r[1], o = r[2], f = r[3], g = r[4], c = r[5], u = r[6], m = r[7], p = r[8], x = r[9], v = r[10], P = r[11], O = r[12], T = r[13], L = r[14];
1534
- function R(h, N) {
1535
- for (var d = N ^ -1, y = 0, b = h.length; y < b; ) d = d >>> 8 ^ n[(d ^ h.charCodeAt(y++)) & 255];
1536
- return ~d;
1537
- }
1538
- function $(h, N) {
1539
- for (var d = N ^ -1, y = h.length - 15, b = 0; b < y; ) d = L[h[b++] ^ d & 255] ^ T[h[b++] ^ d >> 8 & 255] ^ O[h[b++] ^ d >> 16 & 255] ^ P[h[b++] ^ d >>> 24] ^ v[h[b++]] ^ x[h[b++]] ^ p[h[b++]] ^ m[h[b++]] ^ u[h[b++]] ^ c[h[b++]] ^ g[h[b++]] ^ f[h[b++]] ^ o[h[b++]] ^ l[h[b++]] ^ a[h[b++]] ^ n[h[b++]];
1540
- for (y += 15; b < y; ) d = d >>> 8 ^ n[(d ^ h[b++]) & 255];
1541
- return ~d;
1542
- }
1543
- function w(h, N) {
1544
- for (var d = N ^ -1, y = 0, b = h.length, S = 0, j = 0; y < b; )
1545
- S = h.charCodeAt(y++), S < 128 ? d = d >>> 8 ^ n[(d ^ S) & 255] : S < 2048 ? (d = d >>> 8 ^ n[(d ^ (192 | S >> 6 & 31)) & 255], d = d >>> 8 ^ n[(d ^ (128 | S & 63)) & 255]) : S >= 55296 && S < 57344 ? (S = (S & 1023) + 64, j = h.charCodeAt(y++) & 1023, d = d >>> 8 ^ n[(d ^ (240 | S >> 8 & 7)) & 255], d = d >>> 8 ^ n[(d ^ (128 | S >> 2 & 63)) & 255], d = d >>> 8 ^ n[(d ^ (128 | j >> 6 & 15 | (S & 3) << 4)) & 255], d = d >>> 8 ^ n[(d ^ (128 | j & 63)) & 255]) : (d = d >>> 8 ^ n[(d ^ (224 | S >> 12 & 15)) & 255], d = d >>> 8 ^ n[(d ^ (128 | S >> 6 & 63)) & 255], d = d >>> 8 ^ n[(d ^ (128 | S & 63)) & 255]);
1546
- return ~d;
1547
- }
1548
- e.table = n, e.bstr = R, e.buf = $, e.str = w;
1549
- });
1550
- }(G)), G;
1551
- }
1552
- var je = ke();
1553
- export {
1554
- je as c,
1555
- C as i
1556
- };