@hortiview/default-components 1.5.0 → 1.5.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.
- package/dist/components/DefaultAllowedComponent/DefaultAllowedComponent.js +8 -48
- package/dist/components/DefaultFormNumber/DefaultFormNumber.js +12 -1514
- package/dist/components/DefaultFormSelect/DefaultFormSelect.js +9 -178
- package/dist/components/DefaultLoadingSpinner/DefaultLoadingSpinner.js +6 -6
- package/dist/components/GenericTable/GenericTable.js +12 -18746
- package/dist/components/HealthChecks/DataBaseHealthCheck.js +2 -2
- package/dist/components/HealthChecks/DefaultHealthCheck.js +4 -4
- package/dist/components/HealthChecks/IotServiceHealthCheck.js +5 -5
- package/dist/components/HealthChecks/PlatformHealthCheck.js +4 -4
- package/dist/components/ImpatienceLoadingSpinner/ImpatienceLoadingSpinner.js +9 -9
- package/dist/components/InternationalizationWrapper/InternationalizationWrapper.js +4 -4
- package/dist/components/OfflineView/OfflineView.js +9 -9
- package/dist/i18n.js +1696 -5
- package/dist/{i18nInstance-D_96ADqd.js → i18nInstance-CYqpK5II.js} +2 -2
- package/dist/useTranslation-DGtUf8nl.js +101 -0
- package/package.json +3 -3
- package/dist/Iconify-D3gVmKx3.js +0 -84
- package/dist/InfoCard-Ba-VFnki.js +0 -58
- package/dist/LoadingSpinner-CmwCv7BO.js +0 -503
- package/dist/OfflineView-CIwV08EQ-BClnJRzV.js +0 -46
- package/dist/assets/DefaultAllowedComponent.css +0 -1
- package/dist/assets/DefaultFormNumber.css +0 -1
- package/dist/assets/DefaultFormSelect.css +0 -1
- package/dist/assets/GenericTable.css +0 -1
- package/dist/assets/Iconify.css +0 -1
- package/dist/assets/InfoCard.css +0 -1
- package/dist/assets/LoadingSpinner.css +0 -1
- package/dist/assets/OfflineView-CIwV08EQ.css +0 -1
- package/dist/component-Bz_dtX1r-DqCAj-DR.js +0 -304
- package/dist/component-DEJuY56h-CYiwt7Ga.js +0 -571
- package/dist/correct-is-regexp-logic-Y0ToWEjF-pByZFQLo.js +0 -494
- package/dist/i18n-CCQpJsQK.js +0 -1707
- package/dist/index.es--C-VLspF-B3Cy1zrT.js +0 -845
- package/dist/index.es-B74L_Dje-mYAvKwSb.js +0 -2005
- package/dist/index.es-B8p8KCdj--cmqwwUJ.js +0 -360
- package/dist/index.es-BPv5dCFQ-BmH1Hq7_.js +0 -1044
- package/dist/index.es-BanVdXEd-BYOBCuJj.js +0 -79
- package/dist/index.es-SjZ_-d7U-HvaOH_Z0.js +0 -860
- package/dist/index.es-nwjKmW7--CUlbl1RR.js +0 -14375
- package/dist/isTypedArray-DziahYkI-Cw9ssvDH.js +0 -210
- package/dist/slicedToArray-ByMQIs5x-BsvSjTDl.js +0 -432
- package/dist/useHelperText-Cqx6ggnc.js +0 -392
- package/dist/useTranslation-BQQybhSd.js +0 -5042
package/dist/i18n.js
CHANGED
|
@@ -1,7 +1,1698 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./locales/en-US.js";
|
|
3
|
-
import "./locales/es-MX.js";
|
|
4
|
-
import "./locales/tr-TR.js";
|
|
1
|
+
import { AVAILABLE_LOCALES as ke } from "@hortiview/shared-components";
|
|
2
|
+
import $e from "./locales/en-US.js";
|
|
3
|
+
import Re from "./locales/es-MX.js";
|
|
4
|
+
import Pe from "./locales/tr-TR.js";
|
|
5
|
+
import { s as Ne, b as Ee } from "./i18nInstance-CYqpK5II.js";
|
|
6
|
+
const Fe = {
|
|
7
|
+
type: "3rdParty",
|
|
8
|
+
init(r) {
|
|
9
|
+
Ne(r.options.react), Ee(r);
|
|
10
|
+
}
|
|
11
|
+
}, c = (r) => typeof r == "string", H = () => {
|
|
12
|
+
let r, e;
|
|
13
|
+
const t = new Promise((n, s) => {
|
|
14
|
+
r = n, e = s;
|
|
15
|
+
});
|
|
16
|
+
return t.resolve = r, t.reject = e, t;
|
|
17
|
+
}, ie = (r) => r == null ? "" : "" + r, De = (r, e, t) => {
|
|
18
|
+
r.forEach((n) => {
|
|
19
|
+
e[n] && (t[n] = e[n]);
|
|
20
|
+
});
|
|
21
|
+
}, Ae = /###/g, re = (r) => r && r.indexOf("###") > -1 ? r.replace(Ae, ".") : r, ae = (r) => !r || c(r), z = (r, e, t) => {
|
|
22
|
+
const n = c(e) ? e.split(".") : e;
|
|
23
|
+
let s = 0;
|
|
24
|
+
for (; s < n.length - 1; ) {
|
|
25
|
+
if (ae(r)) return {};
|
|
26
|
+
const i = re(n[s]);
|
|
27
|
+
!r[i] && t && (r[i] = new t()), Object.prototype.hasOwnProperty.call(r, i) ? r = r[i] : r = {}, ++s;
|
|
28
|
+
}
|
|
29
|
+
return ae(r) ? {} : {
|
|
30
|
+
obj: r,
|
|
31
|
+
k: re(n[s])
|
|
32
|
+
};
|
|
33
|
+
}, oe = (r, e, t) => {
|
|
34
|
+
const {
|
|
35
|
+
obj: n,
|
|
36
|
+
k: s
|
|
37
|
+
} = z(r, e, Object);
|
|
38
|
+
if (n !== void 0 || e.length === 1) {
|
|
39
|
+
n[s] = t;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let i = e[e.length - 1], a = e.slice(0, e.length - 1), l = z(r, a, Object);
|
|
43
|
+
for (; l.obj === void 0 && a.length; )
|
|
44
|
+
i = `${a[a.length - 1]}.${i}`, a = a.slice(0, a.length - 1), l = z(r, a, Object), l != null && l.obj && typeof l.obj[`${l.k}.${i}`] < "u" && (l.obj = void 0);
|
|
45
|
+
l.obj[`${l.k}.${i}`] = t;
|
|
46
|
+
}, Ie = (r, e, t, n) => {
|
|
47
|
+
const {
|
|
48
|
+
obj: s,
|
|
49
|
+
k: i
|
|
50
|
+
} = z(r, e, Object);
|
|
51
|
+
s[i] = s[i] || [], s[i].push(t);
|
|
52
|
+
}, Q = (r, e) => {
|
|
53
|
+
const {
|
|
54
|
+
obj: t,
|
|
55
|
+
k: n
|
|
56
|
+
} = z(r, e);
|
|
57
|
+
if (t && Object.prototype.hasOwnProperty.call(t, n))
|
|
58
|
+
return t[n];
|
|
59
|
+
}, je = (r, e, t) => {
|
|
60
|
+
const n = Q(r, t);
|
|
61
|
+
return n !== void 0 ? n : Q(e, t);
|
|
62
|
+
}, we = (r, e, t) => {
|
|
63
|
+
for (const n in e)
|
|
64
|
+
n !== "__proto__" && n !== "constructor" && (n in r ? c(r[n]) || r[n] instanceof String || c(e[n]) || e[n] instanceof String ? t && (r[n] = e[n]) : we(r[n], e[n], t) : r[n] = e[n]);
|
|
65
|
+
return r;
|
|
66
|
+
}, A = (r) => r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
67
|
+
var Te = {
|
|
68
|
+
"&": "&",
|
|
69
|
+
"<": "<",
|
|
70
|
+
">": ">",
|
|
71
|
+
'"': """,
|
|
72
|
+
"'": "'",
|
|
73
|
+
"/": "/"
|
|
74
|
+
};
|
|
75
|
+
const Ve = (r) => c(r) ? r.replace(/[&<>"'\/]/g, (e) => Te[e]) : r;
|
|
76
|
+
class Ue {
|
|
77
|
+
constructor(e) {
|
|
78
|
+
this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
|
|
79
|
+
}
|
|
80
|
+
getRegExp(e) {
|
|
81
|
+
const t = this.regExpMap.get(e);
|
|
82
|
+
if (t !== void 0)
|
|
83
|
+
return t;
|
|
84
|
+
const n = new RegExp(e);
|
|
85
|
+
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, n), this.regExpQueue.push(e), n;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const Ke = [" ", ",", "?", "!", ";"], Me = new Ue(20), He = (r, e, t) => {
|
|
89
|
+
e = e || "", t = t || "";
|
|
90
|
+
const n = Ke.filter((a) => e.indexOf(a) < 0 && t.indexOf(a) < 0);
|
|
91
|
+
if (n.length === 0) return !0;
|
|
92
|
+
const s = Me.getRegExp(`(${n.map((a) => a === "?" ? "\\?" : a).join("|")})`);
|
|
93
|
+
let i = !s.test(r);
|
|
94
|
+
if (!i) {
|
|
95
|
+
const a = r.indexOf(t);
|
|
96
|
+
a > 0 && !s.test(r.substring(0, a)) && (i = !0);
|
|
97
|
+
}
|
|
98
|
+
return i;
|
|
99
|
+
}, _ = function(r, e) {
|
|
100
|
+
let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
|
|
101
|
+
if (!r) return;
|
|
102
|
+
if (r[e])
|
|
103
|
+
return Object.prototype.hasOwnProperty.call(r, e) ? r[e] : void 0;
|
|
104
|
+
const n = e.split(t);
|
|
105
|
+
let s = r;
|
|
106
|
+
for (let i = 0; i < n.length; ) {
|
|
107
|
+
if (!s || typeof s != "object")
|
|
108
|
+
return;
|
|
109
|
+
let a, l = "";
|
|
110
|
+
for (let o = i; o < n.length; ++o)
|
|
111
|
+
if (o !== i && (l += t), l += n[o], a = s[l], a !== void 0) {
|
|
112
|
+
if (["string", "number", "boolean"].indexOf(typeof a) > -1 && o < n.length - 1)
|
|
113
|
+
continue;
|
|
114
|
+
i += o - i + 1;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
s = a;
|
|
118
|
+
}
|
|
119
|
+
return s;
|
|
120
|
+
}, Y = (r) => r == null ? void 0 : r.replace("_", "-"), ze = {
|
|
121
|
+
type: "logger",
|
|
122
|
+
log(r) {
|
|
123
|
+
this.output("log", r);
|
|
124
|
+
},
|
|
125
|
+
warn(r) {
|
|
126
|
+
this.output("warn", r);
|
|
127
|
+
},
|
|
128
|
+
error(r) {
|
|
129
|
+
this.output("error", r);
|
|
130
|
+
},
|
|
131
|
+
output(r, e) {
|
|
132
|
+
var t, n;
|
|
133
|
+
(n = (t = console == null ? void 0 : console[r]) == null ? void 0 : t.apply) == null || n.call(t, console, e);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
class q {
|
|
137
|
+
constructor(e) {
|
|
138
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
139
|
+
this.init(e, t);
|
|
140
|
+
}
|
|
141
|
+
init(e) {
|
|
142
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
143
|
+
this.prefix = t.prefix || "i18next:", this.logger = e || ze, this.options = t, this.debug = t.debug;
|
|
144
|
+
}
|
|
145
|
+
log() {
|
|
146
|
+
for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
|
|
147
|
+
t[n] = arguments[n];
|
|
148
|
+
return this.forward(t, "log", "", !0);
|
|
149
|
+
}
|
|
150
|
+
warn() {
|
|
151
|
+
for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
|
|
152
|
+
t[n] = arguments[n];
|
|
153
|
+
return this.forward(t, "warn", "", !0);
|
|
154
|
+
}
|
|
155
|
+
error() {
|
|
156
|
+
for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
|
|
157
|
+
t[n] = arguments[n];
|
|
158
|
+
return this.forward(t, "error", "");
|
|
159
|
+
}
|
|
160
|
+
deprecate() {
|
|
161
|
+
for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
|
|
162
|
+
t[n] = arguments[n];
|
|
163
|
+
return this.forward(t, "warn", "WARNING DEPRECATED: ", !0);
|
|
164
|
+
}
|
|
165
|
+
forward(e, t, n, s) {
|
|
166
|
+
return s && !this.debug ? null : (c(e[0]) && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[t](e));
|
|
167
|
+
}
|
|
168
|
+
create(e) {
|
|
169
|
+
return new q(this.logger, {
|
|
170
|
+
prefix: `${this.prefix}:${e}:`,
|
|
171
|
+
...this.options
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
clone(e) {
|
|
175
|
+
return e = e || this.options, e.prefix = e.prefix || this.prefix, new q(this.logger, e);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
var P = new q();
|
|
179
|
+
class Z {
|
|
180
|
+
constructor() {
|
|
181
|
+
this.observers = {};
|
|
182
|
+
}
|
|
183
|
+
on(e, t) {
|
|
184
|
+
return e.split(" ").forEach((n) => {
|
|
185
|
+
this.observers[n] || (this.observers[n] = /* @__PURE__ */ new Map());
|
|
186
|
+
const s = this.observers[n].get(t) || 0;
|
|
187
|
+
this.observers[n].set(t, s + 1);
|
|
188
|
+
}), this;
|
|
189
|
+
}
|
|
190
|
+
off(e, t) {
|
|
191
|
+
if (this.observers[e]) {
|
|
192
|
+
if (!t) {
|
|
193
|
+
delete this.observers[e];
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
this.observers[e].delete(t);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
emit(e) {
|
|
200
|
+
for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), s = 1; s < t; s++)
|
|
201
|
+
n[s - 1] = arguments[s];
|
|
202
|
+
this.observers[e] && Array.from(this.observers[e].entries()).forEach((a) => {
|
|
203
|
+
let [l, o] = a;
|
|
204
|
+
for (let u = 0; u < o; u++)
|
|
205
|
+
l(...n);
|
|
206
|
+
}), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach((a) => {
|
|
207
|
+
let [l, o] = a;
|
|
208
|
+
for (let u = 0; u < o; u++)
|
|
209
|
+
l.apply(l, [e, ...n]);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
class le extends Z {
|
|
214
|
+
constructor(e) {
|
|
215
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
216
|
+
ns: ["translation"],
|
|
217
|
+
defaultNS: "translation"
|
|
218
|
+
};
|
|
219
|
+
super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
|
|
220
|
+
}
|
|
221
|
+
addNamespaces(e) {
|
|
222
|
+
this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
|
|
223
|
+
}
|
|
224
|
+
removeNamespaces(e) {
|
|
225
|
+
const t = this.options.ns.indexOf(e);
|
|
226
|
+
t > -1 && this.options.ns.splice(t, 1);
|
|
227
|
+
}
|
|
228
|
+
getResource(e, t, n) {
|
|
229
|
+
var u, d;
|
|
230
|
+
let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
231
|
+
const i = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, a = s.ignoreJSONStructure !== void 0 ? s.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
232
|
+
let l;
|
|
233
|
+
e.indexOf(".") > -1 ? l = e.split(".") : (l = [e, t], n && (Array.isArray(n) ? l.push(...n) : c(n) && i ? l.push(...n.split(i)) : l.push(n)));
|
|
234
|
+
const o = Q(this.data, l);
|
|
235
|
+
return !o && !t && !n && e.indexOf(".") > -1 && (e = l[0], t = l[1], n = l.slice(2).join(".")), o || !a || !c(n) ? o : _((d = (u = this.data) == null ? void 0 : u[e]) == null ? void 0 : d[t], n, i);
|
|
236
|
+
}
|
|
237
|
+
addResource(e, t, n, s) {
|
|
238
|
+
let i = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
|
|
239
|
+
silent: !1
|
|
240
|
+
};
|
|
241
|
+
const a = i.keySeparator !== void 0 ? i.keySeparator : this.options.keySeparator;
|
|
242
|
+
let l = [e, t];
|
|
243
|
+
n && (l = l.concat(a ? n.split(a) : n)), e.indexOf(".") > -1 && (l = e.split("."), s = t, t = l[1]), this.addNamespaces(t), oe(this.data, l, s), i.silent || this.emit("added", e, t, n, s);
|
|
244
|
+
}
|
|
245
|
+
addResources(e, t, n) {
|
|
246
|
+
let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
|
|
247
|
+
silent: !1
|
|
248
|
+
};
|
|
249
|
+
for (const i in n)
|
|
250
|
+
(c(n[i]) || Array.isArray(n[i])) && this.addResource(e, t, i, n[i], {
|
|
251
|
+
silent: !0
|
|
252
|
+
});
|
|
253
|
+
s.silent || this.emit("added", e, t, n);
|
|
254
|
+
}
|
|
255
|
+
addResourceBundle(e, t, n, s, i) {
|
|
256
|
+
let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
|
|
257
|
+
silent: !1,
|
|
258
|
+
skipCopy: !1
|
|
259
|
+
}, l = [e, t];
|
|
260
|
+
e.indexOf(".") > -1 && (l = e.split("."), s = n, n = t, t = l[1]), this.addNamespaces(t);
|
|
261
|
+
let o = Q(this.data, l) || {};
|
|
262
|
+
a.skipCopy || (n = JSON.parse(JSON.stringify(n))), s ? we(o, n, i) : o = {
|
|
263
|
+
...o,
|
|
264
|
+
...n
|
|
265
|
+
}, oe(this.data, l, o), a.silent || this.emit("added", e, t, n);
|
|
266
|
+
}
|
|
267
|
+
removeResourceBundle(e, t) {
|
|
268
|
+
this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
|
|
269
|
+
}
|
|
270
|
+
hasResourceBundle(e, t) {
|
|
271
|
+
return this.getResource(e, t) !== void 0;
|
|
272
|
+
}
|
|
273
|
+
getResourceBundle(e, t) {
|
|
274
|
+
return t || (t = this.options.defaultNS), this.getResource(e, t);
|
|
275
|
+
}
|
|
276
|
+
getDataByLanguage(e) {
|
|
277
|
+
return this.data[e];
|
|
278
|
+
}
|
|
279
|
+
hasLanguageSomeTranslations(e) {
|
|
280
|
+
const t = this.getDataByLanguage(e);
|
|
281
|
+
return !!(t && Object.keys(t) || []).find((s) => t[s] && Object.keys(t[s]).length > 0);
|
|
282
|
+
}
|
|
283
|
+
toJSON() {
|
|
284
|
+
return this.data;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
var Le = {
|
|
288
|
+
processors: {},
|
|
289
|
+
addPostProcessor(r) {
|
|
290
|
+
this.processors[r.name] = r;
|
|
291
|
+
},
|
|
292
|
+
handle(r, e, t, n, s) {
|
|
293
|
+
return r.forEach((i) => {
|
|
294
|
+
var a;
|
|
295
|
+
e = ((a = this.processors[i]) == null ? void 0 : a.process(e, t, n, s)) ?? e;
|
|
296
|
+
}), e;
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
const ue = {}, fe = (r) => !c(r) && typeof r != "boolean" && typeof r != "number";
|
|
300
|
+
class G extends Z {
|
|
301
|
+
constructor(e) {
|
|
302
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
303
|
+
super(), De(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = P.create("translator");
|
|
304
|
+
}
|
|
305
|
+
changeLanguage(e) {
|
|
306
|
+
e && (this.language = e);
|
|
307
|
+
}
|
|
308
|
+
exists(e) {
|
|
309
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
310
|
+
interpolation: {}
|
|
311
|
+
};
|
|
312
|
+
if (e == null)
|
|
313
|
+
return !1;
|
|
314
|
+
const n = this.resolve(e, t);
|
|
315
|
+
return (n == null ? void 0 : n.res) !== void 0;
|
|
316
|
+
}
|
|
317
|
+
extractFromKey(e, t) {
|
|
318
|
+
let n = t.nsSeparator !== void 0 ? t.nsSeparator : this.options.nsSeparator;
|
|
319
|
+
n === void 0 && (n = ":");
|
|
320
|
+
const s = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
|
|
321
|
+
let i = t.ns || this.options.defaultNS || [];
|
|
322
|
+
const a = n && e.indexOf(n) > -1, l = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !He(e, n, s);
|
|
323
|
+
if (a && !l) {
|
|
324
|
+
const o = e.match(this.interpolator.nestingRegexp);
|
|
325
|
+
if (o && o.length > 0)
|
|
326
|
+
return {
|
|
327
|
+
key: e,
|
|
328
|
+
namespaces: c(i) ? [i] : i
|
|
329
|
+
};
|
|
330
|
+
const u = e.split(n);
|
|
331
|
+
(n !== s || n === s && this.options.ns.indexOf(u[0]) > -1) && (i = u.shift()), e = u.join(s);
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
key: e,
|
|
335
|
+
namespaces: c(i) ? [i] : i
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
translate(e, t, n) {
|
|
339
|
+
if (typeof t != "object" && this.options.overloadTranslationOptionHandler && (t = this.options.overloadTranslationOptionHandler(arguments)), typeof t == "object" && (t = {
|
|
340
|
+
...t
|
|
341
|
+
}), t || (t = {}), e == null) return "";
|
|
342
|
+
Array.isArray(e) || (e = [String(e)]);
|
|
343
|
+
const s = t.returnDetails !== void 0 ? t.returnDetails : this.options.returnDetails, i = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator, {
|
|
344
|
+
key: a,
|
|
345
|
+
namespaces: l
|
|
346
|
+
} = this.extractFromKey(e[e.length - 1], t), o = l[l.length - 1], u = t.lng || this.language, d = t.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
347
|
+
if ((u == null ? void 0 : u.toLowerCase()) === "cimode") {
|
|
348
|
+
if (d) {
|
|
349
|
+
const O = t.nsSeparator || this.options.nsSeparator;
|
|
350
|
+
return s ? {
|
|
351
|
+
res: `${o}${O}${a}`,
|
|
352
|
+
usedKey: a,
|
|
353
|
+
exactUsedKey: a,
|
|
354
|
+
usedLng: u,
|
|
355
|
+
usedNS: o,
|
|
356
|
+
usedParams: this.getUsedParamsDetails(t)
|
|
357
|
+
} : `${o}${O}${a}`;
|
|
358
|
+
}
|
|
359
|
+
return s ? {
|
|
360
|
+
res: a,
|
|
361
|
+
usedKey: a,
|
|
362
|
+
exactUsedKey: a,
|
|
363
|
+
usedLng: u,
|
|
364
|
+
usedNS: o,
|
|
365
|
+
usedParams: this.getUsedParamsDetails(t)
|
|
366
|
+
} : a;
|
|
367
|
+
}
|
|
368
|
+
const h = this.resolve(e, t);
|
|
369
|
+
let f = h == null ? void 0 : h.res;
|
|
370
|
+
const m = (h == null ? void 0 : h.usedKey) || a, g = (h == null ? void 0 : h.exactUsedKey) || a, p = ["[object Number]", "[object Function]", "[object RegExp]"], x = t.joinArrays !== void 0 ? t.joinArrays : this.options.joinArrays, b = !this.i18nFormat || this.i18nFormat.handleAsObject, w = t.count !== void 0 && !c(t.count), $ = G.hasDefaultValue(t), C = w ? this.pluralResolver.getSuffix(u, t.count, t) : "", V = t.ordinal && w ? this.pluralResolver.getSuffix(u, t.count, {
|
|
371
|
+
ordinal: !1
|
|
372
|
+
}) : "", U = w && !t.ordinal && t.count === 0, y = U && t[`defaultValue${this.options.pluralSeparator}zero`] || t[`defaultValue${C}`] || t[`defaultValue${V}`] || t.defaultValue;
|
|
373
|
+
let L = f;
|
|
374
|
+
b && !f && $ && (L = y);
|
|
375
|
+
const F = fe(L), D = Object.prototype.toString.apply(L);
|
|
376
|
+
if (b && L && F && p.indexOf(D) < 0 && !(c(x) && Array.isArray(L))) {
|
|
377
|
+
if (!t.returnObjects && !this.options.returnObjects) {
|
|
378
|
+
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
379
|
+
const O = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(m, L, {
|
|
380
|
+
...t,
|
|
381
|
+
ns: l
|
|
382
|
+
}) : `key '${a} (${this.language})' returned an object instead of string.`;
|
|
383
|
+
return s ? (h.res = O, h.usedParams = this.getUsedParamsDetails(t), h) : O;
|
|
384
|
+
}
|
|
385
|
+
if (i) {
|
|
386
|
+
const O = Array.isArray(L), k = O ? [] : {}, ee = O ? g : m;
|
|
387
|
+
for (const R in L)
|
|
388
|
+
if (Object.prototype.hasOwnProperty.call(L, R)) {
|
|
389
|
+
const N = `${ee}${i}${R}`;
|
|
390
|
+
$ && !f ? k[R] = this.translate(N, {
|
|
391
|
+
...t,
|
|
392
|
+
defaultValue: fe(y) ? y[R] : void 0,
|
|
393
|
+
joinArrays: !1,
|
|
394
|
+
ns: l
|
|
395
|
+
}) : k[R] = this.translate(N, {
|
|
396
|
+
...t,
|
|
397
|
+
joinArrays: !1,
|
|
398
|
+
ns: l
|
|
399
|
+
}), k[R] === N && (k[R] = L[R]);
|
|
400
|
+
}
|
|
401
|
+
f = k;
|
|
402
|
+
}
|
|
403
|
+
} else if (b && c(x) && Array.isArray(f))
|
|
404
|
+
f = f.join(x), f && (f = this.extendTranslation(f, e, t, n));
|
|
405
|
+
else {
|
|
406
|
+
let O = !1, k = !1;
|
|
407
|
+
!this.isValidLookup(f) && $ && (O = !0, f = y), this.isValidLookup(f) || (k = !0, f = a);
|
|
408
|
+
const R = (t.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && k ? void 0 : f, N = $ && y !== f && this.options.updateMissing;
|
|
409
|
+
if (k || O || N) {
|
|
410
|
+
if (this.logger.log(N ? "updateKey" : "missingKey", u, o, a, N ? y : f), i) {
|
|
411
|
+
const v = this.resolve(a, {
|
|
412
|
+
...t,
|
|
413
|
+
keySeparator: !1
|
|
414
|
+
});
|
|
415
|
+
v && v.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.");
|
|
416
|
+
}
|
|
417
|
+
let K = [];
|
|
418
|
+
const J = this.languageUtils.getFallbackCodes(this.options.fallbackLng, t.lng || this.language);
|
|
419
|
+
if (this.options.saveMissingTo === "fallback" && J && J[0])
|
|
420
|
+
for (let v = 0; v < J.length; v++)
|
|
421
|
+
K.push(J[v]);
|
|
422
|
+
else this.options.saveMissingTo === "all" ? K = this.languageUtils.toResolveHierarchy(t.lng || this.language) : K.push(t.lng || this.language);
|
|
423
|
+
const te = (v, E, M) => {
|
|
424
|
+
var se;
|
|
425
|
+
const ne = $ && M !== f ? M : R;
|
|
426
|
+
this.options.missingKeyHandler ? this.options.missingKeyHandler(v, o, E, ne, N, t) : (se = this.backendConnector) != null && se.saveMissing && this.backendConnector.saveMissing(v, o, E, ne, N, t), this.emit("missingKey", v, o, E, f);
|
|
427
|
+
};
|
|
428
|
+
this.options.saveMissing && (this.options.saveMissingPlurals && w ? K.forEach((v) => {
|
|
429
|
+
const E = this.pluralResolver.getSuffixes(v, t);
|
|
430
|
+
U && t[`defaultValue${this.options.pluralSeparator}zero`] && E.indexOf(`${this.options.pluralSeparator}zero`) < 0 && E.push(`${this.options.pluralSeparator}zero`), E.forEach((M) => {
|
|
431
|
+
te([v], a + M, t[`defaultValue${M}`] || y);
|
|
432
|
+
});
|
|
433
|
+
}) : te(K, a, y));
|
|
434
|
+
}
|
|
435
|
+
f = this.extendTranslation(f, e, t, h, n), k && f === a && this.options.appendNamespaceToMissingKey && (f = `${o}:${a}`), (k || O) && this.options.parseMissingKeyHandler && (f = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${o}:${a}` : a, O ? f : void 0));
|
|
436
|
+
}
|
|
437
|
+
return s ? (h.res = f, h.usedParams = this.getUsedParamsDetails(t), h) : f;
|
|
438
|
+
}
|
|
439
|
+
extendTranslation(e, t, n, s, i) {
|
|
440
|
+
var u, d;
|
|
441
|
+
var a = this;
|
|
442
|
+
if ((u = this.i18nFormat) != null && u.parse)
|
|
443
|
+
e = this.i18nFormat.parse(e, {
|
|
444
|
+
...this.options.interpolation.defaultVariables,
|
|
445
|
+
...n
|
|
446
|
+
}, n.lng || this.language || s.usedLng, s.usedNS, s.usedKey, {
|
|
447
|
+
resolved: s
|
|
448
|
+
});
|
|
449
|
+
else if (!n.skipInterpolation) {
|
|
450
|
+
n.interpolation && this.interpolator.init({
|
|
451
|
+
...n,
|
|
452
|
+
interpolation: {
|
|
453
|
+
...this.options.interpolation,
|
|
454
|
+
...n.interpolation
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
const h = c(e) && (((d = n == null ? void 0 : n.interpolation) == null ? void 0 : d.skipOnVariables) !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
458
|
+
let f;
|
|
459
|
+
if (h) {
|
|
460
|
+
const g = e.match(this.interpolator.nestingRegexp);
|
|
461
|
+
f = g && g.length;
|
|
462
|
+
}
|
|
463
|
+
let m = n.replace && !c(n.replace) ? n.replace : n;
|
|
464
|
+
if (this.options.interpolation.defaultVariables && (m = {
|
|
465
|
+
...this.options.interpolation.defaultVariables,
|
|
466
|
+
...m
|
|
467
|
+
}), e = this.interpolator.interpolate(e, m, n.lng || this.language || s.usedLng, n), h) {
|
|
468
|
+
const g = e.match(this.interpolator.nestingRegexp), p = g && g.length;
|
|
469
|
+
f < p && (n.nest = !1);
|
|
470
|
+
}
|
|
471
|
+
!n.lng && s && s.res && (n.lng = this.language || s.usedLng), n.nest !== !1 && (e = this.interpolator.nest(e, function() {
|
|
472
|
+
for (var g = arguments.length, p = new Array(g), x = 0; x < g; x++)
|
|
473
|
+
p[x] = arguments[x];
|
|
474
|
+
return (i == null ? void 0 : i[0]) === p[0] && !n.context ? (a.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${t[0]}`), null) : a.translate(...p, t);
|
|
475
|
+
}, n)), n.interpolation && this.interpolator.reset();
|
|
476
|
+
}
|
|
477
|
+
const l = n.postProcess || this.options.postProcess, o = c(l) ? [l] : l;
|
|
478
|
+
return e != null && (o != null && o.length) && n.applyPostProcessor !== !1 && (e = Le.handle(o, e, t, this.options && this.options.postProcessPassResolved ? {
|
|
479
|
+
i18nResolved: {
|
|
480
|
+
...s,
|
|
481
|
+
usedParams: this.getUsedParamsDetails(n)
|
|
482
|
+
},
|
|
483
|
+
...n
|
|
484
|
+
} : n, this)), e;
|
|
485
|
+
}
|
|
486
|
+
resolve(e) {
|
|
487
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n, s, i, a, l;
|
|
488
|
+
return c(e) && (e = [e]), e.forEach((o) => {
|
|
489
|
+
if (this.isValidLookup(n)) return;
|
|
490
|
+
const u = this.extractFromKey(o, t), d = u.key;
|
|
491
|
+
s = d;
|
|
492
|
+
let h = u.namespaces;
|
|
493
|
+
this.options.fallbackNS && (h = h.concat(this.options.fallbackNS));
|
|
494
|
+
const f = t.count !== void 0 && !c(t.count), m = f && !t.ordinal && t.count === 0, g = t.context !== void 0 && (c(t.context) || typeof t.context == "number") && t.context !== "", p = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
|
|
495
|
+
h.forEach((x) => {
|
|
496
|
+
var b, w;
|
|
497
|
+
this.isValidLookup(n) || (l = x, !ue[`${p[0]}-${x}`] && ((b = this.utils) != null && b.hasLoadedNamespace) && !((w = this.utils) != null && w.hasLoadedNamespace(l)) && (ue[`${p[0]}-${x}`] = !0, this.logger.warn(`key "${s}" for languages "${p.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!!!")), p.forEach(($) => {
|
|
498
|
+
var U;
|
|
499
|
+
if (this.isValidLookup(n)) return;
|
|
500
|
+
a = $;
|
|
501
|
+
const C = [d];
|
|
502
|
+
if ((U = this.i18nFormat) != null && U.addLookupKeys)
|
|
503
|
+
this.i18nFormat.addLookupKeys(C, d, $, x, t);
|
|
504
|
+
else {
|
|
505
|
+
let y;
|
|
506
|
+
f && (y = this.pluralResolver.getSuffix($, t.count, t));
|
|
507
|
+
const L = `${this.options.pluralSeparator}zero`, F = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
508
|
+
if (f && (C.push(d + y), t.ordinal && y.indexOf(F) === 0 && C.push(d + y.replace(F, this.options.pluralSeparator)), m && C.push(d + L)), g) {
|
|
509
|
+
const D = `${d}${this.options.contextSeparator}${t.context}`;
|
|
510
|
+
C.push(D), f && (C.push(D + y), t.ordinal && y.indexOf(F) === 0 && C.push(D + y.replace(F, this.options.pluralSeparator)), m && C.push(D + L));
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
let V;
|
|
514
|
+
for (; V = C.pop(); )
|
|
515
|
+
this.isValidLookup(n) || (i = V, n = this.getResource($, x, V, t));
|
|
516
|
+
}));
|
|
517
|
+
});
|
|
518
|
+
}), {
|
|
519
|
+
res: n,
|
|
520
|
+
usedKey: s,
|
|
521
|
+
exactUsedKey: i,
|
|
522
|
+
usedLng: a,
|
|
523
|
+
usedNS: l
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
isValidLookup(e) {
|
|
527
|
+
return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
|
|
528
|
+
}
|
|
529
|
+
getResource(e, t, n) {
|
|
530
|
+
var i;
|
|
531
|
+
let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
532
|
+
return (i = this.i18nFormat) != null && i.getResource ? this.i18nFormat.getResource(e, t, n, s) : this.resourceStore.getResource(e, t, n, s);
|
|
533
|
+
}
|
|
534
|
+
getUsedParamsDetails() {
|
|
535
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
536
|
+
const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], n = e.replace && !c(e.replace);
|
|
537
|
+
let s = n ? e.replace : e;
|
|
538
|
+
if (n && typeof e.count < "u" && (s.count = e.count), this.options.interpolation.defaultVariables && (s = {
|
|
539
|
+
...this.options.interpolation.defaultVariables,
|
|
540
|
+
...s
|
|
541
|
+
}), !n) {
|
|
542
|
+
s = {
|
|
543
|
+
...s
|
|
544
|
+
};
|
|
545
|
+
for (const i of t)
|
|
546
|
+
delete s[i];
|
|
547
|
+
}
|
|
548
|
+
return s;
|
|
549
|
+
}
|
|
550
|
+
static hasDefaultValue(e) {
|
|
551
|
+
const t = "defaultValue";
|
|
552
|
+
for (const n in e)
|
|
553
|
+
if (Object.prototype.hasOwnProperty.call(e, n) && t === n.substring(0, t.length) && e[n] !== void 0)
|
|
554
|
+
return !0;
|
|
555
|
+
return !1;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
class de {
|
|
559
|
+
constructor(e) {
|
|
560
|
+
this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = P.create("languageUtils");
|
|
561
|
+
}
|
|
562
|
+
getScriptPartFromCode(e) {
|
|
563
|
+
if (e = Y(e), !e || e.indexOf("-") < 0) return null;
|
|
564
|
+
const t = e.split("-");
|
|
565
|
+
return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
|
|
566
|
+
}
|
|
567
|
+
getLanguagePartFromCode(e) {
|
|
568
|
+
if (e = Y(e), !e || e.indexOf("-") < 0) return e;
|
|
569
|
+
const t = e.split("-");
|
|
570
|
+
return this.formatLanguageCode(t[0]);
|
|
571
|
+
}
|
|
572
|
+
formatLanguageCode(e) {
|
|
573
|
+
if (c(e) && e.indexOf("-") > -1) {
|
|
574
|
+
let t;
|
|
575
|
+
try {
|
|
576
|
+
t = Intl.getCanonicalLocales(e)[0];
|
|
577
|
+
} catch {
|
|
578
|
+
}
|
|
579
|
+
return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
|
|
580
|
+
}
|
|
581
|
+
return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
|
|
582
|
+
}
|
|
583
|
+
isSupportedCode(e) {
|
|
584
|
+
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
|
|
585
|
+
}
|
|
586
|
+
getBestMatchFromCodes(e) {
|
|
587
|
+
if (!e) return null;
|
|
588
|
+
let t;
|
|
589
|
+
return e.forEach((n) => {
|
|
590
|
+
if (t) return;
|
|
591
|
+
const s = this.formatLanguageCode(n);
|
|
592
|
+
(!this.options.supportedLngs || this.isSupportedCode(s)) && (t = s);
|
|
593
|
+
}), !t && this.options.supportedLngs && e.forEach((n) => {
|
|
594
|
+
if (t) return;
|
|
595
|
+
const s = this.getLanguagePartFromCode(n);
|
|
596
|
+
if (this.isSupportedCode(s)) return t = s;
|
|
597
|
+
t = this.options.supportedLngs.find((i) => {
|
|
598
|
+
if (i === s) return i;
|
|
599
|
+
if (!(i.indexOf("-") < 0 && s.indexOf("-") < 0) && (i.indexOf("-") > 0 && s.indexOf("-") < 0 && i.substring(0, i.indexOf("-")) === s || i.indexOf(s) === 0 && s.length > 1))
|
|
600
|
+
return i;
|
|
601
|
+
});
|
|
602
|
+
}), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
|
|
603
|
+
}
|
|
604
|
+
getFallbackCodes(e, t) {
|
|
605
|
+
if (!e) return [];
|
|
606
|
+
if (typeof e == "function" && (e = e(t)), c(e) && (e = [e]), Array.isArray(e)) return e;
|
|
607
|
+
if (!t) return e.default || [];
|
|
608
|
+
let n = e[t];
|
|
609
|
+
return n || (n = e[this.getScriptPartFromCode(t)]), n || (n = e[this.formatLanguageCode(t)]), n || (n = e[this.getLanguagePartFromCode(t)]), n || (n = e.default), n || [];
|
|
610
|
+
}
|
|
611
|
+
toResolveHierarchy(e, t) {
|
|
612
|
+
const n = this.getFallbackCodes(t || this.options.fallbackLng || [], e), s = [], i = (a) => {
|
|
613
|
+
a && (this.isSupportedCode(a) ? s.push(a) : this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`));
|
|
614
|
+
};
|
|
615
|
+
return c(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && i(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && i(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && i(this.getLanguagePartFromCode(e))) : c(e) && i(this.formatLanguageCode(e)), n.forEach((a) => {
|
|
616
|
+
s.indexOf(a) < 0 && i(this.formatLanguageCode(a));
|
|
617
|
+
}), s;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const he = {
|
|
621
|
+
zero: 0,
|
|
622
|
+
one: 1,
|
|
623
|
+
two: 2,
|
|
624
|
+
few: 3,
|
|
625
|
+
many: 4,
|
|
626
|
+
other: 5
|
|
627
|
+
}, ge = {
|
|
628
|
+
select: (r) => r === 1 ? "one" : "other",
|
|
629
|
+
resolvedOptions: () => ({
|
|
630
|
+
pluralCategories: ["one", "other"]
|
|
631
|
+
})
|
|
632
|
+
};
|
|
633
|
+
class Be {
|
|
634
|
+
constructor(e) {
|
|
635
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
636
|
+
this.languageUtils = e, this.options = t, this.logger = P.create("pluralResolver"), this.pluralRulesCache = {};
|
|
637
|
+
}
|
|
638
|
+
addRule(e, t) {
|
|
639
|
+
this.rules[e] = t;
|
|
640
|
+
}
|
|
641
|
+
clearCache() {
|
|
642
|
+
this.pluralRulesCache = {};
|
|
643
|
+
}
|
|
644
|
+
getRule(e) {
|
|
645
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
646
|
+
const n = Y(e === "dev" ? "en" : e), s = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({
|
|
647
|
+
cleanedCode: n,
|
|
648
|
+
type: s
|
|
649
|
+
});
|
|
650
|
+
if (i in this.pluralRulesCache)
|
|
651
|
+
return this.pluralRulesCache[i];
|
|
652
|
+
let a;
|
|
653
|
+
try {
|
|
654
|
+
a = new Intl.PluralRules(n, {
|
|
655
|
+
type: s
|
|
656
|
+
});
|
|
657
|
+
} catch {
|
|
658
|
+
if (!Intl)
|
|
659
|
+
return this.logger.error("No Intl support, please use an Intl polyfill!"), ge;
|
|
660
|
+
if (!e.match(/-|_/)) return ge;
|
|
661
|
+
const o = this.languageUtils.getLanguagePartFromCode(e);
|
|
662
|
+
a = this.getRule(o, t);
|
|
663
|
+
}
|
|
664
|
+
return this.pluralRulesCache[i] = a, a;
|
|
665
|
+
}
|
|
666
|
+
needsPlural(e) {
|
|
667
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = this.getRule(e, t);
|
|
668
|
+
return n || (n = this.getRule("dev", t)), (n == null ? void 0 : n.resolvedOptions().pluralCategories.length) > 1;
|
|
669
|
+
}
|
|
670
|
+
getPluralFormsOfKey(e, t) {
|
|
671
|
+
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
672
|
+
return this.getSuffixes(e, n).map((s) => `${t}${s}`);
|
|
673
|
+
}
|
|
674
|
+
getSuffixes(e) {
|
|
675
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = this.getRule(e, t);
|
|
676
|
+
return n || (n = this.getRule("dev", t)), n ? n.resolvedOptions().pluralCategories.sort((s, i) => he[s] - he[i]).map((s) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${s}`) : [];
|
|
677
|
+
}
|
|
678
|
+
getSuffix(e, t) {
|
|
679
|
+
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
680
|
+
const s = this.getRule(e, n);
|
|
681
|
+
return s ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${s.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, n));
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
const ce = function(r, e, t) {
|
|
685
|
+
let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".", s = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, i = je(r, e, t);
|
|
686
|
+
return !i && s && c(t) && (i = _(r, t, n), i === void 0 && (i = _(e, t, n))), i;
|
|
687
|
+
}, X = (r) => r.replace(/\$/g, "$$$$");
|
|
688
|
+
class Je {
|
|
689
|
+
constructor() {
|
|
690
|
+
var t;
|
|
691
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
692
|
+
this.logger = P.create("interpolator"), this.options = e, this.format = ((t = e == null ? void 0 : e.interpolation) == null ? void 0 : t.format) || ((n) => n), this.init(e);
|
|
693
|
+
}
|
|
694
|
+
init() {
|
|
695
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
696
|
+
e.interpolation || (e.interpolation = {
|
|
697
|
+
escapeValue: !0
|
|
698
|
+
});
|
|
699
|
+
const {
|
|
700
|
+
escape: t,
|
|
701
|
+
escapeValue: n,
|
|
702
|
+
useRawValueToEscape: s,
|
|
703
|
+
prefix: i,
|
|
704
|
+
prefixEscaped: a,
|
|
705
|
+
suffix: l,
|
|
706
|
+
suffixEscaped: o,
|
|
707
|
+
formatSeparator: u,
|
|
708
|
+
unescapeSuffix: d,
|
|
709
|
+
unescapePrefix: h,
|
|
710
|
+
nestingPrefix: f,
|
|
711
|
+
nestingPrefixEscaped: m,
|
|
712
|
+
nestingSuffix: g,
|
|
713
|
+
nestingSuffixEscaped: p,
|
|
714
|
+
nestingOptionsSeparator: x,
|
|
715
|
+
maxReplaces: b,
|
|
716
|
+
alwaysFormat: w
|
|
717
|
+
} = e.interpolation;
|
|
718
|
+
this.escape = t !== void 0 ? t : Ve, this.escapeValue = n !== void 0 ? n : !0, this.useRawValueToEscape = s !== void 0 ? s : !1, this.prefix = i ? A(i) : a || "{{", this.suffix = l ? A(l) : o || "}}", this.formatSeparator = u || ",", this.unescapePrefix = d ? "" : h || "-", this.unescapeSuffix = this.unescapePrefix ? "" : d || "", this.nestingPrefix = f ? A(f) : m || A("$t("), this.nestingSuffix = g ? A(g) : p || A(")"), this.nestingOptionsSeparator = x || ",", this.maxReplaces = b || 1e3, this.alwaysFormat = w !== void 0 ? w : !1, this.resetRegExp();
|
|
719
|
+
}
|
|
720
|
+
reset() {
|
|
721
|
+
this.options && this.init(this.options);
|
|
722
|
+
}
|
|
723
|
+
resetRegExp() {
|
|
724
|
+
const e = (t, n) => (t == null ? void 0 : t.source) === n ? (t.lastIndex = 0, t) : new RegExp(n, "g");
|
|
725
|
+
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}`);
|
|
726
|
+
}
|
|
727
|
+
interpolate(e, t, n, s) {
|
|
728
|
+
var m;
|
|
729
|
+
let i, a, l;
|
|
730
|
+
const o = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (g) => {
|
|
731
|
+
if (g.indexOf(this.formatSeparator) < 0) {
|
|
732
|
+
const w = ce(t, o, g, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
733
|
+
return this.alwaysFormat ? this.format(w, void 0, n, {
|
|
734
|
+
...s,
|
|
735
|
+
...t,
|
|
736
|
+
interpolationkey: g
|
|
737
|
+
}) : w;
|
|
738
|
+
}
|
|
739
|
+
const p = g.split(this.formatSeparator), x = p.shift().trim(), b = p.join(this.formatSeparator).trim();
|
|
740
|
+
return this.format(ce(t, o, x, this.options.keySeparator, this.options.ignoreJSONStructure), b, n, {
|
|
741
|
+
...s,
|
|
742
|
+
...t,
|
|
743
|
+
interpolationkey: x
|
|
744
|
+
});
|
|
745
|
+
};
|
|
746
|
+
this.resetRegExp();
|
|
747
|
+
const d = (s == null ? void 0 : s.missingInterpolationHandler) || this.options.missingInterpolationHandler, h = ((m = s == null ? void 0 : s.interpolation) == null ? void 0 : m.skipOnVariables) !== void 0 ? s.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
748
|
+
return [{
|
|
749
|
+
regex: this.regexpUnescape,
|
|
750
|
+
safeValue: (g) => X(g)
|
|
751
|
+
}, {
|
|
752
|
+
regex: this.regexp,
|
|
753
|
+
safeValue: (g) => this.escapeValue ? X(this.escape(g)) : X(g)
|
|
754
|
+
}].forEach((g) => {
|
|
755
|
+
for (l = 0; i = g.regex.exec(e); ) {
|
|
756
|
+
const p = i[1].trim();
|
|
757
|
+
if (a = u(p), a === void 0)
|
|
758
|
+
if (typeof d == "function") {
|
|
759
|
+
const b = d(e, i, s);
|
|
760
|
+
a = c(b) ? b : "";
|
|
761
|
+
} else if (s && Object.prototype.hasOwnProperty.call(s, p))
|
|
762
|
+
a = "";
|
|
763
|
+
else if (h) {
|
|
764
|
+
a = i[0];
|
|
765
|
+
continue;
|
|
766
|
+
} else
|
|
767
|
+
this.logger.warn(`missed to pass in variable ${p} for interpolating ${e}`), a = "";
|
|
768
|
+
else !c(a) && !this.useRawValueToEscape && (a = ie(a));
|
|
769
|
+
const x = g.safeValue(a);
|
|
770
|
+
if (e = e.replace(i[0], x), h ? (g.regex.lastIndex += a.length, g.regex.lastIndex -= i[0].length) : g.regex.lastIndex = 0, l++, l >= this.maxReplaces)
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
}), e;
|
|
774
|
+
}
|
|
775
|
+
nest(e, t) {
|
|
776
|
+
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, s, i, a;
|
|
777
|
+
const l = (o, u) => {
|
|
778
|
+
const d = this.nestingOptionsSeparator;
|
|
779
|
+
if (o.indexOf(d) < 0) return o;
|
|
780
|
+
const h = o.split(new RegExp(`${d}[ ]*{`));
|
|
781
|
+
let f = `{${h[1]}`;
|
|
782
|
+
o = h[0], f = this.interpolate(f, a);
|
|
783
|
+
const m = f.match(/'/g), g = f.match(/"/g);
|
|
784
|
+
(((m == null ? void 0 : m.length) ?? 0) % 2 === 0 && !g || g.length % 2 !== 0) && (f = f.replace(/'/g, '"'));
|
|
785
|
+
try {
|
|
786
|
+
a = JSON.parse(f), u && (a = {
|
|
787
|
+
...u,
|
|
788
|
+
...a
|
|
789
|
+
});
|
|
790
|
+
} catch (p) {
|
|
791
|
+
return this.logger.warn(`failed parsing options string in nesting for key ${o}`, p), `${o}${d}${f}`;
|
|
792
|
+
}
|
|
793
|
+
return a.defaultValue && a.defaultValue.indexOf(this.prefix) > -1 && delete a.defaultValue, o;
|
|
794
|
+
};
|
|
795
|
+
for (; s = this.nestingRegexp.exec(e); ) {
|
|
796
|
+
let o = [];
|
|
797
|
+
a = {
|
|
798
|
+
...n
|
|
799
|
+
}, a = a.replace && !c(a.replace) ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue;
|
|
800
|
+
let u = !1;
|
|
801
|
+
if (s[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(s[1])) {
|
|
802
|
+
const d = s[1].split(this.formatSeparator).map((h) => h.trim());
|
|
803
|
+
s[1] = d.shift(), o = d, u = !0;
|
|
804
|
+
}
|
|
805
|
+
if (i = t(l.call(this, s[1].trim(), a), a), i && s[0] === e && !c(i)) return i;
|
|
806
|
+
c(i) || (i = ie(i)), i || (this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`), i = ""), u && (i = o.reduce((d, h) => this.format(d, h, n.lng, {
|
|
807
|
+
...n,
|
|
808
|
+
interpolationkey: s[1].trim()
|
|
809
|
+
}), i.trim())), e = e.replace(s[0], i), this.regexp.lastIndex = 0;
|
|
810
|
+
}
|
|
811
|
+
return e;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
const We = (r) => {
|
|
815
|
+
let e = r.toLowerCase().trim();
|
|
816
|
+
const t = {};
|
|
817
|
+
if (r.indexOf("(") > -1) {
|
|
818
|
+
const n = r.split("(");
|
|
819
|
+
e = n[0].toLowerCase().trim();
|
|
820
|
+
const s = n[1].substring(0, n[1].length - 1);
|
|
821
|
+
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) => {
|
|
822
|
+
if (a) {
|
|
823
|
+
const [l, ...o] = a.split(":"), u = o.join(":").trim().replace(/^'+|'+$/g, ""), d = l.trim();
|
|
824
|
+
t[d] || (t[d] = u), u === "false" && (t[d] = !1), u === "true" && (t[d] = !0), isNaN(u) || (t[d] = parseInt(u, 10));
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
return {
|
|
829
|
+
formatName: e,
|
|
830
|
+
formatOptions: t
|
|
831
|
+
};
|
|
832
|
+
}, I = (r) => {
|
|
833
|
+
const e = {};
|
|
834
|
+
return (t, n, s) => {
|
|
835
|
+
let i = s;
|
|
836
|
+
s && s.interpolationkey && s.formatParams && s.formatParams[s.interpolationkey] && s[s.interpolationkey] && (i = {
|
|
837
|
+
...i,
|
|
838
|
+
[s.interpolationkey]: void 0
|
|
839
|
+
});
|
|
840
|
+
const a = n + JSON.stringify(i);
|
|
841
|
+
let l = e[a];
|
|
842
|
+
return l || (l = r(Y(n), s), e[a] = l), l(t);
|
|
843
|
+
};
|
|
844
|
+
};
|
|
845
|
+
class Qe {
|
|
846
|
+
constructor() {
|
|
847
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
848
|
+
this.logger = P.create("formatter"), this.options = e, this.formats = {
|
|
849
|
+
number: I((t, n) => {
|
|
850
|
+
const s = new Intl.NumberFormat(t, {
|
|
851
|
+
...n
|
|
852
|
+
});
|
|
853
|
+
return (i) => s.format(i);
|
|
854
|
+
}),
|
|
855
|
+
currency: I((t, n) => {
|
|
856
|
+
const s = new Intl.NumberFormat(t, {
|
|
857
|
+
...n,
|
|
858
|
+
style: "currency"
|
|
859
|
+
});
|
|
860
|
+
return (i) => s.format(i);
|
|
861
|
+
}),
|
|
862
|
+
datetime: I((t, n) => {
|
|
863
|
+
const s = new Intl.DateTimeFormat(t, {
|
|
864
|
+
...n
|
|
865
|
+
});
|
|
866
|
+
return (i) => s.format(i);
|
|
867
|
+
}),
|
|
868
|
+
relativetime: I((t, n) => {
|
|
869
|
+
const s = new Intl.RelativeTimeFormat(t, {
|
|
870
|
+
...n
|
|
871
|
+
});
|
|
872
|
+
return (i) => s.format(i, n.range || "day");
|
|
873
|
+
}),
|
|
874
|
+
list: I((t, n) => {
|
|
875
|
+
const s = new Intl.ListFormat(t, {
|
|
876
|
+
...n
|
|
877
|
+
});
|
|
878
|
+
return (i) => s.format(i);
|
|
879
|
+
})
|
|
880
|
+
}, this.init(e);
|
|
881
|
+
}
|
|
882
|
+
init(e) {
|
|
883
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
884
|
+
interpolation: {}
|
|
885
|
+
};
|
|
886
|
+
this.formatSeparator = t.interpolation.formatSeparator || ",";
|
|
887
|
+
}
|
|
888
|
+
add(e, t) {
|
|
889
|
+
this.formats[e.toLowerCase().trim()] = t;
|
|
890
|
+
}
|
|
891
|
+
addCached(e, t) {
|
|
892
|
+
this.formats[e.toLowerCase().trim()] = I(t);
|
|
893
|
+
}
|
|
894
|
+
format(e, t, n) {
|
|
895
|
+
let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
896
|
+
const i = t.split(this.formatSeparator);
|
|
897
|
+
if (i.length > 1 && i[0].indexOf("(") > 1 && i[0].indexOf(")") < 0 && i.find((l) => l.indexOf(")") > -1)) {
|
|
898
|
+
const l = i.findIndex((o) => o.indexOf(")") > -1);
|
|
899
|
+
i[0] = [i[0], ...i.splice(1, l)].join(this.formatSeparator);
|
|
900
|
+
}
|
|
901
|
+
return i.reduce((l, o) => {
|
|
902
|
+
var h;
|
|
903
|
+
const {
|
|
904
|
+
formatName: u,
|
|
905
|
+
formatOptions: d
|
|
906
|
+
} = We(o);
|
|
907
|
+
if (this.formats[u]) {
|
|
908
|
+
let f = l;
|
|
909
|
+
try {
|
|
910
|
+
const m = ((h = s == null ? void 0 : s.formatParams) == null ? void 0 : h[s.interpolationkey]) || {}, g = m.locale || m.lng || s.locale || s.lng || n;
|
|
911
|
+
f = this.formats[u](l, g, {
|
|
912
|
+
...d,
|
|
913
|
+
...s,
|
|
914
|
+
...m
|
|
915
|
+
});
|
|
916
|
+
} catch (m) {
|
|
917
|
+
this.logger.warn(m);
|
|
918
|
+
}
|
|
919
|
+
return f;
|
|
920
|
+
} else
|
|
921
|
+
this.logger.warn(`there was no format function for ${u}`);
|
|
922
|
+
return l;
|
|
923
|
+
}, e);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
const Ye = (r, e) => {
|
|
927
|
+
r.pending[e] !== void 0 && (delete r.pending[e], r.pendingCount--);
|
|
928
|
+
};
|
|
929
|
+
class qe extends Z {
|
|
930
|
+
constructor(e, t, n) {
|
|
931
|
+
var i, a;
|
|
932
|
+
let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
933
|
+
super(), this.backend = e, this.store = t, this.services = n, this.languageUtils = n.languageUtils, this.options = s, this.logger = P.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 = [], (a = (i = this.backend) == null ? void 0 : i.init) == null || a.call(i, n, s.backend, s);
|
|
934
|
+
}
|
|
935
|
+
queueLoad(e, t, n, s) {
|
|
936
|
+
const i = {}, a = {}, l = {}, o = {};
|
|
937
|
+
return e.forEach((u) => {
|
|
938
|
+
let d = !0;
|
|
939
|
+
t.forEach((h) => {
|
|
940
|
+
const f = `${u}|${h}`;
|
|
941
|
+
!n.reload && this.store.hasResourceBundle(u, h) ? this.state[f] = 2 : this.state[f] < 0 || (this.state[f] === 1 ? a[f] === void 0 && (a[f] = !0) : (this.state[f] = 1, d = !1, a[f] === void 0 && (a[f] = !0), i[f] === void 0 && (i[f] = !0), o[h] === void 0 && (o[h] = !0)));
|
|
942
|
+
}), d || (l[u] = !0);
|
|
943
|
+
}), (Object.keys(i).length || Object.keys(a).length) && this.queue.push({
|
|
944
|
+
pending: a,
|
|
945
|
+
pendingCount: Object.keys(a).length,
|
|
946
|
+
loaded: {},
|
|
947
|
+
errors: [],
|
|
948
|
+
callback: s
|
|
949
|
+
}), {
|
|
950
|
+
toLoad: Object.keys(i),
|
|
951
|
+
pending: Object.keys(a),
|
|
952
|
+
toLoadLanguages: Object.keys(l),
|
|
953
|
+
toLoadNamespaces: Object.keys(o)
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
loaded(e, t, n) {
|
|
957
|
+
const s = e.split("|"), i = s[0], a = s[1];
|
|
958
|
+
t && this.emit("failedLoading", i, a, t), !t && n && this.store.addResourceBundle(i, a, n, void 0, void 0, {
|
|
959
|
+
skipCopy: !0
|
|
960
|
+
}), this.state[e] = t ? -1 : 2, t && n && (this.state[e] = 0);
|
|
961
|
+
const l = {};
|
|
962
|
+
this.queue.forEach((o) => {
|
|
963
|
+
Ie(o.loaded, [i], a), Ye(o, e), t && o.errors.push(t), o.pendingCount === 0 && !o.done && (Object.keys(o.loaded).forEach((u) => {
|
|
964
|
+
l[u] || (l[u] = {});
|
|
965
|
+
const d = o.loaded[u];
|
|
966
|
+
d.length && d.forEach((h) => {
|
|
967
|
+
l[u][h] === void 0 && (l[u][h] = !0);
|
|
968
|
+
});
|
|
969
|
+
}), o.done = !0, o.errors.length ? o.callback(o.errors) : o.callback());
|
|
970
|
+
}), this.emit("loaded", l), this.queue = this.queue.filter((o) => !o.done);
|
|
971
|
+
}
|
|
972
|
+
read(e, t, n) {
|
|
973
|
+
let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0, i = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout, a = arguments.length > 5 ? arguments[5] : void 0;
|
|
974
|
+
if (!e.length) return a(null, {});
|
|
975
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
|
976
|
+
this.waitingReads.push({
|
|
977
|
+
lng: e,
|
|
978
|
+
ns: t,
|
|
979
|
+
fcName: n,
|
|
980
|
+
tried: s,
|
|
981
|
+
wait: i,
|
|
982
|
+
callback: a
|
|
983
|
+
});
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
this.readingCalls++;
|
|
987
|
+
const l = (u, d) => {
|
|
988
|
+
if (this.readingCalls--, this.waitingReads.length > 0) {
|
|
989
|
+
const h = this.waitingReads.shift();
|
|
990
|
+
this.read(h.lng, h.ns, h.fcName, h.tried, h.wait, h.callback);
|
|
991
|
+
}
|
|
992
|
+
if (u && d && s < this.maxRetries) {
|
|
993
|
+
setTimeout(() => {
|
|
994
|
+
this.read.call(this, e, t, n, s + 1, i * 2, a);
|
|
995
|
+
}, i);
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
a(u, d);
|
|
999
|
+
}, o = this.backend[n].bind(this.backend);
|
|
1000
|
+
if (o.length === 2) {
|
|
1001
|
+
try {
|
|
1002
|
+
const u = o(e, t);
|
|
1003
|
+
u && typeof u.then == "function" ? u.then((d) => l(null, d)).catch(l) : l(null, u);
|
|
1004
|
+
} catch (u) {
|
|
1005
|
+
l(u);
|
|
1006
|
+
}
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
return o(e, t, l);
|
|
1010
|
+
}
|
|
1011
|
+
prepareLoading(e, t) {
|
|
1012
|
+
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, s = arguments.length > 3 ? arguments[3] : void 0;
|
|
1013
|
+
if (!this.backend)
|
|
1014
|
+
return this.logger.warn("No backend was added via i18next.use. Will not load resources."), s && s();
|
|
1015
|
+
c(e) && (e = this.languageUtils.toResolveHierarchy(e)), c(t) && (t = [t]);
|
|
1016
|
+
const i = this.queueLoad(e, t, n, s);
|
|
1017
|
+
if (!i.toLoad.length)
|
|
1018
|
+
return i.pending.length || s(), null;
|
|
1019
|
+
i.toLoad.forEach((a) => {
|
|
1020
|
+
this.loadOne(a);
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
load(e, t, n) {
|
|
1024
|
+
this.prepareLoading(e, t, {}, n);
|
|
1025
|
+
}
|
|
1026
|
+
reload(e, t, n) {
|
|
1027
|
+
this.prepareLoading(e, t, {
|
|
1028
|
+
reload: !0
|
|
1029
|
+
}, n);
|
|
1030
|
+
}
|
|
1031
|
+
loadOne(e) {
|
|
1032
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
1033
|
+
const n = e.split("|"), s = n[0], i = n[1];
|
|
1034
|
+
this.read(s, i, "read", void 0, void 0, (a, l) => {
|
|
1035
|
+
a && this.logger.warn(`${t}loading namespace ${i} for language ${s} failed`, a), !a && l && this.logger.log(`${t}loaded namespace ${i} for language ${s}`, l), this.loaded(e, a, l);
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
saveMissing(e, t, n, s, i) {
|
|
1039
|
+
var o, u, d, h, f;
|
|
1040
|
+
let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {}, l = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
|
|
1041
|
+
};
|
|
1042
|
+
if ((u = (o = this.services) == null ? void 0 : o.utils) != null && u.hasLoadedNamespace && !((h = (d = this.services) == null ? void 0 : d.utils) != null && h.hasLoadedNamespace(t))) {
|
|
1043
|
+
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!!!");
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
if (!(n == null || n === "")) {
|
|
1047
|
+
if ((f = this.backend) != null && f.create) {
|
|
1048
|
+
const m = {
|
|
1049
|
+
...a,
|
|
1050
|
+
isUpdate: i
|
|
1051
|
+
}, g = this.backend.create.bind(this.backend);
|
|
1052
|
+
if (g.length < 6)
|
|
1053
|
+
try {
|
|
1054
|
+
let p;
|
|
1055
|
+
g.length === 5 ? p = g(e, t, n, s, m) : p = g(e, t, n, s), p && typeof p.then == "function" ? p.then((x) => l(null, x)).catch(l) : l(null, p);
|
|
1056
|
+
} catch (p) {
|
|
1057
|
+
l(p);
|
|
1058
|
+
}
|
|
1059
|
+
else
|
|
1060
|
+
g(e, t, n, s, l, m);
|
|
1061
|
+
}
|
|
1062
|
+
!e || !e[0] || this.store.addResource(e[0], t, n, s);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
const pe = () => ({
|
|
1067
|
+
debug: !1,
|
|
1068
|
+
initAsync: !0,
|
|
1069
|
+
ns: ["translation"],
|
|
1070
|
+
defaultNS: ["translation"],
|
|
1071
|
+
fallbackLng: ["dev"],
|
|
1072
|
+
fallbackNS: !1,
|
|
1073
|
+
supportedLngs: !1,
|
|
1074
|
+
nonExplicitSupportedLngs: !1,
|
|
1075
|
+
load: "all",
|
|
1076
|
+
preload: !1,
|
|
1077
|
+
simplifyPluralSuffix: !0,
|
|
1078
|
+
keySeparator: ".",
|
|
1079
|
+
nsSeparator: ":",
|
|
1080
|
+
pluralSeparator: "_",
|
|
1081
|
+
contextSeparator: "_",
|
|
1082
|
+
partialBundledLanguages: !1,
|
|
1083
|
+
saveMissing: !1,
|
|
1084
|
+
updateMissing: !1,
|
|
1085
|
+
saveMissingTo: "fallback",
|
|
1086
|
+
saveMissingPlurals: !0,
|
|
1087
|
+
missingKeyHandler: !1,
|
|
1088
|
+
missingInterpolationHandler: !1,
|
|
1089
|
+
postProcess: !1,
|
|
1090
|
+
postProcessPassResolved: !1,
|
|
1091
|
+
returnNull: !1,
|
|
1092
|
+
returnEmptyString: !0,
|
|
1093
|
+
returnObjects: !1,
|
|
1094
|
+
joinArrays: !1,
|
|
1095
|
+
returnedObjectHandler: !1,
|
|
1096
|
+
parseMissingKeyHandler: !1,
|
|
1097
|
+
appendNamespaceToMissingKey: !1,
|
|
1098
|
+
appendNamespaceToCIMode: !1,
|
|
1099
|
+
overloadTranslationOptionHandler: (r) => {
|
|
1100
|
+
let e = {};
|
|
1101
|
+
if (typeof r[1] == "object" && (e = r[1]), c(r[1]) && (e.defaultValue = r[1]), c(r[2]) && (e.tDescription = r[2]), typeof r[2] == "object" || typeof r[3] == "object") {
|
|
1102
|
+
const t = r[3] || r[2];
|
|
1103
|
+
Object.keys(t).forEach((n) => {
|
|
1104
|
+
e[n] = t[n];
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
return e;
|
|
1108
|
+
},
|
|
1109
|
+
interpolation: {
|
|
1110
|
+
escapeValue: !0,
|
|
1111
|
+
format: (r) => r,
|
|
1112
|
+
prefix: "{{",
|
|
1113
|
+
suffix: "}}",
|
|
1114
|
+
formatSeparator: ",",
|
|
1115
|
+
unescapePrefix: "-",
|
|
1116
|
+
nestingPrefix: "$t(",
|
|
1117
|
+
nestingSuffix: ")",
|
|
1118
|
+
nestingOptionsSeparator: ",",
|
|
1119
|
+
maxReplaces: 1e3,
|
|
1120
|
+
skipOnVariables: !0
|
|
1121
|
+
}
|
|
1122
|
+
}), me = (r) => {
|
|
1123
|
+
var e, t;
|
|
1124
|
+
return c(r.ns) && (r.ns = [r.ns]), c(r.fallbackLng) && (r.fallbackLng = [r.fallbackLng]), c(r.fallbackNS) && (r.fallbackNS = [r.fallbackNS]), ((t = (e = r.supportedLngs) == null ? void 0 : e.indexOf) == null ? void 0 : t.call(e, "cimode")) < 0 && (r.supportedLngs = r.supportedLngs.concat(["cimode"])), typeof r.initImmediate == "boolean" && (r.initAsync = r.initImmediate), r;
|
|
1125
|
+
}, W = () => {
|
|
1126
|
+
}, Ge = (r) => {
|
|
1127
|
+
Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach((t) => {
|
|
1128
|
+
typeof r[t] == "function" && (r[t] = r[t].bind(r));
|
|
1129
|
+
});
|
|
1130
|
+
};
|
|
1131
|
+
class B extends Z {
|
|
1132
|
+
constructor() {
|
|
1133
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 ? arguments[1] : void 0;
|
|
1134
|
+
if (super(), this.options = me(e), this.services = {}, this.logger = P, this.modules = {
|
|
1135
|
+
external: []
|
|
1136
|
+
}, Ge(this), t && !this.isInitialized && !e.isClone) {
|
|
1137
|
+
if (!this.options.initAsync)
|
|
1138
|
+
return this.init(e, t), this;
|
|
1139
|
+
setTimeout(() => {
|
|
1140
|
+
this.init(e, t);
|
|
1141
|
+
}, 0);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
init() {
|
|
1145
|
+
var e = this;
|
|
1146
|
+
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = arguments.length > 1 ? arguments[1] : void 0;
|
|
1147
|
+
this.isInitializing = !0, typeof t == "function" && (n = t, t = {}), t.defaultNS == null && t.ns && (c(t.ns) ? t.defaultNS = t.ns : t.ns.indexOf("translation") < 0 && (t.defaultNS = t.ns[0]));
|
|
1148
|
+
const s = pe();
|
|
1149
|
+
this.options = {
|
|
1150
|
+
...s,
|
|
1151
|
+
...this.options,
|
|
1152
|
+
...me(t)
|
|
1153
|
+
}, this.options.interpolation = {
|
|
1154
|
+
...s.interpolation,
|
|
1155
|
+
...this.options.interpolation
|
|
1156
|
+
}, t.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = t.keySeparator), t.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = t.nsSeparator);
|
|
1157
|
+
const i = (d) => d ? typeof d == "function" ? new d() : d : null;
|
|
1158
|
+
if (!this.options.isClone) {
|
|
1159
|
+
this.modules.logger ? P.init(i(this.modules.logger), this.options) : P.init(null, this.options);
|
|
1160
|
+
let d;
|
|
1161
|
+
this.modules.formatter ? d = this.modules.formatter : d = Qe;
|
|
1162
|
+
const h = new de(this.options);
|
|
1163
|
+
this.store = new le(this.options.resources, this.options);
|
|
1164
|
+
const f = this.services;
|
|
1165
|
+
f.logger = P, f.resourceStore = this.store, f.languageUtils = h, f.pluralResolver = new Be(h, {
|
|
1166
|
+
prepend: this.options.pluralSeparator,
|
|
1167
|
+
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1168
|
+
}), d && (!this.options.interpolation.format || this.options.interpolation.format === s.interpolation.format) && (f.formatter = i(d), f.formatter.init(f, this.options), this.options.interpolation.format = f.formatter.format.bind(f.formatter)), f.interpolator = new Je(this.options), f.utils = {
|
|
1169
|
+
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
1170
|
+
}, f.backendConnector = new qe(i(this.modules.backend), f.resourceStore, f, this.options), f.backendConnector.on("*", function(m) {
|
|
1171
|
+
for (var g = arguments.length, p = new Array(g > 1 ? g - 1 : 0), x = 1; x < g; x++)
|
|
1172
|
+
p[x - 1] = arguments[x];
|
|
1173
|
+
e.emit(m, ...p);
|
|
1174
|
+
}), this.modules.languageDetector && (f.languageDetector = i(this.modules.languageDetector), f.languageDetector.init && f.languageDetector.init(f, this.options.detection, this.options)), this.modules.i18nFormat && (f.i18nFormat = i(this.modules.i18nFormat), f.i18nFormat.init && f.i18nFormat.init(this)), this.translator = new G(this.services, this.options), this.translator.on("*", function(m) {
|
|
1175
|
+
for (var g = arguments.length, p = new Array(g > 1 ? g - 1 : 0), x = 1; x < g; x++)
|
|
1176
|
+
p[x - 1] = arguments[x];
|
|
1177
|
+
e.emit(m, ...p);
|
|
1178
|
+
}), this.modules.external.forEach((m) => {
|
|
1179
|
+
m.init && m.init(this);
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
if (this.format = this.options.interpolation.format, n || (n = W), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
1183
|
+
const d = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
1184
|
+
d.length > 0 && d[0] !== "dev" && (this.options.lng = d[0]);
|
|
1185
|
+
}
|
|
1186
|
+
!this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((d) => {
|
|
1187
|
+
this[d] = function() {
|
|
1188
|
+
return e.store[d](...arguments);
|
|
1189
|
+
};
|
|
1190
|
+
}), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((d) => {
|
|
1191
|
+
this[d] = function() {
|
|
1192
|
+
return e.store[d](...arguments), e;
|
|
1193
|
+
};
|
|
1194
|
+
});
|
|
1195
|
+
const o = H(), u = () => {
|
|
1196
|
+
const d = (h, f) => {
|
|
1197
|
+
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(f), n(h, f);
|
|
1198
|
+
};
|
|
1199
|
+
if (this.languages && !this.isInitialized) return d(null, this.t.bind(this));
|
|
1200
|
+
this.changeLanguage(this.options.lng, d);
|
|
1201
|
+
};
|
|
1202
|
+
return this.options.resources || !this.options.initAsync ? u() : setTimeout(u, 0), o;
|
|
1203
|
+
}
|
|
1204
|
+
loadResources(e) {
|
|
1205
|
+
var i, a;
|
|
1206
|
+
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : W;
|
|
1207
|
+
const s = c(e) ? e : this.language;
|
|
1208
|
+
if (typeof e == "function" && (n = e), !this.options.resources || this.options.partialBundledLanguages) {
|
|
1209
|
+
if ((s == null ? void 0 : s.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return n();
|
|
1210
|
+
const l = [], o = (u) => {
|
|
1211
|
+
if (!u || u === "cimode") return;
|
|
1212
|
+
this.services.languageUtils.toResolveHierarchy(u).forEach((h) => {
|
|
1213
|
+
h !== "cimode" && l.indexOf(h) < 0 && l.push(h);
|
|
1214
|
+
});
|
|
1215
|
+
};
|
|
1216
|
+
s ? o(s) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((d) => o(d)), (a = (i = this.options.preload) == null ? void 0 : i.forEach) == null || a.call(i, (u) => o(u)), this.services.backendConnector.load(l, this.options.ns, (u) => {
|
|
1217
|
+
!u && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), n(u);
|
|
1218
|
+
});
|
|
1219
|
+
} else
|
|
1220
|
+
n(null);
|
|
1221
|
+
}
|
|
1222
|
+
reloadResources(e, t, n) {
|
|
1223
|
+
const s = H();
|
|
1224
|
+
return typeof e == "function" && (n = e, e = void 0), typeof t == "function" && (n = t, t = void 0), e || (e = this.languages), t || (t = this.options.ns), n || (n = W), this.services.backendConnector.reload(e, t, (i) => {
|
|
1225
|
+
s.resolve(), n(i);
|
|
1226
|
+
}), s;
|
|
1227
|
+
}
|
|
1228
|
+
use(e) {
|
|
1229
|
+
if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
|
|
1230
|
+
if (!e.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
|
|
1231
|
+
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" && Le.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
|
|
1232
|
+
}
|
|
1233
|
+
setResolvedLanguage(e) {
|
|
1234
|
+
if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1))
|
|
1235
|
+
for (let t = 0; t < this.languages.length; t++) {
|
|
1236
|
+
const n = this.languages[t];
|
|
1237
|
+
if (!(["cimode", "dev"].indexOf(n) > -1) && this.store.hasLanguageSomeTranslations(n)) {
|
|
1238
|
+
this.resolvedLanguage = n;
|
|
1239
|
+
break;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
changeLanguage(e, t) {
|
|
1244
|
+
var n = this;
|
|
1245
|
+
this.isLanguageChangingTo = e;
|
|
1246
|
+
const s = H();
|
|
1247
|
+
this.emit("languageChanging", e);
|
|
1248
|
+
const i = (o) => {
|
|
1249
|
+
this.language = o, this.languages = this.services.languageUtils.toResolveHierarchy(o), this.resolvedLanguage = void 0, this.setResolvedLanguage(o);
|
|
1250
|
+
}, a = (o, u) => {
|
|
1251
|
+
u ? (i(u), this.translator.changeLanguage(u), this.isLanguageChangingTo = void 0, this.emit("languageChanged", u), this.logger.log("languageChanged", u)) : this.isLanguageChangingTo = void 0, s.resolve(function() {
|
|
1252
|
+
return n.t(...arguments);
|
|
1253
|
+
}), t && t(o, function() {
|
|
1254
|
+
return n.t(...arguments);
|
|
1255
|
+
});
|
|
1256
|
+
}, l = (o) => {
|
|
1257
|
+
var d, h;
|
|
1258
|
+
!e && !o && this.services.languageDetector && (o = []);
|
|
1259
|
+
const u = c(o) ? o : this.services.languageUtils.getBestMatchFromCodes(o);
|
|
1260
|
+
u && (this.language || i(u), this.translator.language || this.translator.changeLanguage(u), (h = (d = this.services.languageDetector) == null ? void 0 : d.cacheUserLanguage) == null || h.call(d, u)), this.loadResources(u, (f) => {
|
|
1261
|
+
a(f, u);
|
|
1262
|
+
});
|
|
1263
|
+
};
|
|
1264
|
+
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;
|
|
1265
|
+
}
|
|
1266
|
+
getFixedT(e, t, n) {
|
|
1267
|
+
var s = this;
|
|
1268
|
+
const i = function(a, l) {
|
|
1269
|
+
let o;
|
|
1270
|
+
if (typeof l != "object") {
|
|
1271
|
+
for (var u = arguments.length, d = new Array(u > 2 ? u - 2 : 0), h = 2; h < u; h++)
|
|
1272
|
+
d[h - 2] = arguments[h];
|
|
1273
|
+
o = s.options.overloadTranslationOptionHandler([a, l].concat(d));
|
|
1274
|
+
} else
|
|
1275
|
+
o = {
|
|
1276
|
+
...l
|
|
1277
|
+
};
|
|
1278
|
+
o.lng = o.lng || i.lng, o.lngs = o.lngs || i.lngs, o.ns = o.ns || i.ns, o.keyPrefix !== "" && (o.keyPrefix = o.keyPrefix || n || i.keyPrefix);
|
|
1279
|
+
const f = s.options.keySeparator || ".";
|
|
1280
|
+
let m;
|
|
1281
|
+
return o.keyPrefix && Array.isArray(a) ? m = a.map((g) => `${o.keyPrefix}${f}${g}`) : m = o.keyPrefix ? `${o.keyPrefix}${f}${a}` : a, s.t(m, o);
|
|
1282
|
+
};
|
|
1283
|
+
return c(e) ? i.lng = e : i.lngs = e, i.ns = t, i.keyPrefix = n, i;
|
|
1284
|
+
}
|
|
1285
|
+
t() {
|
|
1286
|
+
var s;
|
|
1287
|
+
for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
|
|
1288
|
+
t[n] = arguments[n];
|
|
1289
|
+
return (s = this.translator) == null ? void 0 : s.translate(...t);
|
|
1290
|
+
}
|
|
1291
|
+
exists() {
|
|
1292
|
+
var s;
|
|
1293
|
+
for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
|
|
1294
|
+
t[n] = arguments[n];
|
|
1295
|
+
return (s = this.translator) == null ? void 0 : s.exists(...t);
|
|
1296
|
+
}
|
|
1297
|
+
setDefaultNamespace(e) {
|
|
1298
|
+
this.options.defaultNS = e;
|
|
1299
|
+
}
|
|
1300
|
+
hasLoadedNamespace(e) {
|
|
1301
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1302
|
+
if (!this.isInitialized)
|
|
1303
|
+
return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
|
|
1304
|
+
if (!this.languages || !this.languages.length)
|
|
1305
|
+
return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
|
|
1306
|
+
const n = t.lng || this.resolvedLanguage || this.languages[0], s = this.options ? this.options.fallbackLng : !1, i = this.languages[this.languages.length - 1];
|
|
1307
|
+
if (n.toLowerCase() === "cimode") return !0;
|
|
1308
|
+
const a = (l, o) => {
|
|
1309
|
+
const u = this.services.backendConnector.state[`${l}|${o}`];
|
|
1310
|
+
return u === -1 || u === 0 || u === 2;
|
|
1311
|
+
};
|
|
1312
|
+
if (t.precheck) {
|
|
1313
|
+
const l = t.precheck(this, a);
|
|
1314
|
+
if (l !== void 0) return l;
|
|
1315
|
+
}
|
|
1316
|
+
return !!(this.hasResourceBundle(n, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(n, e) && (!s || a(i, e)));
|
|
1317
|
+
}
|
|
1318
|
+
loadNamespaces(e, t) {
|
|
1319
|
+
const n = H();
|
|
1320
|
+
return this.options.ns ? (c(e) && (e = [e]), e.forEach((s) => {
|
|
1321
|
+
this.options.ns.indexOf(s) < 0 && this.options.ns.push(s);
|
|
1322
|
+
}), this.loadResources((s) => {
|
|
1323
|
+
n.resolve(), t && t(s);
|
|
1324
|
+
}), n) : (t && t(), Promise.resolve());
|
|
1325
|
+
}
|
|
1326
|
+
loadLanguages(e, t) {
|
|
1327
|
+
const n = H();
|
|
1328
|
+
c(e) && (e = [e]);
|
|
1329
|
+
const s = this.options.preload || [], i = e.filter((a) => s.indexOf(a) < 0 && this.services.languageUtils.isSupportedCode(a));
|
|
1330
|
+
return i.length ? (this.options.preload = s.concat(i), this.loadResources((a) => {
|
|
1331
|
+
n.resolve(), t && t(a);
|
|
1332
|
+
}), n) : (t && t(), Promise.resolve());
|
|
1333
|
+
}
|
|
1334
|
+
dir(e) {
|
|
1335
|
+
var s, i;
|
|
1336
|
+
if (e || (e = this.resolvedLanguage || (((s = this.languages) == null ? void 0 : s.length) > 0 ? this.languages[0] : this.language)), !e) return "rtl";
|
|
1337
|
+
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 = ((i = this.services) == null ? void 0 : i.languageUtils) || new de(pe());
|
|
1338
|
+
return t.indexOf(n.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
1339
|
+
}
|
|
1340
|
+
static createInstance() {
|
|
1341
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 ? arguments[1] : void 0;
|
|
1342
|
+
return new B(e, t);
|
|
1343
|
+
}
|
|
1344
|
+
cloneInstance() {
|
|
1345
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : W;
|
|
1346
|
+
const n = e.forkResourceStore;
|
|
1347
|
+
n && delete e.forkResourceStore;
|
|
1348
|
+
const s = {
|
|
1349
|
+
...this.options,
|
|
1350
|
+
...e,
|
|
1351
|
+
isClone: !0
|
|
1352
|
+
}, i = new B(s);
|
|
1353
|
+
if ((e.debug !== void 0 || e.prefix !== void 0) && (i.logger = i.logger.clone(e)), ["store", "services", "language"].forEach((l) => {
|
|
1354
|
+
i[l] = this[l];
|
|
1355
|
+
}), i.services = {
|
|
1356
|
+
...this.services
|
|
1357
|
+
}, i.services.utils = {
|
|
1358
|
+
hasLoadedNamespace: i.hasLoadedNamespace.bind(i)
|
|
1359
|
+
}, n) {
|
|
1360
|
+
const l = Object.keys(this.store.data).reduce((o, u) => (o[u] = {
|
|
1361
|
+
...this.store.data[u]
|
|
1362
|
+
}, Object.keys(o[u]).reduce((d, h) => (d[h] = {
|
|
1363
|
+
...o[u][h]
|
|
1364
|
+
}, d), {})), {});
|
|
1365
|
+
i.store = new le(l, s), i.services.resourceStore = i.store;
|
|
1366
|
+
}
|
|
1367
|
+
return i.translator = new G(i.services, s), i.translator.on("*", function(l) {
|
|
1368
|
+
for (var o = arguments.length, u = new Array(o > 1 ? o - 1 : 0), d = 1; d < o; d++)
|
|
1369
|
+
u[d - 1] = arguments[d];
|
|
1370
|
+
i.emit(l, ...u);
|
|
1371
|
+
}), i.init(s, t), i.translator.options = s, i.translator.backendConnector.services.utils = {
|
|
1372
|
+
hasLoadedNamespace: i.hasLoadedNamespace.bind(i)
|
|
1373
|
+
}, i;
|
|
1374
|
+
}
|
|
1375
|
+
toJSON() {
|
|
1376
|
+
return {
|
|
1377
|
+
options: this.options,
|
|
1378
|
+
store: this.store,
|
|
1379
|
+
language: this.language,
|
|
1380
|
+
languages: this.languages,
|
|
1381
|
+
resolvedLanguage: this.resolvedLanguage
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
const S = B.createInstance();
|
|
1386
|
+
S.createInstance = B.createInstance;
|
|
1387
|
+
S.createInstance;
|
|
1388
|
+
S.dir;
|
|
1389
|
+
S.init;
|
|
1390
|
+
S.loadResources;
|
|
1391
|
+
S.reloadResources;
|
|
1392
|
+
S.use;
|
|
1393
|
+
S.changeLanguage;
|
|
1394
|
+
S.getFixedT;
|
|
1395
|
+
S.t;
|
|
1396
|
+
S.exists;
|
|
1397
|
+
S.setDefaultNamespace;
|
|
1398
|
+
S.hasLoadedNamespace;
|
|
1399
|
+
S.loadNamespaces;
|
|
1400
|
+
S.loadLanguages;
|
|
1401
|
+
const {
|
|
1402
|
+
slice: Ze,
|
|
1403
|
+
forEach: Xe
|
|
1404
|
+
} = [];
|
|
1405
|
+
function _e(r) {
|
|
1406
|
+
return Xe.call(Ze.call(arguments, 1), (e) => {
|
|
1407
|
+
if (e)
|
|
1408
|
+
for (const t in e)
|
|
1409
|
+
r[t] === void 0 && (r[t] = e[t]);
|
|
1410
|
+
}), r;
|
|
1411
|
+
}
|
|
1412
|
+
const xe = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/, et = function(r, e) {
|
|
1413
|
+
const n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
|
|
1414
|
+
path: "/"
|
|
1415
|
+
}, s = encodeURIComponent(e);
|
|
1416
|
+
let i = `${r}=${s}`;
|
|
1417
|
+
if (n.maxAge > 0) {
|
|
1418
|
+
const a = n.maxAge - 0;
|
|
1419
|
+
if (Number.isNaN(a)) throw new Error("maxAge should be a Number");
|
|
1420
|
+
i += `; Max-Age=${Math.floor(a)}`;
|
|
1421
|
+
}
|
|
1422
|
+
if (n.domain) {
|
|
1423
|
+
if (!xe.test(n.domain))
|
|
1424
|
+
throw new TypeError("option domain is invalid");
|
|
1425
|
+
i += `; Domain=${n.domain}`;
|
|
1426
|
+
}
|
|
1427
|
+
if (n.path) {
|
|
1428
|
+
if (!xe.test(n.path))
|
|
1429
|
+
throw new TypeError("option path is invalid");
|
|
1430
|
+
i += `; Path=${n.path}`;
|
|
1431
|
+
}
|
|
1432
|
+
if (n.expires) {
|
|
1433
|
+
if (typeof n.expires.toUTCString != "function")
|
|
1434
|
+
throw new TypeError("option expires is invalid");
|
|
1435
|
+
i += `; Expires=${n.expires.toUTCString()}`;
|
|
1436
|
+
}
|
|
1437
|
+
if (n.httpOnly && (i += "; HttpOnly"), n.secure && (i += "; Secure"), n.sameSite)
|
|
1438
|
+
switch (typeof n.sameSite == "string" ? n.sameSite.toLowerCase() : n.sameSite) {
|
|
1439
|
+
case !0:
|
|
1440
|
+
i += "; SameSite=Strict";
|
|
1441
|
+
break;
|
|
1442
|
+
case "lax":
|
|
1443
|
+
i += "; SameSite=Lax";
|
|
1444
|
+
break;
|
|
1445
|
+
case "strict":
|
|
1446
|
+
i += "; SameSite=Strict";
|
|
1447
|
+
break;
|
|
1448
|
+
case "none":
|
|
1449
|
+
i += "; SameSite=None";
|
|
1450
|
+
break;
|
|
1451
|
+
default:
|
|
1452
|
+
throw new TypeError("option sameSite is invalid");
|
|
1453
|
+
}
|
|
1454
|
+
return i;
|
|
1455
|
+
}, ye = {
|
|
1456
|
+
create(r, e, t, n) {
|
|
1457
|
+
let s = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
|
|
1458
|
+
path: "/",
|
|
1459
|
+
sameSite: "strict"
|
|
1460
|
+
};
|
|
1461
|
+
t && (s.expires = /* @__PURE__ */ new Date(), s.expires.setTime(s.expires.getTime() + t * 60 * 1e3)), n && (s.domain = n), document.cookie = et(r, encodeURIComponent(e), s);
|
|
1462
|
+
},
|
|
1463
|
+
read(r) {
|
|
1464
|
+
const e = `${r}=`, t = document.cookie.split(";");
|
|
1465
|
+
for (let n = 0; n < t.length; n++) {
|
|
1466
|
+
let s = t[n];
|
|
1467
|
+
for (; s.charAt(0) === " "; ) s = s.substring(1, s.length);
|
|
1468
|
+
if (s.indexOf(e) === 0) return s.substring(e.length, s.length);
|
|
1469
|
+
}
|
|
1470
|
+
return null;
|
|
1471
|
+
},
|
|
1472
|
+
remove(r) {
|
|
1473
|
+
this.create(r, "", -1);
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1476
|
+
var tt = {
|
|
1477
|
+
name: "cookie",
|
|
1478
|
+
// Deconstruct the options object and extract the lookupCookie property
|
|
1479
|
+
lookup(r) {
|
|
1480
|
+
let {
|
|
1481
|
+
lookupCookie: e
|
|
1482
|
+
} = r;
|
|
1483
|
+
if (e && typeof document < "u")
|
|
1484
|
+
return ye.read(e) || void 0;
|
|
1485
|
+
},
|
|
1486
|
+
// Deconstruct the options object and extract the lookupCookie, cookieMinutes, cookieDomain, and cookieOptions properties
|
|
1487
|
+
cacheUserLanguage(r, e) {
|
|
1488
|
+
let {
|
|
1489
|
+
lookupCookie: t,
|
|
1490
|
+
cookieMinutes: n,
|
|
1491
|
+
cookieDomain: s,
|
|
1492
|
+
cookieOptions: i
|
|
1493
|
+
} = e;
|
|
1494
|
+
t && typeof document < "u" && ye.create(t, r, n, s, i);
|
|
1495
|
+
}
|
|
1496
|
+
}, nt = {
|
|
1497
|
+
name: "querystring",
|
|
1498
|
+
// Deconstruct the options object and extract the lookupQuerystring property
|
|
1499
|
+
lookup(r) {
|
|
1500
|
+
var n;
|
|
1501
|
+
let {
|
|
1502
|
+
lookupQuerystring: e
|
|
1503
|
+
} = r, t;
|
|
1504
|
+
if (typeof window < "u") {
|
|
1505
|
+
let {
|
|
1506
|
+
search: s
|
|
1507
|
+
} = window.location;
|
|
1508
|
+
!window.location.search && ((n = window.location.hash) == null ? void 0 : n.indexOf("?")) > -1 && (s = window.location.hash.substring(window.location.hash.indexOf("?")));
|
|
1509
|
+
const a = s.substring(1).split("&");
|
|
1510
|
+
for (let l = 0; l < a.length; l++) {
|
|
1511
|
+
const o = a[l].indexOf("=");
|
|
1512
|
+
o > 0 && a[l].substring(0, o) === e && (t = a[l].substring(o + 1));
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
return t;
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
let j = null;
|
|
1519
|
+
const Se = () => {
|
|
1520
|
+
if (j !== null) return j;
|
|
1521
|
+
try {
|
|
1522
|
+
if (j = typeof window < "u" && window.localStorage !== null, !j)
|
|
1523
|
+
return !1;
|
|
1524
|
+
const r = "i18next.translate.boo";
|
|
1525
|
+
window.localStorage.setItem(r, "foo"), window.localStorage.removeItem(r);
|
|
1526
|
+
} catch {
|
|
1527
|
+
j = !1;
|
|
1528
|
+
}
|
|
1529
|
+
return j;
|
|
1530
|
+
};
|
|
1531
|
+
var st = {
|
|
1532
|
+
name: "localStorage",
|
|
1533
|
+
// Deconstruct the options object and extract the lookupLocalStorage property
|
|
1534
|
+
lookup(r) {
|
|
1535
|
+
let {
|
|
1536
|
+
lookupLocalStorage: e
|
|
1537
|
+
} = r;
|
|
1538
|
+
if (e && Se())
|
|
1539
|
+
return window.localStorage.getItem(e) || void 0;
|
|
1540
|
+
},
|
|
1541
|
+
// Deconstruct the options object and extract the lookupLocalStorage property
|
|
1542
|
+
cacheUserLanguage(r, e) {
|
|
1543
|
+
let {
|
|
1544
|
+
lookupLocalStorage: t
|
|
1545
|
+
} = e;
|
|
1546
|
+
t && Se() && window.localStorage.setItem(t, r);
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
let T = null;
|
|
1550
|
+
const be = () => {
|
|
1551
|
+
if (T !== null) return T;
|
|
1552
|
+
try {
|
|
1553
|
+
if (T = typeof window < "u" && window.sessionStorage !== null, !T)
|
|
1554
|
+
return !1;
|
|
1555
|
+
const r = "i18next.translate.boo";
|
|
1556
|
+
window.sessionStorage.setItem(r, "foo"), window.sessionStorage.removeItem(r);
|
|
1557
|
+
} catch {
|
|
1558
|
+
T = !1;
|
|
1559
|
+
}
|
|
1560
|
+
return T;
|
|
1561
|
+
};
|
|
1562
|
+
var it = {
|
|
1563
|
+
name: "sessionStorage",
|
|
1564
|
+
lookup(r) {
|
|
1565
|
+
let {
|
|
1566
|
+
lookupSessionStorage: e
|
|
1567
|
+
} = r;
|
|
1568
|
+
if (e && be())
|
|
1569
|
+
return window.sessionStorage.getItem(e) || void 0;
|
|
1570
|
+
},
|
|
1571
|
+
cacheUserLanguage(r, e) {
|
|
1572
|
+
let {
|
|
1573
|
+
lookupSessionStorage: t
|
|
1574
|
+
} = e;
|
|
1575
|
+
t && be() && window.sessionStorage.setItem(t, r);
|
|
1576
|
+
}
|
|
1577
|
+
}, rt = {
|
|
1578
|
+
name: "navigator",
|
|
1579
|
+
lookup(r) {
|
|
1580
|
+
const e = [];
|
|
1581
|
+
if (typeof navigator < "u") {
|
|
1582
|
+
const {
|
|
1583
|
+
languages: t,
|
|
1584
|
+
userLanguage: n,
|
|
1585
|
+
language: s
|
|
1586
|
+
} = navigator;
|
|
1587
|
+
if (t)
|
|
1588
|
+
for (let i = 0; i < t.length; i++)
|
|
1589
|
+
e.push(t[i]);
|
|
1590
|
+
n && e.push(n), s && e.push(s);
|
|
1591
|
+
}
|
|
1592
|
+
return e.length > 0 ? e : void 0;
|
|
1593
|
+
}
|
|
1594
|
+
}, at = {
|
|
1595
|
+
name: "htmlTag",
|
|
1596
|
+
// Deconstruct the options object and extract the htmlTag property
|
|
1597
|
+
lookup(r) {
|
|
1598
|
+
let {
|
|
1599
|
+
htmlTag: e
|
|
1600
|
+
} = r, t;
|
|
1601
|
+
const n = e || (typeof document < "u" ? document.documentElement : null);
|
|
1602
|
+
return n && typeof n.getAttribute == "function" && (t = n.getAttribute("lang")), t;
|
|
1603
|
+
}
|
|
1604
|
+
}, ot = {
|
|
1605
|
+
name: "path",
|
|
1606
|
+
// Deconstruct the options object and extract the lookupFromPathIndex property
|
|
1607
|
+
lookup(r) {
|
|
1608
|
+
var s;
|
|
1609
|
+
let {
|
|
1610
|
+
lookupFromPathIndex: e
|
|
1611
|
+
} = r;
|
|
1612
|
+
if (typeof window > "u") return;
|
|
1613
|
+
const t = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
|
|
1614
|
+
return Array.isArray(t) ? (s = t[typeof e == "number" ? e : 0]) == null ? void 0 : s.replace("/", "") : void 0;
|
|
1615
|
+
}
|
|
1616
|
+
}, lt = {
|
|
1617
|
+
name: "subdomain",
|
|
1618
|
+
lookup(r) {
|
|
1619
|
+
var s, i;
|
|
1620
|
+
let {
|
|
1621
|
+
lookupFromSubdomainIndex: e
|
|
1622
|
+
} = r;
|
|
1623
|
+
const t = typeof e == "number" ? e + 1 : 1, n = typeof window < "u" && ((i = (s = window.location) == null ? void 0 : s.hostname) == null ? void 0 : i.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));
|
|
1624
|
+
if (n)
|
|
1625
|
+
return n[t];
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
let Oe = !1;
|
|
1629
|
+
try {
|
|
1630
|
+
document.cookie, Oe = !0;
|
|
1631
|
+
} catch {
|
|
1632
|
+
}
|
|
1633
|
+
const ve = ["querystring", "cookie", "localStorage", "sessionStorage", "navigator", "htmlTag"];
|
|
1634
|
+
Oe || ve.splice(1, 1);
|
|
1635
|
+
const ut = () => ({
|
|
1636
|
+
order: ve,
|
|
1637
|
+
lookupQuerystring: "lng",
|
|
1638
|
+
lookupCookie: "i18next",
|
|
1639
|
+
lookupLocalStorage: "i18nextLng",
|
|
1640
|
+
lookupSessionStorage: "i18nextLng",
|
|
1641
|
+
// cache user language
|
|
1642
|
+
caches: ["localStorage"],
|
|
1643
|
+
excludeCacheFor: ["cimode"],
|
|
1644
|
+
// cookieMinutes: 10,
|
|
1645
|
+
// cookieDomain: 'myDomain'
|
|
1646
|
+
convertDetectedLanguage: (r) => r
|
|
1647
|
+
});
|
|
1648
|
+
class Ce {
|
|
1649
|
+
constructor(e) {
|
|
1650
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1651
|
+
this.type = "languageDetector", this.detectors = {}, this.init(e, t);
|
|
1652
|
+
}
|
|
1653
|
+
init() {
|
|
1654
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
1655
|
+
languageUtils: {}
|
|
1656
|
+
}, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1657
|
+
this.services = e, this.options = _e(t, this.options || {}, ut()), typeof this.options.convertDetectedLanguage == "string" && this.options.convertDetectedLanguage.indexOf("15897") > -1 && (this.options.convertDetectedLanguage = (s) => s.replace("-", "_")), this.options.lookupFromUrlIndex && (this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex), this.i18nOptions = n, this.addDetector(tt), this.addDetector(nt), this.addDetector(st), this.addDetector(it), this.addDetector(rt), this.addDetector(at), this.addDetector(ot), this.addDetector(lt);
|
|
1658
|
+
}
|
|
1659
|
+
addDetector(e) {
|
|
1660
|
+
return this.detectors[e.name] = e, this;
|
|
1661
|
+
}
|
|
1662
|
+
detect() {
|
|
1663
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.options.order, t = [];
|
|
1664
|
+
return e.forEach((n) => {
|
|
1665
|
+
if (this.detectors[n]) {
|
|
1666
|
+
let s = this.detectors[n].lookup(this.options);
|
|
1667
|
+
s && typeof s == "string" && (s = [s]), s && (t = t.concat(s));
|
|
1668
|
+
}
|
|
1669
|
+
}), t = t.map((n) => this.options.convertDetectedLanguage(n)), this.services && this.services.languageUtils && this.services.languageUtils.getBestMatchFromCodes ? t : t.length > 0 ? t[0] : null;
|
|
1670
|
+
}
|
|
1671
|
+
cacheUserLanguage(e) {
|
|
1672
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.options.caches;
|
|
1673
|
+
t && (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(e) > -1 || t.forEach((n) => {
|
|
1674
|
+
this.detectors[n] && this.detectors[n].cacheUserLanguage(e, this.options);
|
|
1675
|
+
}));
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
Ce.type = "languageDetector";
|
|
1679
|
+
const ft = S.createInstance();
|
|
1680
|
+
ft.use(Ce).use(Fe).init({
|
|
1681
|
+
lng: "en",
|
|
1682
|
+
fallbackLng: ke,
|
|
1683
|
+
debug: !0,
|
|
1684
|
+
resources: {
|
|
1685
|
+
en: { translation: $e },
|
|
1686
|
+
es: { translation: Re },
|
|
1687
|
+
tr: { translation: Pe }
|
|
1688
|
+
},
|
|
1689
|
+
returnObjects: !0,
|
|
1690
|
+
returnNull: !1,
|
|
1691
|
+
interpolation: {
|
|
1692
|
+
escapeValue: !1
|
|
1693
|
+
// not needed for react as it escapes by default
|
|
1694
|
+
}
|
|
1695
|
+
});
|
|
5
1696
|
export {
|
|
6
|
-
|
|
1697
|
+
ft as default
|
|
7
1698
|
};
|