@sv-print/plugin-i18n 0.1.5 → 0.1.6
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/index.js +1 -1
- package/dist/index.mjs +217 -216
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var Re = Object.defineProperty, Pe = Object.defineProperties;
|
|
2
|
+
var ke = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var re = Object.getOwnPropertySymbols;
|
|
4
|
+
var Ne = Object.prototype.hasOwnProperty, Fe = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ae = (o, e, t) => e in o ? Re(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, p = (o, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
|
|
7
|
+
Ne.call(e, t) && ae(o, t, e[t]);
|
|
8
|
+
if (re)
|
|
9
|
+
for (var t of re(e))
|
|
10
|
+
Fe.call(e, t) && ae(o, t, e[t]);
|
|
11
11
|
return o;
|
|
12
|
-
}, O = (o, e) =>
|
|
13
|
-
const g = (o) => typeof o == "string",
|
|
12
|
+
}, O = (o, e) => Pe(o, ke(e));
|
|
13
|
+
const g = (o) => typeof o == "string", M = () => {
|
|
14
14
|
let o, e;
|
|
15
15
|
const t = new Promise((i, s) => {
|
|
16
16
|
o = i, e = s;
|
|
17
17
|
});
|
|
18
18
|
return t.resolve = o, t.reject = e, t;
|
|
19
|
-
},
|
|
19
|
+
}, oe = (o) => o == null ? "" : "" + o, je = (o, e, t) => {
|
|
20
20
|
o.forEach((i) => {
|
|
21
21
|
e[i] && (t[i] = e[i]);
|
|
22
22
|
});
|
|
23
|
-
},
|
|
23
|
+
}, Ee = /###/g, le = (o) => o && o.indexOf("###") > -1 ? o.replace(Ee, ".") : o, ue = (o) => !o || g(o), H = (o, e, t) => {
|
|
24
24
|
const i = g(e) ? e.split(".") : e;
|
|
25
25
|
let s = 0;
|
|
26
26
|
for (; s < i.length - 1; ) {
|
|
27
|
-
if (
|
|
28
|
-
const n =
|
|
27
|
+
if (ue(o)) return {};
|
|
28
|
+
const n = le(i[s]);
|
|
29
29
|
!o[n] && t && (o[n] = new t()), Object.prototype.hasOwnProperty.call(o, n) ? o = o[n] : o = {}, ++s;
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return ue(o) ? {} : {
|
|
32
32
|
obj: o,
|
|
33
|
-
k:
|
|
33
|
+
k: le(i[s])
|
|
34
34
|
};
|
|
35
|
-
},
|
|
35
|
+
}, fe = (o, e, t) => {
|
|
36
36
|
const {
|
|
37
37
|
obj: i,
|
|
38
38
|
k: s
|
|
39
|
-
} =
|
|
39
|
+
} = H(o, e, Object);
|
|
40
40
|
if (i !== void 0 || e.length === 1) {
|
|
41
41
|
i[s] = t;
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
let n = e[e.length - 1], r = e.slice(0, e.length - 1), a =
|
|
44
|
+
let n = e[e.length - 1], r = e.slice(0, e.length - 1), a = H(o, r, Object);
|
|
45
45
|
for (; a.obj === void 0 && r.length; )
|
|
46
|
-
n = `${r[r.length - 1]}.${n}`, r = r.slice(0, r.length - 1), a =
|
|
46
|
+
n = `${r[r.length - 1]}.${n}`, r = r.slice(0, r.length - 1), a = H(o, r, Object), a != null && a.obj && typeof a.obj[`${a.k}.${n}`] != "undefined" && (a.obj = void 0);
|
|
47
47
|
a.obj[`${a.k}.${n}`] = t;
|
|
48
|
-
},
|
|
48
|
+
}, Te = (o, e, t, i) => {
|
|
49
49
|
const {
|
|
50
50
|
obj: s,
|
|
51
51
|
k: n
|
|
52
|
-
} =
|
|
52
|
+
} = H(o, e, Object);
|
|
53
53
|
s[n] = s[n] || [], s[n].push(t);
|
|
54
|
-
},
|
|
54
|
+
}, Q = (o, e) => {
|
|
55
55
|
const {
|
|
56
56
|
obj: t,
|
|
57
57
|
k: i
|
|
58
|
-
} =
|
|
58
|
+
} = H(o, e);
|
|
59
59
|
if (t && Object.prototype.hasOwnProperty.call(t, i))
|
|
60
60
|
return t[i];
|
|
61
|
-
},
|
|
62
|
-
const i =
|
|
63
|
-
return i !== void 0 ? i :
|
|
64
|
-
},
|
|
61
|
+
}, Ie = (o, e, t) => {
|
|
62
|
+
const i = Q(o, t);
|
|
63
|
+
return i !== void 0 ? i : Q(e, t);
|
|
64
|
+
}, we = (o, e, t) => {
|
|
65
65
|
for (const i in e)
|
|
66
|
-
i !== "__proto__" && i !== "constructor" && (i in o ? g(o[i]) || o[i] instanceof String || g(e[i]) || e[i] instanceof String ? t && (o[i] = e[i]) :
|
|
66
|
+
i !== "__proto__" && i !== "constructor" && (i in o ? g(o[i]) || o[i] instanceof String || g(e[i]) || e[i] instanceof String ? t && (o[i] = e[i]) : we(o[i], e[i], t) : o[i] = e[i]);
|
|
67
67
|
return o;
|
|
68
|
-
},
|
|
69
|
-
var
|
|
68
|
+
}, V = (o) => o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
69
|
+
var De = {
|
|
70
70
|
"&": "&",
|
|
71
71
|
"<": "<",
|
|
72
72
|
">": ">",
|
|
@@ -74,8 +74,8 @@ var Ie = {
|
|
|
74
74
|
"'": "'",
|
|
75
75
|
"/": "/"
|
|
76
76
|
};
|
|
77
|
-
const
|
|
78
|
-
class
|
|
77
|
+
const Ve = (o) => g(o) ? o.replace(/[&<>"'\/]/g, (e) => De[e]) : o;
|
|
78
|
+
class Ae {
|
|
79
79
|
constructor(e) {
|
|
80
80
|
this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
|
|
81
81
|
}
|
|
@@ -87,18 +87,18 @@ class Ve {
|
|
|
87
87
|
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, i), this.regExpQueue.push(e), i;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
const
|
|
90
|
+
const Ke = [" ", ",", "?", "!", ";"], Ue = new Ae(20), Me = (o, e, t) => {
|
|
91
91
|
e = e || "", t = t || "";
|
|
92
|
-
const i =
|
|
92
|
+
const i = Ke.filter((r) => e.indexOf(r) < 0 && t.indexOf(r) < 0);
|
|
93
93
|
if (i.length === 0) return !0;
|
|
94
|
-
const s =
|
|
94
|
+
const s = Ue.getRegExp(`(${i.map((r) => r === "?" ? "\\?" : r).join("|")})`);
|
|
95
95
|
let n = !s.test(o);
|
|
96
96
|
if (!n) {
|
|
97
97
|
const r = o.indexOf(t);
|
|
98
98
|
r > 0 && !s.test(o.substring(0, r)) && (n = !0);
|
|
99
99
|
}
|
|
100
100
|
return n;
|
|
101
|
-
},
|
|
101
|
+
}, ee = (o, e, t = ".") => {
|
|
102
102
|
if (!o) return;
|
|
103
103
|
if (o[e])
|
|
104
104
|
return Object.prototype.hasOwnProperty.call(o, e) ? o[e] : void 0;
|
|
@@ -118,7 +118,7 @@ const Ae = [" ", ",", "?", "!", ";"], Ke = new Ve(20), Ue = (o, e, t) => {
|
|
|
118
118
|
s = r;
|
|
119
119
|
}
|
|
120
120
|
return s;
|
|
121
|
-
},
|
|
121
|
+
}, B = (o) => o == null ? void 0 : o.replace("_", "-"), He = {
|
|
122
122
|
type: "logger",
|
|
123
123
|
log(o) {
|
|
124
124
|
this.output("log", o);
|
|
@@ -134,12 +134,12 @@ const Ae = [" ", ",", "?", "!", ";"], Ke = new Ve(20), Ue = (o, e, t) => {
|
|
|
134
134
|
(i = (t = console == null ? void 0 : console[o]) == null ? void 0 : t.apply) == null || i.call(t, console, e);
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
-
class
|
|
137
|
+
class G {
|
|
138
138
|
constructor(e, t = {}) {
|
|
139
139
|
this.init(e, t);
|
|
140
140
|
}
|
|
141
141
|
init(e, t = {}) {
|
|
142
|
-
this.prefix = t.prefix || "i18next:", this.logger = e ||
|
|
142
|
+
this.prefix = t.prefix || "i18next:", this.logger = e || He, this.options = t, this.debug = t.debug;
|
|
143
143
|
}
|
|
144
144
|
log(...e) {
|
|
145
145
|
return this.forward(e, "log", "", !0);
|
|
@@ -157,16 +157,16 @@ class Q {
|
|
|
157
157
|
return s && !this.debug ? null : (g(e[0]) && (e[0] = `${i}${this.prefix} ${e[0]}`), this.logger[t](e));
|
|
158
158
|
}
|
|
159
159
|
create(e) {
|
|
160
|
-
return new
|
|
160
|
+
return new G(this.logger, p({
|
|
161
161
|
prefix: `${this.prefix}:${e}:`
|
|
162
162
|
}, this.options));
|
|
163
163
|
}
|
|
164
164
|
clone(e) {
|
|
165
|
-
return e = e || this.options, e.prefix = e.prefix || this.prefix, new
|
|
165
|
+
return e = e || this.options, e.prefix = e.prefix || this.prefix, new G(this.logger, e);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
var
|
|
169
|
-
class
|
|
168
|
+
var F = new G();
|
|
169
|
+
class X {
|
|
170
170
|
constructor() {
|
|
171
171
|
this.observers = {};
|
|
172
172
|
}
|
|
@@ -196,7 +196,7 @@ class Z {
|
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
class
|
|
199
|
+
class he extends X {
|
|
200
200
|
constructor(e, t = {
|
|
201
201
|
ns: ["translation"],
|
|
202
202
|
defaultNS: "translation"
|
|
@@ -215,15 +215,15 @@ class fe extends Z {
|
|
|
215
215
|
const n = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, r = s.ignoreJSONStructure !== void 0 ? s.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
216
216
|
let a;
|
|
217
217
|
e.indexOf(".") > -1 ? a = e.split(".") : (a = [e, t], i && (Array.isArray(i) ? a.push(...i) : g(i) && n ? a.push(...i.split(n)) : a.push(i)));
|
|
218
|
-
const l =
|
|
219
|
-
return !l && !t && !i && e.indexOf(".") > -1 && (e = a[0], t = a[1], i = a.slice(2).join(".")), l || !r || !g(i) ? l :
|
|
218
|
+
const l = Q(this.data, a);
|
|
219
|
+
return !l && !t && !i && e.indexOf(".") > -1 && (e = a[0], t = a[1], i = a.slice(2).join(".")), l || !r || !g(i) ? l : ee((h = (u = this.data) == null ? void 0 : u[e]) == null ? void 0 : h[t], i, n);
|
|
220
220
|
}
|
|
221
221
|
addResource(e, t, i, s, n = {
|
|
222
222
|
silent: !1
|
|
223
223
|
}) {
|
|
224
224
|
const r = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator;
|
|
225
225
|
let a = [e, t];
|
|
226
|
-
i && (a = a.concat(r ? i.split(r) : i)), e.indexOf(".") > -1 && (a = e.split("."), s = t, t = a[1]), this.addNamespaces(t),
|
|
226
|
+
i && (a = a.concat(r ? i.split(r) : i)), e.indexOf(".") > -1 && (a = e.split("."), s = t, t = a[1]), this.addNamespaces(t), fe(this.data, a, s), n.silent || this.emit("added", e, t, i, s);
|
|
227
227
|
}
|
|
228
228
|
addResources(e, t, i, s = {
|
|
229
229
|
silent: !1
|
|
@@ -240,8 +240,8 @@ class fe extends Z {
|
|
|
240
240
|
}) {
|
|
241
241
|
let a = [e, t];
|
|
242
242
|
e.indexOf(".") > -1 && (a = e.split("."), s = i, i = t, t = a[1]), this.addNamespaces(t);
|
|
243
|
-
let l =
|
|
244
|
-
r.skipCopy || (i = JSON.parse(JSON.stringify(i))), s ?
|
|
243
|
+
let l = Q(this.data, a) || {};
|
|
244
|
+
r.skipCopy || (i = JSON.parse(JSON.stringify(i))), s ? we(l, i, n) : l = p(p({}, l), i), fe(this.data, a, l), r.silent || this.emit("added", e, t, i);
|
|
245
245
|
}
|
|
246
246
|
removeResourceBundle(e, t) {
|
|
247
247
|
this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
|
|
@@ -263,7 +263,7 @@ class fe extends Z {
|
|
|
263
263
|
return this.data;
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
var
|
|
266
|
+
var ve = {
|
|
267
267
|
processors: {},
|
|
268
268
|
addPostProcessor(o) {
|
|
269
269
|
this.processors[o.name] = o;
|
|
@@ -275,10 +275,10 @@ var we = {
|
|
|
275
275
|
}), e;
|
|
276
276
|
}
|
|
277
277
|
};
|
|
278
|
-
const
|
|
279
|
-
class
|
|
278
|
+
const ce = {}, de = (o) => !g(o) && typeof o != "boolean" && typeof o != "number";
|
|
279
|
+
class Z extends X {
|
|
280
280
|
constructor(e, t = {}) {
|
|
281
|
-
super(),
|
|
281
|
+
super(), je(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = F.create("translator");
|
|
282
282
|
}
|
|
283
283
|
changeLanguage(e) {
|
|
284
284
|
e && (this.language = e);
|
|
@@ -296,7 +296,7 @@ class G extends Z {
|
|
|
296
296
|
i === void 0 && (i = ":");
|
|
297
297
|
const s = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
|
|
298
298
|
let n = t.ns || this.options.defaultNS || [];
|
|
299
|
-
const r = i && e.indexOf(i) > -1, a = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !
|
|
299
|
+
const r = i && e.indexOf(i) > -1, a = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !Me(e, i, s);
|
|
300
300
|
if (r && !a) {
|
|
301
301
|
const l = e.match(this.interpolator.nestingRegexp);
|
|
302
302
|
if (l && l.length > 0)
|
|
@@ -341,68 +341,68 @@ class G extends Z {
|
|
|
341
341
|
} : a;
|
|
342
342
|
const d = this.resolve(e, s);
|
|
343
343
|
let c = d == null ? void 0 : d.res;
|
|
344
|
-
const x = (d == null ? void 0 : d.usedKey) || a, S = (d == null ? void 0 : d.exactUsedKey) || a,
|
|
344
|
+
const x = (d == null ? void 0 : d.usedKey) || a, S = (d == null ? void 0 : d.exactUsedKey) || a, R = ["[object Number]", "[object Function]", "[object RegExp]"], C = s.joinArrays !== void 0 ? s.joinArrays : this.options.joinArrays, I = !this.i18nFormat || this.i18nFormat.handleAsObject, L = s.count !== void 0 && !g(s.count), j = Z.hasDefaultValue(s), J = L ? this.pluralResolver.getSuffix(f, s.count, s) : "", E = s.ordinal && L ? this.pluralResolver.getSuffix(f, s.count, {
|
|
345
345
|
ordinal: !1
|
|
346
|
-
}) : "",
|
|
346
|
+
}) : "", A = L && !s.ordinal && s.count === 0, w = A && s[`defaultValue${this.options.pluralSeparator}zero`] || s[`defaultValue${J}`] || s[`defaultValue${E}`] || s.defaultValue;
|
|
347
347
|
let b = c;
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
if (
|
|
348
|
+
I && !c && j && (b = w);
|
|
349
|
+
const Ce = de(b), $e = Object.prototype.toString.apply(b);
|
|
350
|
+
if (I && b && Ce && R.indexOf($e) < 0 && !(g(C) && Array.isArray(b))) {
|
|
351
351
|
if (!s.returnObjects && !this.options.returnObjects) {
|
|
352
352
|
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
353
|
-
const
|
|
353
|
+
const k = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(x, b, O(p({}, s), {
|
|
354
354
|
ns: l
|
|
355
355
|
})) : `key '${a} (${this.language})' returned an object instead of string.`;
|
|
356
|
-
return n ? (d.res =
|
|
356
|
+
return n ? (d.res = k, d.usedParams = this.getUsedParamsDetails(s), d) : k;
|
|
357
357
|
}
|
|
358
358
|
if (r) {
|
|
359
|
-
const
|
|
360
|
-
for (const
|
|
361
|
-
if (Object.prototype.hasOwnProperty.call(b,
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
defaultValue:
|
|
359
|
+
const k = Array.isArray(b), P = k ? [] : {}, te = k ? S : x;
|
|
360
|
+
for (const N in b)
|
|
361
|
+
if (Object.prototype.hasOwnProperty.call(b, N)) {
|
|
362
|
+
const T = `${te}${r}${N}`;
|
|
363
|
+
j && !c ? P[N] = this.translate(T, O(p({}, s), {
|
|
364
|
+
defaultValue: de(w) ? w[N] : void 0,
|
|
365
365
|
joinArrays: !1,
|
|
366
366
|
ns: l
|
|
367
|
-
})) :
|
|
367
|
+
})) : P[N] = this.translate(T, O(p({}, s), {
|
|
368
368
|
joinArrays: !1,
|
|
369
369
|
ns: l
|
|
370
|
-
})),
|
|
370
|
+
})), P[N] === T && (P[N] = b[N]);
|
|
371
371
|
}
|
|
372
|
-
c =
|
|
372
|
+
c = P;
|
|
373
373
|
}
|
|
374
|
-
} else if (
|
|
374
|
+
} else if (I && g(C) && Array.isArray(c))
|
|
375
375
|
c = c.join(C), c && (c = this.extendTranslation(c, e, s, i));
|
|
376
376
|
else {
|
|
377
|
-
let
|
|
378
|
-
!this.isValidLookup(c) &&
|
|
379
|
-
const
|
|
380
|
-
if (
|
|
381
|
-
if (this.logger.log(
|
|
377
|
+
let k = !1, P = !1;
|
|
378
|
+
!this.isValidLookup(c) && j && (k = !0, c = w), this.isValidLookup(c) || (P = !0, c = a);
|
|
379
|
+
const N = (s.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && P ? void 0 : c, T = j && w !== c && this.options.updateMissing;
|
|
380
|
+
if (P || k || T) {
|
|
381
|
+
if (this.logger.log(T ? "updateKey" : "missingKey", f, u, a, T ? w : c), r) {
|
|
382
382
|
const v = this.resolve(a, O(p({}, s), {
|
|
383
383
|
keySeparator: !1
|
|
384
384
|
}));
|
|
385
385
|
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.");
|
|
386
386
|
}
|
|
387
|
-
let
|
|
388
|
-
const
|
|
389
|
-
if (this.options.saveMissingTo === "fallback" &&
|
|
390
|
-
for (let v = 0; v <
|
|
391
|
-
|
|
392
|
-
else this.options.saveMissingTo === "all" ?
|
|
393
|
-
const
|
|
394
|
-
var
|
|
395
|
-
const
|
|
396
|
-
this.options.missingKeyHandler ? this.options.missingKeyHandler(v, u,
|
|
387
|
+
let K = [];
|
|
388
|
+
const W = this.languageUtils.getFallbackCodes(this.options.fallbackLng, s.lng || this.language);
|
|
389
|
+
if (this.options.saveMissingTo === "fallback" && W && W[0])
|
|
390
|
+
for (let v = 0; v < W.length; v++)
|
|
391
|
+
K.push(W[v]);
|
|
392
|
+
else this.options.saveMissingTo === "all" ? K = this.languageUtils.toResolveHierarchy(s.lng || this.language) : K.push(s.lng || this.language);
|
|
393
|
+
const ie = (v, D, U) => {
|
|
394
|
+
var ne;
|
|
395
|
+
const se = j && U !== c ? U : N;
|
|
396
|
+
this.options.missingKeyHandler ? this.options.missingKeyHandler(v, u, D, se, T, s) : (ne = this.backendConnector) != null && ne.saveMissing && this.backendConnector.saveMissing(v, u, D, se, T, s), this.emit("missingKey", v, u, D, c);
|
|
397
397
|
};
|
|
398
|
-
this.options.saveMissing && (this.options.saveMissingPlurals && L ?
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
|
|
398
|
+
this.options.saveMissing && (this.options.saveMissingPlurals && L ? K.forEach((v) => {
|
|
399
|
+
const D = this.pluralResolver.getSuffixes(v, s);
|
|
400
|
+
A && s[`defaultValue${this.options.pluralSeparator}zero`] && D.indexOf(`${this.options.pluralSeparator}zero`) < 0 && D.push(`${this.options.pluralSeparator}zero`), D.forEach((U) => {
|
|
401
|
+
ie([v], a + U, s[`defaultValue${U}`] || w);
|
|
402
402
|
});
|
|
403
|
-
}) :
|
|
403
|
+
}) : ie(K, a, w));
|
|
404
404
|
}
|
|
405
|
-
c = this.extendTranslation(c, e, s, d, i),
|
|
405
|
+
c = this.extendTranslation(c, e, s, d, i), P && c === a && this.options.appendNamespaceToMissingKey && (c = `${u}${h}${a}`), (P || k) && this.options.parseMissingKeyHandler && (c = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${u}${h}${a}` : a, k ? c : void 0, s));
|
|
406
406
|
}
|
|
407
407
|
return n ? (d.res = c, d.usedParams = this.getUsedParamsDetails(s), d) : c;
|
|
408
408
|
}
|
|
@@ -430,7 +430,7 @@ class G extends Z {
|
|
|
430
430
|
!i.lng && s && s.res && (i.lng = this.language || s.usedLng), i.nest !== !1 && (e = this.interpolator.nest(e, (...d) => (n == null ? void 0 : n[0]) === d[0] && !i.context ? (this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`), null) : this.translate(...d, t), i)), i.interpolation && this.interpolator.reset();
|
|
431
431
|
}
|
|
432
432
|
const r = i.postProcess || this.options.postProcess, a = g(r) ? [r] : r;
|
|
433
|
-
return e != null && (a != null && a.length) && i.applyPostProcessor !== !1 && (e =
|
|
433
|
+
return e != null && (a != null && a.length) && i.applyPostProcessor !== !1 && (e = ve.handle(a, e, t, this.options && this.options.postProcessPassResolved ? p({
|
|
434
434
|
i18nResolved: O(p({}, s), {
|
|
435
435
|
usedParams: this.getUsedParamsDetails(i)
|
|
436
436
|
})
|
|
@@ -446,26 +446,26 @@ class G extends Z {
|
|
|
446
446
|
this.options.fallbackNS && (f = f.concat(this.options.fallbackNS));
|
|
447
447
|
const m = t.count !== void 0 && !g(t.count), d = m && !t.ordinal && t.count === 0, c = t.context !== void 0 && (g(t.context) || typeof t.context == "number") && t.context !== "", x = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
|
|
448
448
|
f.forEach((S) => {
|
|
449
|
-
var
|
|
450
|
-
this.isValidLookup(i) || (a = S, !
|
|
451
|
-
var
|
|
449
|
+
var R, C;
|
|
450
|
+
this.isValidLookup(i) || (a = S, !ce[`${x[0]}-${S}`] && ((R = this.utils) != null && R.hasLoadedNamespace) && !((C = this.utils) != null && C.hasLoadedNamespace(a)) && (ce[`${x[0]}-${S}`] = !0, this.logger.warn(`key "${s}" for languages "${x.join(", ")}" won't get resolved as namespace "${a}" 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((I) => {
|
|
451
|
+
var J;
|
|
452
452
|
if (this.isValidLookup(i)) return;
|
|
453
|
-
r =
|
|
453
|
+
r = I;
|
|
454
454
|
const L = [h];
|
|
455
|
-
if ((
|
|
456
|
-
this.i18nFormat.addLookupKeys(L, h,
|
|
455
|
+
if ((J = this.i18nFormat) != null && J.addLookupKeys)
|
|
456
|
+
this.i18nFormat.addLookupKeys(L, h, I, S, t);
|
|
457
457
|
else {
|
|
458
|
-
let
|
|
459
|
-
m && (
|
|
460
|
-
const
|
|
461
|
-
if (m && (L.push(h +
|
|
458
|
+
let E;
|
|
459
|
+
m && (E = this.pluralResolver.getSuffix(I, t.count, t));
|
|
460
|
+
const A = `${this.options.pluralSeparator}zero`, w = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
461
|
+
if (m && (L.push(h + E), t.ordinal && E.indexOf(w) === 0 && L.push(h + E.replace(w, this.options.pluralSeparator)), d && L.push(h + A)), c) {
|
|
462
462
|
const b = `${h}${this.options.contextSeparator}${t.context}`;
|
|
463
|
-
L.push(b), m && (L.push(b +
|
|
463
|
+
L.push(b), m && (L.push(b + E), t.ordinal && E.indexOf(w) === 0 && L.push(b + E.replace(w, this.options.pluralSeparator)), d && L.push(b + A));
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
let
|
|
467
|
-
for (;
|
|
468
|
-
this.isValidLookup(i) || (n =
|
|
466
|
+
let j;
|
|
467
|
+
for (; j = L.pop(); )
|
|
468
|
+
this.isValidLookup(i) || (n = j, i = this.getResource(I, S, j, t));
|
|
469
469
|
}));
|
|
470
470
|
});
|
|
471
471
|
}), {
|
|
@@ -501,17 +501,17 @@ class G extends Z {
|
|
|
501
501
|
return !1;
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
|
-
class
|
|
504
|
+
class pe {
|
|
505
505
|
constructor(e) {
|
|
506
|
-
this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger =
|
|
506
|
+
this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = F.create("languageUtils");
|
|
507
507
|
}
|
|
508
508
|
getScriptPartFromCode(e) {
|
|
509
|
-
if (e =
|
|
509
|
+
if (e = B(e), !e || e.indexOf("-") < 0) return null;
|
|
510
510
|
const t = e.split("-");
|
|
511
511
|
return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
|
|
512
512
|
}
|
|
513
513
|
getLanguagePartFromCode(e) {
|
|
514
|
-
if (e =
|
|
514
|
+
if (e = B(e), !e || e.indexOf("-") < 0) return e;
|
|
515
515
|
const t = e.split("-");
|
|
516
516
|
return this.formatLanguageCode(t[0]);
|
|
517
517
|
}
|
|
@@ -565,22 +565,22 @@ class de {
|
|
|
565
565
|
}), s;
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
|
-
const
|
|
568
|
+
const ge = {
|
|
569
569
|
zero: 0,
|
|
570
570
|
one: 1,
|
|
571
571
|
two: 2,
|
|
572
572
|
few: 3,
|
|
573
573
|
many: 4,
|
|
574
574
|
other: 5
|
|
575
|
-
},
|
|
575
|
+
}, me = {
|
|
576
576
|
select: (o) => o === 1 ? "one" : "other",
|
|
577
577
|
resolvedOptions: () => ({
|
|
578
578
|
pluralCategories: ["one", "other"]
|
|
579
579
|
})
|
|
580
580
|
};
|
|
581
|
-
class
|
|
581
|
+
class Be {
|
|
582
582
|
constructor(e, t = {}) {
|
|
583
|
-
this.languageUtils = e, this.options = t, this.logger =
|
|
583
|
+
this.languageUtils = e, this.options = t, this.logger = F.create("pluralResolver"), this.pluralRulesCache = {};
|
|
584
584
|
}
|
|
585
585
|
addRule(e, t) {
|
|
586
586
|
this.rules[e] = t;
|
|
@@ -589,7 +589,7 @@ class He {
|
|
|
589
589
|
this.pluralRulesCache = {};
|
|
590
590
|
}
|
|
591
591
|
getRule(e, t = {}) {
|
|
592
|
-
const i =
|
|
592
|
+
const i = B(e === "dev" ? "en" : e), s = t.ordinal ? "ordinal" : "cardinal", n = JSON.stringify({
|
|
593
593
|
cleanedCode: i,
|
|
594
594
|
type: s
|
|
595
595
|
});
|
|
@@ -602,8 +602,8 @@ class He {
|
|
|
602
602
|
});
|
|
603
603
|
} catch (a) {
|
|
604
604
|
if (!Intl)
|
|
605
|
-
return this.logger.error("No Intl support, please use an Intl polyfill!"),
|
|
606
|
-
if (!e.match(/-|_/)) return
|
|
605
|
+
return this.logger.error("No Intl support, please use an Intl polyfill!"), me;
|
|
606
|
+
if (!e.match(/-|_/)) return me;
|
|
607
607
|
const l = this.languageUtils.getLanguagePartFromCode(e);
|
|
608
608
|
r = this.getRule(l, t);
|
|
609
609
|
}
|
|
@@ -618,21 +618,21 @@ class He {
|
|
|
618
618
|
}
|
|
619
619
|
getSuffixes(e, t = {}) {
|
|
620
620
|
let i = this.getRule(e, t);
|
|
621
|
-
return i || (i = this.getRule("dev", t)), i ? i.resolvedOptions().pluralCategories.sort((s, n) =>
|
|
621
|
+
return i || (i = this.getRule("dev", t)), i ? i.resolvedOptions().pluralCategories.sort((s, n) => ge[s] - ge[n]).map((s) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${s}`) : [];
|
|
622
622
|
}
|
|
623
623
|
getSuffix(e, t, i = {}) {
|
|
624
624
|
const s = this.getRule(e, i);
|
|
625
625
|
return s ? `${this.options.prepend}${i.ordinal ? `ordinal${this.options.prepend}` : ""}${s.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, i));
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
|
-
const
|
|
629
|
-
let n =
|
|
630
|
-
return !n && s && g(t) && (n =
|
|
631
|
-
},
|
|
632
|
-
class
|
|
628
|
+
const xe = (o, e, t, i = ".", s = !0) => {
|
|
629
|
+
let n = Ie(o, e, t);
|
|
630
|
+
return !n && s && g(t) && (n = ee(o, t, i), n === void 0 && (n = ee(e, t, i))), n;
|
|
631
|
+
}, q = (o) => o.replace(/\$/g, "$$$$");
|
|
632
|
+
class ze {
|
|
633
633
|
constructor(e = {}) {
|
|
634
634
|
var t;
|
|
635
|
-
this.logger =
|
|
635
|
+
this.logger = F.create("interpolator"), this.options = e, this.format = ((t = e == null ? void 0 : e.interpolation) == null ? void 0 : t.format) || ((i) => i), this.init(e);
|
|
636
636
|
}
|
|
637
637
|
init(e = {}) {
|
|
638
638
|
e.interpolation || (e.interpolation = {
|
|
@@ -654,10 +654,10 @@ class Be {
|
|
|
654
654
|
nestingSuffix: c,
|
|
655
655
|
nestingSuffixEscaped: x,
|
|
656
656
|
nestingOptionsSeparator: S,
|
|
657
|
-
maxReplaces:
|
|
657
|
+
maxReplaces: R,
|
|
658
658
|
alwaysFormat: C
|
|
659
659
|
} = e.interpolation;
|
|
660
|
-
this.escape = t !== void 0 ? t :
|
|
660
|
+
this.escape = t !== void 0 ? t : Ve, this.escapeValue = i !== void 0 ? i : !0, this.useRawValueToEscape = s !== void 0 ? s : !1, this.prefix = n ? V(n) : r || "{{", this.suffix = a ? V(a) : l || "}}", this.formatSeparator = u || ",", this.unescapePrefix = h ? "" : f || "-", this.unescapeSuffix = this.unescapePrefix ? "" : h || "", this.nestingPrefix = m ? V(m) : d || V("$t("), this.nestingSuffix = c ? V(c) : x || V(")"), this.nestingOptionsSeparator = S || ",", this.maxReplaces = R || 1e3, this.alwaysFormat = C !== void 0 ? C : !1, this.resetRegExp();
|
|
661
661
|
}
|
|
662
662
|
reset() {
|
|
663
663
|
this.options && this.init(this.options);
|
|
@@ -671,13 +671,13 @@ class Be {
|
|
|
671
671
|
let n, r, a;
|
|
672
672
|
const l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (c) => {
|
|
673
673
|
if (c.indexOf(this.formatSeparator) < 0) {
|
|
674
|
-
const C =
|
|
674
|
+
const C = xe(t, l, c, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
675
675
|
return this.alwaysFormat ? this.format(C, void 0, i, O(p(p({}, s), t), {
|
|
676
676
|
interpolationkey: c
|
|
677
677
|
})) : C;
|
|
678
678
|
}
|
|
679
|
-
const x = c.split(this.formatSeparator), S = x.shift().trim(),
|
|
680
|
-
return this.format(
|
|
679
|
+
const x = c.split(this.formatSeparator), S = x.shift().trim(), R = x.join(this.formatSeparator).trim();
|
|
680
|
+
return this.format(xe(t, l, S, this.options.keySeparator, this.options.ignoreJSONStructure), R, i, O(p(p({}, s), t), {
|
|
681
681
|
interpolationkey: S
|
|
682
682
|
}));
|
|
683
683
|
};
|
|
@@ -685,17 +685,17 @@ class Be {
|
|
|
685
685
|
const h = (s == null ? void 0 : s.missingInterpolationHandler) || this.options.missingInterpolationHandler, f = ((d = s == null ? void 0 : s.interpolation) == null ? void 0 : d.skipOnVariables) !== void 0 ? s.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
686
686
|
return [{
|
|
687
687
|
regex: this.regexpUnescape,
|
|
688
|
-
safeValue: (c) =>
|
|
688
|
+
safeValue: (c) => q(c)
|
|
689
689
|
}, {
|
|
690
690
|
regex: this.regexp,
|
|
691
|
-
safeValue: (c) => this.escapeValue ?
|
|
691
|
+
safeValue: (c) => this.escapeValue ? q(this.escape(c)) : q(c)
|
|
692
692
|
}].forEach((c) => {
|
|
693
693
|
for (a = 0; n = c.regex.exec(e); ) {
|
|
694
694
|
const x = n[1].trim();
|
|
695
695
|
if (r = u(x), r === void 0)
|
|
696
696
|
if (typeof h == "function") {
|
|
697
|
-
const
|
|
698
|
-
r = g(
|
|
697
|
+
const R = h(e, n, s);
|
|
698
|
+
r = g(R) ? R : "";
|
|
699
699
|
} else if (s && Object.prototype.hasOwnProperty.call(s, x))
|
|
700
700
|
r = "";
|
|
701
701
|
else if (f) {
|
|
@@ -703,7 +703,7 @@ class Be {
|
|
|
703
703
|
continue;
|
|
704
704
|
} else
|
|
705
705
|
this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`), r = "";
|
|
706
|
-
else !g(r) && !this.useRawValueToEscape && (r =
|
|
706
|
+
else !g(r) && !this.useRawValueToEscape && (r = oe(r));
|
|
707
707
|
const S = c.safeValue(r);
|
|
708
708
|
if (e = e.replace(n[0], S), f ? (c.regex.lastIndex += r.length, c.regex.lastIndex -= n[0].length) : c.regex.lastIndex = 0, a++, a >= this.maxReplaces)
|
|
709
709
|
break;
|
|
@@ -733,14 +733,14 @@ class Be {
|
|
|
733
733
|
r = p({}, i), r = r.replace && !g(r.replace) ? r.replace : r, r.applyPostProcessor = !1, delete r.defaultValue;
|
|
734
734
|
const u = /{.*}/.test(s[1]) ? s[1].lastIndexOf("}") + 1 : s[1].indexOf(this.formatSeparator);
|
|
735
735
|
if (u !== -1 && (l = s[1].slice(u).split(this.formatSeparator).map((h) => h.trim()).filter(Boolean), s[1] = s[1].slice(0, u)), n = t(a.call(this, s[1].trim(), r), r), n && s[0] === e && !g(n)) return n;
|
|
736
|
-
g(n) || (n =
|
|
736
|
+
g(n) || (n = oe(n)), n || (this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`), n = ""), l.length && (n = l.reduce((h, f) => this.format(h, f, i.lng, O(p({}, i), {
|
|
737
737
|
interpolationkey: s[1].trim()
|
|
738
738
|
})), n.trim())), e = e.replace(s[0], n), this.regexp.lastIndex = 0;
|
|
739
739
|
}
|
|
740
740
|
return e;
|
|
741
741
|
}
|
|
742
742
|
}
|
|
743
|
-
const
|
|
743
|
+
const Je = (o) => {
|
|
744
744
|
let e = o.toLowerCase().trim();
|
|
745
745
|
const t = {};
|
|
746
746
|
if (o.indexOf("(") > -1) {
|
|
@@ -758,7 +758,7 @@ const ze = (o) => {
|
|
|
758
758
|
formatName: e,
|
|
759
759
|
formatOptions: t
|
|
760
760
|
};
|
|
761
|
-
},
|
|
761
|
+
}, ye = (o) => {
|
|
762
762
|
const e = {};
|
|
763
763
|
return (t, i, s) => {
|
|
764
764
|
let n = s;
|
|
@@ -767,18 +767,18 @@ const ze = (o) => {
|
|
|
767
767
|
}));
|
|
768
768
|
const r = i + JSON.stringify(n);
|
|
769
769
|
let a = e[r];
|
|
770
|
-
return a || (a = o(
|
|
770
|
+
return a || (a = o(B(i), s), e[r] = a), a(t);
|
|
771
771
|
};
|
|
772
|
-
},
|
|
773
|
-
class
|
|
772
|
+
}, We = (o) => (e, t, i) => o(B(t), i)(e);
|
|
773
|
+
class _e {
|
|
774
774
|
constructor(e = {}) {
|
|
775
|
-
this.logger =
|
|
775
|
+
this.logger = F.create("formatter"), this.options = e, this.init(e);
|
|
776
776
|
}
|
|
777
777
|
init(e, t = {
|
|
778
778
|
interpolation: {}
|
|
779
779
|
}) {
|
|
780
780
|
this.formatSeparator = t.interpolation.formatSeparator || ",";
|
|
781
|
-
const i = t.cacheInBuiltFormats ?
|
|
781
|
+
const i = t.cacheInBuiltFormats ? ye : We;
|
|
782
782
|
this.formats = {
|
|
783
783
|
number: i((s, n) => {
|
|
784
784
|
const r = new Intl.NumberFormat(s, p({}, n));
|
|
@@ -808,7 +808,7 @@ class We {
|
|
|
808
808
|
this.formats[e.toLowerCase().trim()] = t;
|
|
809
809
|
}
|
|
810
810
|
addCached(e, t) {
|
|
811
|
-
this.formats[e.toLowerCase().trim()] =
|
|
811
|
+
this.formats[e.toLowerCase().trim()] = ye(t);
|
|
812
812
|
}
|
|
813
813
|
format(e, t, i, s = {}) {
|
|
814
814
|
const n = t.split(this.formatSeparator);
|
|
@@ -821,7 +821,7 @@ class We {
|
|
|
821
821
|
const {
|
|
822
822
|
formatName: u,
|
|
823
823
|
formatOptions: h
|
|
824
|
-
} =
|
|
824
|
+
} = Je(l);
|
|
825
825
|
if (this.formats[u]) {
|
|
826
826
|
let m = a;
|
|
827
827
|
try {
|
|
@@ -837,13 +837,13 @@ class We {
|
|
|
837
837
|
}, e);
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
const
|
|
840
|
+
const Ye = (o, e) => {
|
|
841
841
|
o.pending[e] !== void 0 && (delete o.pending[e], o.pendingCount--);
|
|
842
842
|
};
|
|
843
|
-
class
|
|
843
|
+
class Qe extends X {
|
|
844
844
|
constructor(e, t, i, s = {}) {
|
|
845
845
|
var n, r;
|
|
846
|
-
super(), this.backend = e, this.store = t, this.services = i, this.languageUtils = i.languageUtils, this.options = s, this.logger =
|
|
846
|
+
super(), this.backend = e, this.store = t, this.services = i, this.languageUtils = i.languageUtils, this.options = s, this.logger = F.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 = [], (r = (n = this.backend) == null ? void 0 : n.init) == null || r.call(n, i, s.backend, s);
|
|
847
847
|
}
|
|
848
848
|
queueLoad(e, t, i, s) {
|
|
849
849
|
const n = {}, r = {}, a = {}, l = {};
|
|
@@ -873,7 +873,7 @@ class Ye extends Z {
|
|
|
873
873
|
}), this.state[e] = t ? -1 : 2, t && i && (this.state[e] = 0);
|
|
874
874
|
const a = {};
|
|
875
875
|
this.queue.forEach((l) => {
|
|
876
|
-
|
|
876
|
+
Te(l.loaded, [n], r), Ye(l, e), t && l.errors.push(t), l.pendingCount === 0 && !l.done && (Object.keys(l.loaded).forEach((u) => {
|
|
877
877
|
a[u] || (a[u] = {});
|
|
878
878
|
const h = l.loaded[u];
|
|
879
879
|
h.length && h.forEach((f) => {
|
|
@@ -971,7 +971,7 @@ class Ye extends Z {
|
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
|
-
const
|
|
974
|
+
const Se = () => ({
|
|
975
975
|
debug: !1,
|
|
976
976
|
initAsync: !0,
|
|
977
977
|
ns: ["translation"],
|
|
@@ -1028,20 +1028,20 @@ const ye = () => ({
|
|
|
1028
1028
|
skipOnVariables: !0
|
|
1029
1029
|
},
|
|
1030
1030
|
cacheInBuiltFormats: !0
|
|
1031
|
-
}),
|
|
1031
|
+
}), be = (o) => {
|
|
1032
1032
|
var e, t;
|
|
1033
1033
|
return g(o.ns) && (o.ns = [o.ns]), g(o.fallbackLng) && (o.fallbackLng = [o.fallbackLng]), g(o.fallbackNS) && (o.fallbackNS = [o.fallbackNS]), ((t = (e = o.supportedLngs) == null ? void 0 : e.indexOf) == null ? void 0 : t.call(e, "cimode")) < 0 && (o.supportedLngs = o.supportedLngs.concat(["cimode"])), typeof o.initImmediate == "boolean" && (o.initAsync = o.initImmediate), o;
|
|
1034
|
-
},
|
|
1035
|
-
},
|
|
1034
|
+
}, _ = () => {
|
|
1035
|
+
}, Ge = (o) => {
|
|
1036
1036
|
Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach((t) => {
|
|
1037
1037
|
typeof o[t] == "function" && (o[t] = o[t].bind(o));
|
|
1038
1038
|
});
|
|
1039
1039
|
};
|
|
1040
|
-
class
|
|
1040
|
+
class z extends X {
|
|
1041
1041
|
constructor(e = {}, t) {
|
|
1042
|
-
if (super(), this.options =
|
|
1042
|
+
if (super(), this.options = be(e), this.services = {}, this.logger = F, this.modules = {
|
|
1043
1043
|
external: []
|
|
1044
|
-
},
|
|
1044
|
+
}, Ge(this), t && !this.isInitialized && !e.isClone) {
|
|
1045
1045
|
if (!this.options.initAsync)
|
|
1046
1046
|
return this.init(e, t), this;
|
|
1047
1047
|
setTimeout(() => {
|
|
@@ -1051,30 +1051,30 @@ class B extends Z {
|
|
|
1051
1051
|
}
|
|
1052
1052
|
init(e = {}, t) {
|
|
1053
1053
|
this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (g(e.ns) ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0]));
|
|
1054
|
-
const i =
|
|
1055
|
-
this.options = p(p(p({}, i), this.options),
|
|
1054
|
+
const i = Se();
|
|
1055
|
+
this.options = p(p(p({}, i), this.options), be(e)), this.options.interpolation = p(p({}, i.interpolation), this.options.interpolation), e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator);
|
|
1056
1056
|
const s = (u) => u ? typeof u == "function" ? new u() : u : null;
|
|
1057
1057
|
if (!this.options.isClone) {
|
|
1058
|
-
this.modules.logger ?
|
|
1058
|
+
this.modules.logger ? F.init(s(this.modules.logger), this.options) : F.init(null, this.options);
|
|
1059
1059
|
let u;
|
|
1060
|
-
this.modules.formatter ? u = this.modules.formatter : u =
|
|
1061
|
-
const h = new
|
|
1062
|
-
this.store = new
|
|
1060
|
+
this.modules.formatter ? u = this.modules.formatter : u = _e;
|
|
1061
|
+
const h = new pe(this.options);
|
|
1062
|
+
this.store = new he(this.options.resources, this.options);
|
|
1063
1063
|
const f = this.services;
|
|
1064
|
-
f.logger =
|
|
1064
|
+
f.logger = F, f.resourceStore = this.store, f.languageUtils = h, f.pluralResolver = new Be(h, {
|
|
1065
1065
|
prepend: this.options.pluralSeparator,
|
|
1066
1066
|
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1067
|
-
}), this.options.interpolation.format && this.options.interpolation.format !== i.interpolation.format && this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), u && (!this.options.interpolation.format || this.options.interpolation.format === i.interpolation.format) && (f.formatter = s(u), f.formatter.init && f.formatter.init(f, this.options), this.options.interpolation.format = f.formatter.format.bind(f.formatter)), f.interpolator = new
|
|
1067
|
+
}), this.options.interpolation.format && this.options.interpolation.format !== i.interpolation.format && this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), u && (!this.options.interpolation.format || this.options.interpolation.format === i.interpolation.format) && (f.formatter = s(u), f.formatter.init && f.formatter.init(f, this.options), this.options.interpolation.format = f.formatter.format.bind(f.formatter)), f.interpolator = new ze(this.options), f.utils = {
|
|
1068
1068
|
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
1069
|
-
}, f.backendConnector = new
|
|
1069
|
+
}, f.backendConnector = new Qe(s(this.modules.backend), f.resourceStore, f, this.options), f.backendConnector.on("*", (d, ...c) => {
|
|
1070
1070
|
this.emit(d, ...c);
|
|
1071
|
-
}), this.modules.languageDetector && (f.languageDetector = s(this.modules.languageDetector), f.languageDetector.init && f.languageDetector.init(f, this.options.detection, this.options)), this.modules.i18nFormat && (f.i18nFormat = s(this.modules.i18nFormat), f.i18nFormat.init && f.i18nFormat.init(this)), this.translator = new
|
|
1071
|
+
}), this.modules.languageDetector && (f.languageDetector = s(this.modules.languageDetector), f.languageDetector.init && f.languageDetector.init(f, this.options.detection, this.options)), this.modules.i18nFormat && (f.i18nFormat = s(this.modules.i18nFormat), f.i18nFormat.init && f.i18nFormat.init(this)), this.translator = new Z(this.services, this.options), this.translator.on("*", (d, ...c) => {
|
|
1072
1072
|
this.emit(d, ...c);
|
|
1073
1073
|
}), this.modules.external.forEach((d) => {
|
|
1074
1074
|
d.init && d.init(this);
|
|
1075
1075
|
});
|
|
1076
1076
|
}
|
|
1077
|
-
if (this.format = this.options.interpolation.format, t || (t =
|
|
1077
|
+
if (this.format = this.options.interpolation.format, t || (t = _), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
1078
1078
|
const u = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
1079
1079
|
u.length > 0 && u[0] !== "dev" && (this.options.lng = u[0]);
|
|
1080
1080
|
}
|
|
@@ -1083,7 +1083,7 @@ class B extends Z {
|
|
|
1083
1083
|
}), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((u) => {
|
|
1084
1084
|
this[u] = (...h) => (this.store[u](...h), this);
|
|
1085
1085
|
});
|
|
1086
|
-
const a =
|
|
1086
|
+
const a = M(), l = () => {
|
|
1087
1087
|
const u = (h, f) => {
|
|
1088
1088
|
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), a.resolve(f), t(h, f);
|
|
1089
1089
|
};
|
|
@@ -1092,7 +1092,7 @@ class B extends Z {
|
|
|
1092
1092
|
};
|
|
1093
1093
|
return this.options.resources || !this.options.initAsync ? l() : setTimeout(l, 0), a;
|
|
1094
1094
|
}
|
|
1095
|
-
loadResources(e, t =
|
|
1095
|
+
loadResources(e, t = _) {
|
|
1096
1096
|
var n, r;
|
|
1097
1097
|
let i = t;
|
|
1098
1098
|
const s = g(e) ? e : this.language;
|
|
@@ -1111,15 +1111,15 @@ class B extends Z {
|
|
|
1111
1111
|
i(null);
|
|
1112
1112
|
}
|
|
1113
1113
|
reloadResources(e, t, i) {
|
|
1114
|
-
const s =
|
|
1115
|
-
return typeof e == "function" && (i = e, e = void 0), typeof t == "function" && (i = t, t = void 0), e || (e = this.languages), t || (t = this.options.ns), i || (i =
|
|
1114
|
+
const s = M();
|
|
1115
|
+
return typeof e == "function" && (i = e, e = void 0), typeof t == "function" && (i = t, t = void 0), e || (e = this.languages), t || (t = this.options.ns), i || (i = _), this.services.backendConnector.reload(e, t, (n) => {
|
|
1116
1116
|
s.resolve(), i(n);
|
|
1117
1117
|
}), s;
|
|
1118
1118
|
}
|
|
1119
1119
|
use(e) {
|
|
1120
1120
|
if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
|
|
1121
1121
|
if (!e.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
|
|
1122
|
-
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" &&
|
|
1122
|
+
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" && ve.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
|
|
1123
1123
|
}
|
|
1124
1124
|
setResolvedLanguage(e) {
|
|
1125
1125
|
if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
|
|
@@ -1135,7 +1135,7 @@ class B extends Z {
|
|
|
1135
1135
|
}
|
|
1136
1136
|
changeLanguage(e, t) {
|
|
1137
1137
|
this.isLanguageChangingTo = e;
|
|
1138
|
-
const i =
|
|
1138
|
+
const i = M();
|
|
1139
1139
|
this.emit("languageChanging", e);
|
|
1140
1140
|
const s = (a) => {
|
|
1141
1141
|
this.language = a, this.languages = this.services.languageUtils.toResolveHierarchy(a), this.resolvedLanguage = void 0, this.setResolvedLanguage(a);
|
|
@@ -1190,7 +1190,7 @@ class B extends Z {
|
|
|
1190
1190
|
return !!(this.hasResourceBundle(i, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || r(i, e) && (!s || r(n, e)));
|
|
1191
1191
|
}
|
|
1192
1192
|
loadNamespaces(e, t) {
|
|
1193
|
-
const i =
|
|
1193
|
+
const i = M();
|
|
1194
1194
|
return this.options.ns ? (g(e) && (e = [e]), e.forEach((s) => {
|
|
1195
1195
|
this.options.ns.indexOf(s) < 0 && this.options.ns.push(s);
|
|
1196
1196
|
}), this.loadResources((s) => {
|
|
@@ -1198,7 +1198,7 @@ class B extends Z {
|
|
|
1198
1198
|
}), i) : (t && t(), Promise.resolve());
|
|
1199
1199
|
}
|
|
1200
1200
|
loadLanguages(e, t) {
|
|
1201
|
-
const i =
|
|
1201
|
+
const i = M();
|
|
1202
1202
|
g(e) && (e = [e]);
|
|
1203
1203
|
const s = this.options.preload || [], n = e.filter((r) => s.indexOf(r) < 0 && this.services.languageUtils.isSupportedCode(r));
|
|
1204
1204
|
return n.length ? (this.options.preload = s.concat(n), this.loadResources((r) => {
|
|
@@ -1216,27 +1216,27 @@ class B extends Z {
|
|
|
1216
1216
|
}
|
|
1217
1217
|
} catch (r) {
|
|
1218
1218
|
}
|
|
1219
|
-
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"], i = ((n = this.services) == null ? void 0 : n.languageUtils) || new
|
|
1219
|
+
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"], i = ((n = this.services) == null ? void 0 : n.languageUtils) || new pe(Se());
|
|
1220
1220
|
return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(i.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
1221
1221
|
}
|
|
1222
1222
|
static createInstance(e = {}, t) {
|
|
1223
|
-
return new
|
|
1223
|
+
return new z(e, t);
|
|
1224
1224
|
}
|
|
1225
|
-
cloneInstance(e = {}, t =
|
|
1225
|
+
cloneInstance(e = {}, t = _) {
|
|
1226
1226
|
const i = e.forkResourceStore;
|
|
1227
1227
|
i && delete e.forkResourceStore;
|
|
1228
1228
|
const s = O(p(p({}, this.options), e), {
|
|
1229
1229
|
isClone: !0
|
|
1230
|
-
}), n = new
|
|
1230
|
+
}), n = new z(s);
|
|
1231
1231
|
if ((e.debug !== void 0 || e.prefix !== void 0) && (n.logger = n.logger.clone(e)), ["store", "services", "language"].forEach((a) => {
|
|
1232
1232
|
n[a] = this[a];
|
|
1233
1233
|
}), n.services = p({}, this.services), n.services.utils = {
|
|
1234
1234
|
hasLoadedNamespace: n.hasLoadedNamespace.bind(n)
|
|
1235
1235
|
}, i) {
|
|
1236
1236
|
const a = Object.keys(this.store.data).reduce((l, u) => (l[u] = p({}, this.store.data[u]), l[u] = Object.keys(l[u]).reduce((h, f) => (h[f] = p({}, l[u][f]), h), l[u]), l), {});
|
|
1237
|
-
n.store = new
|
|
1237
|
+
n.store = new he(a, s), n.services.resourceStore = n.store;
|
|
1238
1238
|
}
|
|
1239
|
-
return n.translator = new
|
|
1239
|
+
return n.translator = new Z(n.services, s), n.translator.on("*", (a, ...l) => {
|
|
1240
1240
|
n.emit(a, ...l);
|
|
1241
1241
|
}), n.init(s, t), n.translator.options = s, n.translator.backendConnector.services.utils = {
|
|
1242
1242
|
hasLoadedNamespace: n.hasLoadedNamespace.bind(n)
|
|
@@ -1252,8 +1252,8 @@ class B extends Z {
|
|
|
1252
1252
|
};
|
|
1253
1253
|
}
|
|
1254
1254
|
}
|
|
1255
|
-
const y =
|
|
1256
|
-
y.createInstance =
|
|
1255
|
+
const y = z.createInstance();
|
|
1256
|
+
y.createInstance = z.createInstance;
|
|
1257
1257
|
y.createInstance;
|
|
1258
1258
|
y.dir;
|
|
1259
1259
|
y.init;
|
|
@@ -1268,11 +1268,11 @@ y.setDefaultNamespace;
|
|
|
1268
1268
|
y.hasLoadedNamespace;
|
|
1269
1269
|
y.loadNamespaces;
|
|
1270
1270
|
y.loadLanguages;
|
|
1271
|
-
const
|
|
1271
|
+
const Ze = (o, e) => {
|
|
1272
1272
|
for (const t of e) {
|
|
1273
1273
|
const i = o.find(t);
|
|
1274
1274
|
i && i.each((s, n) => {
|
|
1275
|
-
const r =
|
|
1275
|
+
const r = $(n);
|
|
1276
1276
|
if (r.attr("data-i18n"))
|
|
1277
1277
|
return;
|
|
1278
1278
|
const a = r.text().trim();
|
|
@@ -1287,11 +1287,11 @@ const Ge = (o, e) => {
|
|
|
1287
1287
|
}));
|
|
1288
1288
|
});
|
|
1289
1289
|
}
|
|
1290
|
-
},
|
|
1290
|
+
}, Y = (o) => {
|
|
1291
1291
|
for (const e of o) {
|
|
1292
|
-
const t =
|
|
1292
|
+
const t = $(e);
|
|
1293
1293
|
t && t.each((i, s) => {
|
|
1294
|
-
const n =
|
|
1294
|
+
const n = $(s);
|
|
1295
1295
|
if (n.attr("data-i18n"))
|
|
1296
1296
|
return;
|
|
1297
1297
|
const r = n.text().trim();
|
|
@@ -1306,8 +1306,8 @@ const Ge = (o, e) => {
|
|
|
1306
1306
|
}));
|
|
1307
1307
|
});
|
|
1308
1308
|
}
|
|
1309
|
-
},
|
|
1310
|
-
|
|
1309
|
+
}, Xe = (o, e) => {
|
|
1310
|
+
Ze(e, [
|
|
1311
1311
|
".hiprint-option-item-label",
|
|
1312
1312
|
"textarea",
|
|
1313
1313
|
"input",
|
|
@@ -1318,7 +1318,7 @@ const Ge = (o, e) => {
|
|
|
1318
1318
|
".hiprint-option-title",
|
|
1319
1319
|
".hiprint-option-item-desc"
|
|
1320
1320
|
]);
|
|
1321
|
-
},
|
|
1321
|
+
}, qe = () => {
|
|
1322
1322
|
document.querySelectorAll("[data-i18n]").forEach((o) => {
|
|
1323
1323
|
const e = o.getAttribute("data-i18n");
|
|
1324
1324
|
if (!e.includes("[")) {
|
|
@@ -1332,19 +1332,19 @@ const Ge = (o, e) => {
|
|
|
1332
1332
|
}
|
|
1333
1333
|
});
|
|
1334
1334
|
};
|
|
1335
|
-
let
|
|
1336
|
-
const
|
|
1337
|
-
if (
|
|
1335
|
+
let Le = !1;
|
|
1336
|
+
const Oe = (o) => {
|
|
1337
|
+
if (Le)
|
|
1338
1338
|
return;
|
|
1339
|
-
|
|
1339
|
+
Le = !0, globalThis.hiprint.i18next = y, globalThis.hiprint.t = y.t;
|
|
1340
1340
|
const e = Object.keys(o.resources || {});
|
|
1341
1341
|
globalThis.hiprint.languages = ["简体中文", ...e], globalThis.hiprint.changeLanguage = (t, i) => {
|
|
1342
1342
|
y.changeLanguage(t, (s, n) => {
|
|
1343
|
-
i && i(s, n),
|
|
1343
|
+
i && i(s, n), qe();
|
|
1344
1344
|
});
|
|
1345
1345
|
};
|
|
1346
1346
|
};
|
|
1347
|
-
function
|
|
1347
|
+
function tt(o, e) {
|
|
1348
1348
|
y.init(p({}, o), (i, s) => {
|
|
1349
1349
|
e && e(y, s, i);
|
|
1350
1350
|
});
|
|
@@ -1359,7 +1359,7 @@ function et(o, e) {
|
|
|
1359
1359
|
description: "添加 i18n 方法",
|
|
1360
1360
|
priority: 1,
|
|
1361
1361
|
run: () => {
|
|
1362
|
-
|
|
1362
|
+
Oe(o);
|
|
1363
1363
|
}
|
|
1364
1364
|
},
|
|
1365
1365
|
{
|
|
@@ -1369,14 +1369,15 @@ function et(o, e) {
|
|
|
1369
1369
|
priority: 1,
|
|
1370
1370
|
run: (i) => {
|
|
1371
1371
|
if (i) {
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
"data-name": i.name
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1372
|
+
if (!i._translationWrapped) {
|
|
1373
|
+
i._translationWrapped = !0;
|
|
1374
|
+
const s = i.createTarget;
|
|
1375
|
+
i.createTarget = function(...n) {
|
|
1376
|
+
const r = s.call(i, ...n);
|
|
1377
|
+
return t.indexOf(i.name) !== -1 && r.attr("data-name") || (r.attr({ "data-name": i.name }), Xe(i, r)), r;
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
return t.indexOf(i.name) === -1 && t.push(i.name), i;
|
|
1380
1381
|
}
|
|
1381
1382
|
}
|
|
1382
1383
|
},
|
|
@@ -1387,18 +1388,18 @@ function et(o, e) {
|
|
|
1387
1388
|
priority: 1,
|
|
1388
1389
|
run: ({ hiprint: i, designerUtils: s }) => {
|
|
1389
1390
|
var a;
|
|
1390
|
-
|
|
1391
|
+
Oe(o);
|
|
1391
1392
|
const n = (a = s.printTemplate) == null ? void 0 : a.id;
|
|
1392
1393
|
n && (globalThis.hinnn.event.on("PrintElementSelectEventKey_" + n, (l) => {
|
|
1393
1394
|
setTimeout(() => {
|
|
1394
|
-
|
|
1395
|
+
Y([".printSetting .prop-tab-items .tab-title"]);
|
|
1395
1396
|
}, 0);
|
|
1396
|
-
}),
|
|
1397
|
-
|
|
1397
|
+
}), $(".hiprint-printPaper.design").on("contextmenu", () => {
|
|
1398
|
+
Y([
|
|
1398
1399
|
".hicontextmenu .hicontextmenuitem .title span",
|
|
1399
1400
|
".hicontextmenu .hicontextmenuitem .nav"
|
|
1400
1401
|
]);
|
|
1401
|
-
})),
|
|
1402
|
+
})), Y([
|
|
1402
1403
|
".svp-header p",
|
|
1403
1404
|
".svp-tools .tool-name",
|
|
1404
1405
|
".svp-dragbox .header span",
|
|
@@ -1414,7 +1415,7 @@ function et(o, e) {
|
|
|
1414
1415
|
priority: 1,
|
|
1415
1416
|
run: (i) => {
|
|
1416
1417
|
setTimeout(() => {
|
|
1417
|
-
|
|
1418
|
+
Y([".preview-bar button span", ".printer-list-txt"]);
|
|
1418
1419
|
}, 0);
|
|
1419
1420
|
}
|
|
1420
1421
|
}
|
|
@@ -1423,6 +1424,6 @@ function et(o, e) {
|
|
|
1423
1424
|
};
|
|
1424
1425
|
}
|
|
1425
1426
|
export {
|
|
1426
|
-
|
|
1427
|
-
|
|
1427
|
+
tt as default,
|
|
1428
|
+
Y as translateBySelector
|
|
1428
1429
|
};
|