@sv-print/plugin-i18n 0.1.4 → 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.d.ts +7 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +251 -283
- package/dist/index.umd.js +1 -1
- package/dist/translate-option.d.ts +2 -0
- package/package.json +9 -5
package/dist/index.mjs
CHANGED
|
@@ -1,72 +1,71 @@
|
|
|
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
|
-
|
|
29
|
-
const n = oe(i[s]);
|
|
27
|
+
if (ue(o)) return {};
|
|
28
|
+
const n = le(i[s]);
|
|
30
29
|
!o[n] && t && (o[n] = new t()), Object.prototype.hasOwnProperty.call(o, n) ? o = o[n] : o = {}, ++s;
|
|
31
30
|
}
|
|
32
|
-
return
|
|
31
|
+
return ue(o) ? {} : {
|
|
33
32
|
obj: o,
|
|
34
|
-
k:
|
|
33
|
+
k: le(i[s])
|
|
35
34
|
};
|
|
36
|
-
},
|
|
35
|
+
}, fe = (o, e, t) => {
|
|
37
36
|
const {
|
|
38
37
|
obj: i,
|
|
39
38
|
k: s
|
|
40
|
-
} =
|
|
39
|
+
} = H(o, e, Object);
|
|
41
40
|
if (i !== void 0 || e.length === 1) {
|
|
42
41
|
i[s] = t;
|
|
43
42
|
return;
|
|
44
43
|
}
|
|
45
|
-
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);
|
|
46
45
|
for (; a.obj === void 0 && r.length; )
|
|
47
|
-
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);
|
|
48
47
|
a.obj[`${a.k}.${n}`] = t;
|
|
49
48
|
}, Te = (o, e, t, i) => {
|
|
50
49
|
const {
|
|
51
50
|
obj: s,
|
|
52
51
|
k: n
|
|
53
|
-
} =
|
|
52
|
+
} = H(o, e, Object);
|
|
54
53
|
s[n] = s[n] || [], s[n].push(t);
|
|
55
|
-
},
|
|
54
|
+
}, Q = (o, e) => {
|
|
56
55
|
const {
|
|
57
56
|
obj: t,
|
|
58
57
|
k: i
|
|
59
|
-
} =
|
|
60
|
-
if (
|
|
58
|
+
} = H(o, e);
|
|
59
|
+
if (t && Object.prototype.hasOwnProperty.call(t, i))
|
|
61
60
|
return t[i];
|
|
62
|
-
},
|
|
63
|
-
const i =
|
|
64
|
-
return i !== void 0 ? i :
|
|
65
|
-
},
|
|
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) => {
|
|
66
65
|
for (const i in e)
|
|
67
|
-
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]);
|
|
68
67
|
return o;
|
|
69
|
-
},
|
|
68
|
+
}, V = (o) => o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
70
69
|
var De = {
|
|
71
70
|
"&": "&",
|
|
72
71
|
"<": "<",
|
|
@@ -75,7 +74,7 @@ var De = {
|
|
|
75
74
|
"'": "'",
|
|
76
75
|
"/": "/"
|
|
77
76
|
};
|
|
78
|
-
const
|
|
77
|
+
const Ve = (o) => g(o) ? o.replace(/[&<>"'\/]/g, (e) => De[e]) : o;
|
|
79
78
|
class Ae {
|
|
80
79
|
constructor(e) {
|
|
81
80
|
this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
|
|
@@ -88,21 +87,19 @@ class Ae {
|
|
|
88
87
|
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, i), this.regExpQueue.push(e), i;
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
|
-
const
|
|
90
|
+
const Ke = [" ", ",", "?", "!", ";"], Ue = new Ae(20), Me = (o, e, t) => {
|
|
92
91
|
e = e || "", t = t || "";
|
|
93
|
-
const i =
|
|
94
|
-
if (i.length === 0)
|
|
95
|
-
|
|
96
|
-
const s = Ke.getRegExp(`(${i.map((r) => r === "?" ? "\\?" : r).join("|")})`);
|
|
92
|
+
const i = Ke.filter((r) => e.indexOf(r) < 0 && t.indexOf(r) < 0);
|
|
93
|
+
if (i.length === 0) return !0;
|
|
94
|
+
const s = Ue.getRegExp(`(${i.map((r) => r === "?" ? "\\?" : r).join("|")})`);
|
|
97
95
|
let n = !s.test(o);
|
|
98
96
|
if (!n) {
|
|
99
97
|
const r = o.indexOf(t);
|
|
100
98
|
r > 0 && !s.test(o.substring(0, r)) && (n = !0);
|
|
101
99
|
}
|
|
102
100
|
return n;
|
|
103
|
-
},
|
|
104
|
-
if (!o)
|
|
105
|
-
return;
|
|
101
|
+
}, ee = (o, e, t = ".") => {
|
|
102
|
+
if (!o) return;
|
|
106
103
|
if (o[e])
|
|
107
104
|
return Object.prototype.hasOwnProperty.call(o, e) ? o[e] : void 0;
|
|
108
105
|
const i = e.split(t);
|
|
@@ -121,7 +118,7 @@ const Ve = [" ", ",", "?", "!", ";"], Ke = new Ae(20), Ue = (o, e, t) => {
|
|
|
121
118
|
s = r;
|
|
122
119
|
}
|
|
123
120
|
return s;
|
|
124
|
-
}, B = (o) => o == null ? void 0 : o.replace("_", "-"),
|
|
121
|
+
}, B = (o) => o == null ? void 0 : o.replace("_", "-"), He = {
|
|
125
122
|
type: "logger",
|
|
126
123
|
log(o) {
|
|
127
124
|
this.output("log", o);
|
|
@@ -137,12 +134,12 @@ const Ve = [" ", ",", "?", "!", ";"], Ke = new Ae(20), Ue = (o, e, t) => {
|
|
|
137
134
|
(i = (t = console == null ? void 0 : console[o]) == null ? void 0 : t.apply) == null || i.call(t, console, e);
|
|
138
135
|
}
|
|
139
136
|
};
|
|
140
|
-
class
|
|
137
|
+
class G {
|
|
141
138
|
constructor(e, t = {}) {
|
|
142
139
|
this.init(e, t);
|
|
143
140
|
}
|
|
144
141
|
init(e, t = {}) {
|
|
145
|
-
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;
|
|
146
143
|
}
|
|
147
144
|
log(...e) {
|
|
148
145
|
return this.forward(e, "log", "", !0);
|
|
@@ -160,16 +157,16 @@ class Q {
|
|
|
160
157
|
return s && !this.debug ? null : (g(e[0]) && (e[0] = `${i}${this.prefix} ${e[0]}`), this.logger[t](e));
|
|
161
158
|
}
|
|
162
159
|
create(e) {
|
|
163
|
-
return new
|
|
160
|
+
return new G(this.logger, p({
|
|
164
161
|
prefix: `${this.prefix}:${e}:`
|
|
165
162
|
}, this.options));
|
|
166
163
|
}
|
|
167
164
|
clone(e) {
|
|
168
|
-
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);
|
|
169
166
|
}
|
|
170
167
|
}
|
|
171
|
-
var
|
|
172
|
-
class
|
|
168
|
+
var F = new G();
|
|
169
|
+
class X {
|
|
173
170
|
constructor() {
|
|
174
171
|
this.observers = {};
|
|
175
172
|
}
|
|
@@ -181,7 +178,7 @@ class Z {
|
|
|
181
178
|
}), this;
|
|
182
179
|
}
|
|
183
180
|
off(e, t) {
|
|
184
|
-
if (
|
|
181
|
+
if (this.observers[e]) {
|
|
185
182
|
if (!t) {
|
|
186
183
|
delete this.observers[e];
|
|
187
184
|
return;
|
|
@@ -199,7 +196,7 @@ class Z {
|
|
|
199
196
|
});
|
|
200
197
|
}
|
|
201
198
|
}
|
|
202
|
-
class
|
|
199
|
+
class he extends X {
|
|
203
200
|
constructor(e, t = {
|
|
204
201
|
ns: ["translation"],
|
|
205
202
|
defaultNS: "translation"
|
|
@@ -218,15 +215,15 @@ class fe extends Z {
|
|
|
218
215
|
const n = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, r = s.ignoreJSONStructure !== void 0 ? s.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
219
216
|
let a;
|
|
220
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)));
|
|
221
|
-
const l =
|
|
222
|
-
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);
|
|
223
220
|
}
|
|
224
221
|
addResource(e, t, i, s, n = {
|
|
225
222
|
silent: !1
|
|
226
223
|
}) {
|
|
227
224
|
const r = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator;
|
|
228
225
|
let a = [e, t];
|
|
229
|
-
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);
|
|
230
227
|
}
|
|
231
228
|
addResources(e, t, i, s = {
|
|
232
229
|
silent: !1
|
|
@@ -243,8 +240,8 @@ class fe extends Z {
|
|
|
243
240
|
}) {
|
|
244
241
|
let a = [e, t];
|
|
245
242
|
e.indexOf(".") > -1 && (a = e.split("."), s = i, i = t, t = a[1]), this.addNamespaces(t);
|
|
246
|
-
let l =
|
|
247
|
-
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);
|
|
248
245
|
}
|
|
249
246
|
removeResourceBundle(e, t) {
|
|
250
247
|
this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
|
|
@@ -266,7 +263,7 @@ class fe extends Z {
|
|
|
266
263
|
return this.data;
|
|
267
264
|
}
|
|
268
265
|
}
|
|
269
|
-
var
|
|
266
|
+
var ve = {
|
|
270
267
|
processors: {},
|
|
271
268
|
addPostProcessor(o) {
|
|
272
269
|
this.processors[o.name] = o;
|
|
@@ -278,10 +275,10 @@ var we = {
|
|
|
278
275
|
}), e;
|
|
279
276
|
}
|
|
280
277
|
};
|
|
281
|
-
const
|
|
282
|
-
class
|
|
278
|
+
const ce = {}, de = (o) => !g(o) && typeof o != "boolean" && typeof o != "number";
|
|
279
|
+
class Z extends X {
|
|
283
280
|
constructor(e, t = {}) {
|
|
284
|
-
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");
|
|
285
282
|
}
|
|
286
283
|
changeLanguage(e) {
|
|
287
284
|
e && (this.language = e);
|
|
@@ -290,8 +287,7 @@ class G extends Z {
|
|
|
290
287
|
interpolation: {}
|
|
291
288
|
}) {
|
|
292
289
|
const i = p({}, t);
|
|
293
|
-
if (e == null)
|
|
294
|
-
return !1;
|
|
290
|
+
if (e == null) return !1;
|
|
295
291
|
const s = this.resolve(e, i);
|
|
296
292
|
return (s == null ? void 0 : s.res) !== void 0;
|
|
297
293
|
}
|
|
@@ -300,7 +296,7 @@ class G extends Z {
|
|
|
300
296
|
i === void 0 && (i = ":");
|
|
301
297
|
const s = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
|
|
302
298
|
let n = t.ns || this.options.defaultNS || [];
|
|
303
|
-
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);
|
|
304
300
|
if (r && !a) {
|
|
305
301
|
const l = e.match(this.interpolator.nestingRegexp);
|
|
306
302
|
if (l && l.length > 0)
|
|
@@ -318,8 +314,7 @@ class G extends Z {
|
|
|
318
314
|
}
|
|
319
315
|
translate(e, t, i) {
|
|
320
316
|
let s = typeof t == "object" ? p({}, t) : t;
|
|
321
|
-
if (typeof s != "object" && this.options.overloadTranslationOptionHandler && (s = this.options.overloadTranslationOptionHandler(arguments)), typeof options == "object" && (s = p({}, s)), s || (s = {}), e == null)
|
|
322
|
-
return "";
|
|
317
|
+
if (typeof s != "object" && this.options.overloadTranslationOptionHandler && (s = this.options.overloadTranslationOptionHandler(arguments)), typeof options == "object" && (s = p({}, s)), s || (s = {}), e == null) return "";
|
|
323
318
|
Array.isArray(e) || (e = [String(e)]);
|
|
324
319
|
const n = s.returnDetails !== void 0 ? s.returnDetails : this.options.returnDetails, r = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, {
|
|
325
320
|
key: a,
|
|
@@ -346,69 +341,68 @@ class G extends Z {
|
|
|
346
341
|
} : a;
|
|
347
342
|
const d = this.resolve(e, s);
|
|
348
343
|
let c = d == null ? void 0 : d.res;
|
|
349
|
-
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, {
|
|
350
345
|
ordinal: !1
|
|
351
|
-
}) : "", A = L && !s.ordinal && s.count === 0, w = A && s[`defaultValue${this.options.pluralSeparator}zero`] || s[`defaultValue${
|
|
346
|
+
}) : "", A = L && !s.ordinal && s.count === 0, w = A && s[`defaultValue${this.options.pluralSeparator}zero`] || s[`defaultValue${J}`] || s[`defaultValue${E}`] || s.defaultValue;
|
|
352
347
|
let b = c;
|
|
353
|
-
|
|
354
|
-
const Ce =
|
|
355
|
-
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))) {
|
|
356
351
|
if (!s.returnObjects && !this.options.returnObjects) {
|
|
357
352
|
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
358
|
-
const
|
|
353
|
+
const k = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(x, b, O(p({}, s), {
|
|
359
354
|
ns: l
|
|
360
355
|
})) : `key '${a} (${this.language})' returned an object instead of string.`;
|
|
361
|
-
return n ? (d.res =
|
|
356
|
+
return n ? (d.res = k, d.usedParams = this.getUsedParamsDetails(s), d) : k;
|
|
362
357
|
}
|
|
363
358
|
if (r) {
|
|
364
|
-
const
|
|
365
|
-
for (const
|
|
366
|
-
if (Object.prototype.hasOwnProperty.call(b,
|
|
367
|
-
const T = `${
|
|
368
|
-
|
|
369
|
-
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,
|
|
370
365
|
joinArrays: !1,
|
|
371
366
|
ns: l
|
|
372
|
-
})) :
|
|
367
|
+
})) : P[N] = this.translate(T, O(p({}, s), {
|
|
373
368
|
joinArrays: !1,
|
|
374
369
|
ns: l
|
|
375
|
-
})),
|
|
370
|
+
})), P[N] === T && (P[N] = b[N]);
|
|
376
371
|
}
|
|
377
|
-
c =
|
|
372
|
+
c = P;
|
|
378
373
|
}
|
|
379
|
-
} else if (
|
|
380
|
-
c = c.join(
|
|
374
|
+
} else if (I && g(C) && Array.isArray(c))
|
|
375
|
+
c = c.join(C), c && (c = this.extendTranslation(c, e, s, i));
|
|
381
376
|
else {
|
|
382
|
-
let
|
|
383
|
-
!this.isValidLookup(c) &&
|
|
384
|
-
const
|
|
385
|
-
if (
|
|
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) {
|
|
386
381
|
if (this.logger.log(T ? "updateKey" : "missingKey", f, u, a, T ? w : c), r) {
|
|
387
|
-
const
|
|
382
|
+
const v = this.resolve(a, O(p({}, s), {
|
|
388
383
|
keySeparator: !1
|
|
389
384
|
}));
|
|
390
|
-
|
|
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.");
|
|
391
386
|
}
|
|
392
|
-
let
|
|
393
|
-
const
|
|
394
|
-
if (this.options.saveMissingTo === "fallback" &&
|
|
395
|
-
for (let
|
|
396
|
-
|
|
397
|
-
else
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
this.options.missingKeyHandler ? this.options.missingKeyHandler(C, u, D, ie, T, s) : (se = this.backendConnector) != null && se.saveMissing && this.backendConnector.saveMissing(C, u, D, ie, T, s), this.emit("missingKey", C, u, D, c);
|
|
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);
|
|
403
397
|
};
|
|
404
|
-
this.options.saveMissing && (this.options.saveMissingPlurals && L ?
|
|
405
|
-
const D = this.pluralResolver.getSuffixes(
|
|
406
|
-
A && s[`defaultValue${this.options.pluralSeparator}zero`] && D.indexOf(`${this.options.pluralSeparator}zero`) < 0 && D.push(`${this.options.pluralSeparator}zero`), D.forEach((
|
|
407
|
-
|
|
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);
|
|
408
402
|
});
|
|
409
|
-
}) :
|
|
403
|
+
}) : ie(K, a, w));
|
|
410
404
|
}
|
|
411
|
-
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));
|
|
412
406
|
}
|
|
413
407
|
return n ? (d.res = c, d.usedParams = this.getUsedParamsDetails(s), d) : c;
|
|
414
408
|
}
|
|
@@ -436,7 +430,7 @@ class G extends Z {
|
|
|
436
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();
|
|
437
431
|
}
|
|
438
432
|
const r = i.postProcess || this.options.postProcess, a = g(r) ? [r] : r;
|
|
439
|
-
return e != null && (a
|
|
433
|
+
return e != null && (a != null && a.length) && i.applyPostProcessor !== !1 && (e = ve.handle(a, e, t, this.options && this.options.postProcessPassResolved ? p({
|
|
440
434
|
i18nResolved: O(p({}, s), {
|
|
441
435
|
usedParams: this.getUsedParamsDetails(i)
|
|
442
436
|
})
|
|
@@ -445,35 +439,33 @@ class G extends Z {
|
|
|
445
439
|
resolve(e, t = {}) {
|
|
446
440
|
let i, s, n, r, a;
|
|
447
441
|
return g(e) && (e = [e]), e.forEach((l) => {
|
|
448
|
-
if (this.isValidLookup(i))
|
|
449
|
-
return;
|
|
442
|
+
if (this.isValidLookup(i)) return;
|
|
450
443
|
const u = this.extractFromKey(l, t), h = u.key;
|
|
451
444
|
s = h;
|
|
452
445
|
let f = u.namespaces;
|
|
453
446
|
this.options.fallbackNS && (f = f.concat(this.options.fallbackNS));
|
|
454
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);
|
|
455
448
|
f.forEach((S) => {
|
|
456
|
-
var
|
|
457
|
-
this.isValidLookup(i) || (a = S, !
|
|
458
|
-
var
|
|
459
|
-
if (this.isValidLookup(i))
|
|
460
|
-
|
|
461
|
-
r = j;
|
|
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
|
+
if (this.isValidLookup(i)) return;
|
|
453
|
+
r = I;
|
|
462
454
|
const L = [h];
|
|
463
|
-
if ((
|
|
464
|
-
this.i18nFormat.addLookupKeys(L, h,
|
|
455
|
+
if ((J = this.i18nFormat) != null && J.addLookupKeys)
|
|
456
|
+
this.i18nFormat.addLookupKeys(L, h, I, S, t);
|
|
465
457
|
else {
|
|
466
|
-
let
|
|
467
|
-
m && (
|
|
458
|
+
let E;
|
|
459
|
+
m && (E = this.pluralResolver.getSuffix(I, t.count, t));
|
|
468
460
|
const A = `${this.options.pluralSeparator}zero`, w = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
469
|
-
if (m && (L.push(h +
|
|
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) {
|
|
470
462
|
const b = `${h}${this.options.contextSeparator}${t.context}`;
|
|
471
|
-
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));
|
|
472
464
|
}
|
|
473
465
|
}
|
|
474
|
-
let
|
|
475
|
-
for (;
|
|
476
|
-
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));
|
|
477
469
|
}));
|
|
478
470
|
});
|
|
479
471
|
}), {
|
|
@@ -509,19 +501,17 @@ class G extends Z {
|
|
|
509
501
|
return !1;
|
|
510
502
|
}
|
|
511
503
|
}
|
|
512
|
-
class
|
|
504
|
+
class pe {
|
|
513
505
|
constructor(e) {
|
|
514
|
-
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");
|
|
515
507
|
}
|
|
516
508
|
getScriptPartFromCode(e) {
|
|
517
|
-
if (e = B(e), !e || e.indexOf("-") < 0)
|
|
518
|
-
return null;
|
|
509
|
+
if (e = B(e), !e || e.indexOf("-") < 0) return null;
|
|
519
510
|
const t = e.split("-");
|
|
520
511
|
return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
|
|
521
512
|
}
|
|
522
513
|
getLanguagePartFromCode(e) {
|
|
523
|
-
if (e = B(e), !e || e.indexOf("-") < 0)
|
|
524
|
-
return e;
|
|
514
|
+
if (e = B(e), !e || e.indexOf("-") < 0) return e;
|
|
525
515
|
const t = e.split("-");
|
|
526
516
|
return this.formatLanguageCode(t[0]);
|
|
527
517
|
}
|
|
@@ -540,58 +530,49 @@ class de {
|
|
|
540
530
|
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
|
|
541
531
|
}
|
|
542
532
|
getBestMatchFromCodes(e) {
|
|
543
|
-
if (!e)
|
|
544
|
-
return null;
|
|
533
|
+
if (!e) return null;
|
|
545
534
|
let t;
|
|
546
535
|
return e.forEach((i) => {
|
|
547
|
-
if (t)
|
|
548
|
-
return;
|
|
536
|
+
if (t) return;
|
|
549
537
|
const s = this.formatLanguageCode(i);
|
|
550
538
|
(!this.options.supportedLngs || this.isSupportedCode(s)) && (t = s);
|
|
551
539
|
}), !t && this.options.supportedLngs && e.forEach((i) => {
|
|
552
|
-
if (t)
|
|
553
|
-
return;
|
|
540
|
+
if (t) return;
|
|
554
541
|
const s = this.getScriptPartFromCode(i);
|
|
555
|
-
if (this.isSupportedCode(s))
|
|
556
|
-
return t = s;
|
|
542
|
+
if (this.isSupportedCode(s)) return t = s;
|
|
557
543
|
const n = this.getLanguagePartFromCode(i);
|
|
558
|
-
if (this.isSupportedCode(n))
|
|
559
|
-
return t = n;
|
|
544
|
+
if (this.isSupportedCode(n)) return t = n;
|
|
560
545
|
t = this.options.supportedLngs.find((r) => {
|
|
561
|
-
if (r === n)
|
|
562
|
-
return r;
|
|
546
|
+
if (r === n) return r;
|
|
563
547
|
if (!(r.indexOf("-") < 0 && n.indexOf("-") < 0) && (r.indexOf("-") > 0 && n.indexOf("-") < 0 && r.substring(0, r.indexOf("-")) === n || r.indexOf(n) === 0 && n.length > 1))
|
|
564
548
|
return r;
|
|
565
549
|
});
|
|
566
550
|
}), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
|
|
567
551
|
}
|
|
568
552
|
getFallbackCodes(e, t) {
|
|
569
|
-
if (!e)
|
|
570
|
-
|
|
571
|
-
if (
|
|
572
|
-
return e;
|
|
573
|
-
if (!t)
|
|
574
|
-
return e.default || [];
|
|
553
|
+
if (!e) return [];
|
|
554
|
+
if (typeof e == "function" && (e = e(t)), g(e) && (e = [e]), Array.isArray(e)) return e;
|
|
555
|
+
if (!t) return e.default || [];
|
|
575
556
|
let i = e[t];
|
|
576
557
|
return i || (i = e[this.getScriptPartFromCode(t)]), i || (i = e[this.formatLanguageCode(t)]), i || (i = e[this.getLanguagePartFromCode(t)]), i || (i = e.default), i || [];
|
|
577
558
|
}
|
|
578
559
|
toResolveHierarchy(e, t) {
|
|
579
560
|
const i = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), s = [], n = (r) => {
|
|
580
|
-
|
|
561
|
+
r && (this.isSupportedCode(r) ? s.push(r) : this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`));
|
|
581
562
|
};
|
|
582
563
|
return g(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && n(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && n(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && n(this.getLanguagePartFromCode(e))) : g(e) && n(this.formatLanguageCode(e)), i.forEach((r) => {
|
|
583
564
|
s.indexOf(r) < 0 && n(this.formatLanguageCode(r));
|
|
584
565
|
}), s;
|
|
585
566
|
}
|
|
586
567
|
}
|
|
587
|
-
const
|
|
568
|
+
const ge = {
|
|
588
569
|
zero: 0,
|
|
589
570
|
one: 1,
|
|
590
571
|
two: 2,
|
|
591
572
|
few: 3,
|
|
592
573
|
many: 4,
|
|
593
574
|
other: 5
|
|
594
|
-
},
|
|
575
|
+
}, me = {
|
|
595
576
|
select: (o) => o === 1 ? "one" : "other",
|
|
596
577
|
resolvedOptions: () => ({
|
|
597
578
|
pluralCategories: ["one", "other"]
|
|
@@ -599,7 +580,7 @@ const pe = {
|
|
|
599
580
|
};
|
|
600
581
|
class Be {
|
|
601
582
|
constructor(e, t = {}) {
|
|
602
|
-
this.languageUtils = e, this.options = t, this.logger =
|
|
583
|
+
this.languageUtils = e, this.options = t, this.logger = F.create("pluralResolver"), this.pluralRulesCache = {};
|
|
603
584
|
}
|
|
604
585
|
addRule(e, t) {
|
|
605
586
|
this.rules[e] = t;
|
|
@@ -621,9 +602,8 @@ class Be {
|
|
|
621
602
|
});
|
|
622
603
|
} catch (a) {
|
|
623
604
|
if (!Intl)
|
|
624
|
-
return this.logger.error("No Intl support, please use an Intl polyfill!"),
|
|
625
|
-
if (!e.match(/-|_/))
|
|
626
|
-
return ge;
|
|
605
|
+
return this.logger.error("No Intl support, please use an Intl polyfill!"), me;
|
|
606
|
+
if (!e.match(/-|_/)) return me;
|
|
627
607
|
const l = this.languageUtils.getLanguagePartFromCode(e);
|
|
628
608
|
r = this.getRule(l, t);
|
|
629
609
|
}
|
|
@@ -638,21 +618,21 @@ class Be {
|
|
|
638
618
|
}
|
|
639
619
|
getSuffixes(e, t = {}) {
|
|
640
620
|
let i = this.getRule(e, t);
|
|
641
|
-
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}`) : [];
|
|
642
622
|
}
|
|
643
623
|
getSuffix(e, t, i = {}) {
|
|
644
624
|
const s = this.getRule(e, i);
|
|
645
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));
|
|
646
626
|
}
|
|
647
627
|
}
|
|
648
|
-
const
|
|
649
|
-
let n =
|
|
650
|
-
return !n && s && g(t) && (n =
|
|
651
|
-
},
|
|
652
|
-
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 {
|
|
653
633
|
constructor(e = {}) {
|
|
654
634
|
var t;
|
|
655
|
-
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);
|
|
656
636
|
}
|
|
657
637
|
init(e = {}) {
|
|
658
638
|
e.interpolation || (e.interpolation = {
|
|
@@ -674,10 +654,10 @@ class He {
|
|
|
674
654
|
nestingSuffix: c,
|
|
675
655
|
nestingSuffixEscaped: x,
|
|
676
656
|
nestingOptionsSeparator: S,
|
|
677
|
-
maxReplaces:
|
|
678
|
-
alwaysFormat:
|
|
657
|
+
maxReplaces: R,
|
|
658
|
+
alwaysFormat: C
|
|
679
659
|
} = e.interpolation;
|
|
680
|
-
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();
|
|
681
661
|
}
|
|
682
662
|
reset() {
|
|
683
663
|
this.options && this.init(this.options);
|
|
@@ -691,13 +671,13 @@ class He {
|
|
|
691
671
|
let n, r, a;
|
|
692
672
|
const l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (c) => {
|
|
693
673
|
if (c.indexOf(this.formatSeparator) < 0) {
|
|
694
|
-
const
|
|
695
|
-
return this.alwaysFormat ? this.format(
|
|
674
|
+
const C = xe(t, l, c, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
675
|
+
return this.alwaysFormat ? this.format(C, void 0, i, O(p(p({}, s), t), {
|
|
696
676
|
interpolationkey: c
|
|
697
|
-
})) :
|
|
677
|
+
})) : C;
|
|
698
678
|
}
|
|
699
|
-
const x = c.split(this.formatSeparator), S = x.shift().trim(),
|
|
700
|
-
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), {
|
|
701
681
|
interpolationkey: S
|
|
702
682
|
}));
|
|
703
683
|
};
|
|
@@ -705,17 +685,17 @@ class He {
|
|
|
705
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;
|
|
706
686
|
return [{
|
|
707
687
|
regex: this.regexpUnescape,
|
|
708
|
-
safeValue: (c) =>
|
|
688
|
+
safeValue: (c) => q(c)
|
|
709
689
|
}, {
|
|
710
690
|
regex: this.regexp,
|
|
711
|
-
safeValue: (c) => this.escapeValue ?
|
|
691
|
+
safeValue: (c) => this.escapeValue ? q(this.escape(c)) : q(c)
|
|
712
692
|
}].forEach((c) => {
|
|
713
693
|
for (a = 0; n = c.regex.exec(e); ) {
|
|
714
694
|
const x = n[1].trim();
|
|
715
695
|
if (r = u(x), r === void 0)
|
|
716
696
|
if (typeof h == "function") {
|
|
717
|
-
const
|
|
718
|
-
r = g(
|
|
697
|
+
const R = h(e, n, s);
|
|
698
|
+
r = g(R) ? R : "";
|
|
719
699
|
} else if (s && Object.prototype.hasOwnProperty.call(s, x))
|
|
720
700
|
r = "";
|
|
721
701
|
else if (f) {
|
|
@@ -723,8 +703,7 @@ class He {
|
|
|
723
703
|
continue;
|
|
724
704
|
} else
|
|
725
705
|
this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`), r = "";
|
|
726
|
-
else
|
|
727
|
-
!g(r) && !this.useRawValueToEscape && (r = ae(r));
|
|
706
|
+
else !g(r) && !this.useRawValueToEscape && (r = oe(r));
|
|
728
707
|
const S = c.safeValue(r);
|
|
729
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)
|
|
730
709
|
break;
|
|
@@ -736,8 +715,7 @@ class He {
|
|
|
736
715
|
const a = (l, u) => {
|
|
737
716
|
var x;
|
|
738
717
|
const h = this.nestingOptionsSeparator;
|
|
739
|
-
if (l.indexOf(h) < 0)
|
|
740
|
-
return l;
|
|
718
|
+
if (l.indexOf(h) < 0) return l;
|
|
741
719
|
const f = l.split(new RegExp(`${h}[ ]*{`));
|
|
742
720
|
let m = `{${f[1]}`;
|
|
743
721
|
l = f[0], m = this.interpolate(m, r);
|
|
@@ -754,16 +732,15 @@ class He {
|
|
|
754
732
|
let l = [];
|
|
755
733
|
r = p({}, i), r = r.replace && !g(r.replace) ? r.replace : r, r.applyPostProcessor = !1, delete r.defaultValue;
|
|
756
734
|
const u = /{.*}/.test(s[1]) ? s[1].lastIndexOf("}") + 1 : s[1].indexOf(this.formatSeparator);
|
|
757
|
-
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))
|
|
758
|
-
|
|
759
|
-
g(n) || (n = ae(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), {
|
|
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 = 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), {
|
|
760
737
|
interpolationkey: s[1].trim()
|
|
761
738
|
})), n.trim())), e = e.replace(s[0], n), this.regexp.lastIndex = 0;
|
|
762
739
|
}
|
|
763
740
|
return e;
|
|
764
741
|
}
|
|
765
742
|
}
|
|
766
|
-
const
|
|
743
|
+
const Je = (o) => {
|
|
767
744
|
let e = o.toLowerCase().trim();
|
|
768
745
|
const t = {};
|
|
769
746
|
if (o.indexOf("(") > -1) {
|
|
@@ -781,7 +758,7 @@ const ze = (o) => {
|
|
|
781
758
|
formatName: e,
|
|
782
759
|
formatOptions: t
|
|
783
760
|
};
|
|
784
|
-
},
|
|
761
|
+
}, ye = (o) => {
|
|
785
762
|
const e = {};
|
|
786
763
|
return (t, i, s) => {
|
|
787
764
|
let n = s;
|
|
@@ -792,16 +769,16 @@ const ze = (o) => {
|
|
|
792
769
|
let a = e[r];
|
|
793
770
|
return a || (a = o(B(i), s), e[r] = a), a(t);
|
|
794
771
|
};
|
|
795
|
-
},
|
|
796
|
-
class
|
|
772
|
+
}, We = (o) => (e, t, i) => o(B(t), i)(e);
|
|
773
|
+
class _e {
|
|
797
774
|
constructor(e = {}) {
|
|
798
|
-
this.logger =
|
|
775
|
+
this.logger = F.create("formatter"), this.options = e, this.init(e);
|
|
799
776
|
}
|
|
800
777
|
init(e, t = {
|
|
801
778
|
interpolation: {}
|
|
802
779
|
}) {
|
|
803
780
|
this.formatSeparator = t.interpolation.formatSeparator || ",";
|
|
804
|
-
const i = t.cacheInBuiltFormats ?
|
|
781
|
+
const i = t.cacheInBuiltFormats ? ye : We;
|
|
805
782
|
this.formats = {
|
|
806
783
|
number: i((s, n) => {
|
|
807
784
|
const r = new Intl.NumberFormat(s, p({}, n));
|
|
@@ -831,7 +808,7 @@ class We {
|
|
|
831
808
|
this.formats[e.toLowerCase().trim()] = t;
|
|
832
809
|
}
|
|
833
810
|
addCached(e, t) {
|
|
834
|
-
this.formats[e.toLowerCase().trim()] =
|
|
811
|
+
this.formats[e.toLowerCase().trim()] = ye(t);
|
|
835
812
|
}
|
|
836
813
|
format(e, t, i, s = {}) {
|
|
837
814
|
const n = t.split(this.formatSeparator);
|
|
@@ -844,7 +821,7 @@ class We {
|
|
|
844
821
|
const {
|
|
845
822
|
formatName: u,
|
|
846
823
|
formatOptions: h
|
|
847
|
-
} =
|
|
824
|
+
} = Je(l);
|
|
848
825
|
if (this.formats[u]) {
|
|
849
826
|
let m = a;
|
|
850
827
|
try {
|
|
@@ -860,13 +837,13 @@ class We {
|
|
|
860
837
|
}, e);
|
|
861
838
|
}
|
|
862
839
|
}
|
|
863
|
-
const
|
|
840
|
+
const Ye = (o, e) => {
|
|
864
841
|
o.pending[e] !== void 0 && (delete o.pending[e], o.pendingCount--);
|
|
865
842
|
};
|
|
866
|
-
class
|
|
843
|
+
class Qe extends X {
|
|
867
844
|
constructor(e, t, i, s = {}) {
|
|
868
845
|
var n, r;
|
|
869
|
-
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);
|
|
870
847
|
}
|
|
871
848
|
queueLoad(e, t, i, s) {
|
|
872
849
|
const n = {}, r = {}, a = {}, l = {};
|
|
@@ -896,7 +873,7 @@ class Ye extends Z {
|
|
|
896
873
|
}), this.state[e] = t ? -1 : 2, t && i && (this.state[e] = 0);
|
|
897
874
|
const a = {};
|
|
898
875
|
this.queue.forEach((l) => {
|
|
899
|
-
Te(l.loaded, [n], r),
|
|
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) => {
|
|
900
877
|
a[u] || (a[u] = {});
|
|
901
878
|
const h = l.loaded[u];
|
|
902
879
|
h.length && h.forEach((f) => {
|
|
@@ -906,8 +883,7 @@ class Ye extends Z {
|
|
|
906
883
|
}), this.emit("loaded", a), this.queue = this.queue.filter((l) => !l.done);
|
|
907
884
|
}
|
|
908
885
|
read(e, t, i, s = 0, n = this.retryTimeout, r) {
|
|
909
|
-
if (!e.length)
|
|
910
|
-
return r(null, {});
|
|
886
|
+
if (!e.length) return r(null, {});
|
|
911
887
|
if (this.readingCalls >= this.maxParallelReads) {
|
|
912
888
|
this.waitingReads.push({
|
|
913
889
|
lng: e,
|
|
@@ -972,7 +948,7 @@ class Ye extends Z {
|
|
|
972
948
|
saveMissing(e, t, i, s, n, r = {}, a = () => {
|
|
973
949
|
}) {
|
|
974
950
|
var l, u, h, f, m;
|
|
975
|
-
if ((
|
|
951
|
+
if ((u = (l = this.services) == null ? void 0 : l.utils) != null && u.hasLoadedNamespace && !((f = (h = this.services) == null ? void 0 : h.utils) != null && f.hasLoadedNamespace(t))) {
|
|
976
952
|
this.logger.warn(`did not save key "${i}" 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!!!");
|
|
977
953
|
return;
|
|
978
954
|
}
|
|
@@ -995,7 +971,7 @@ class Ye extends Z {
|
|
|
995
971
|
}
|
|
996
972
|
}
|
|
997
973
|
}
|
|
998
|
-
const
|
|
974
|
+
const Se = () => ({
|
|
999
975
|
debug: !1,
|
|
1000
976
|
initAsync: !0,
|
|
1001
977
|
ns: ["translation"],
|
|
@@ -1052,20 +1028,20 @@ const ye = () => ({
|
|
|
1052
1028
|
skipOnVariables: !0
|
|
1053
1029
|
},
|
|
1054
1030
|
cacheInBuiltFormats: !0
|
|
1055
|
-
}),
|
|
1031
|
+
}), be = (o) => {
|
|
1056
1032
|
var e, t;
|
|
1057
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;
|
|
1058
|
-
},
|
|
1059
|
-
},
|
|
1034
|
+
}, _ = () => {
|
|
1035
|
+
}, Ge = (o) => {
|
|
1060
1036
|
Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach((t) => {
|
|
1061
1037
|
typeof o[t] == "function" && (o[t] = o[t].bind(o));
|
|
1062
1038
|
});
|
|
1063
1039
|
};
|
|
1064
|
-
class
|
|
1040
|
+
class z extends X {
|
|
1065
1041
|
constructor(e = {}, t) {
|
|
1066
|
-
if (super(), this.options =
|
|
1042
|
+
if (super(), this.options = be(e), this.services = {}, this.logger = F, this.modules = {
|
|
1067
1043
|
external: []
|
|
1068
|
-
},
|
|
1044
|
+
}, Ge(this), t && !this.isInitialized && !e.isClone) {
|
|
1069
1045
|
if (!this.options.initAsync)
|
|
1070
1046
|
return this.init(e, t), this;
|
|
1071
1047
|
setTimeout(() => {
|
|
@@ -1075,30 +1051,30 @@ class H extends Z {
|
|
|
1075
1051
|
}
|
|
1076
1052
|
init(e = {}, t) {
|
|
1077
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]));
|
|
1078
|
-
const i =
|
|
1079
|
-
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);
|
|
1080
1056
|
const s = (u) => u ? typeof u == "function" ? new u() : u : null;
|
|
1081
1057
|
if (!this.options.isClone) {
|
|
1082
|
-
this.modules.logger ?
|
|
1058
|
+
this.modules.logger ? F.init(s(this.modules.logger), this.options) : F.init(null, this.options);
|
|
1083
1059
|
let u;
|
|
1084
|
-
this.modules.formatter ? u = this.modules.formatter : u =
|
|
1085
|
-
const h = new
|
|
1086
|
-
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);
|
|
1087
1063
|
const f = this.services;
|
|
1088
|
-
f.logger =
|
|
1064
|
+
f.logger = F, f.resourceStore = this.store, f.languageUtils = h, f.pluralResolver = new Be(h, {
|
|
1089
1065
|
prepend: this.options.pluralSeparator,
|
|
1090
1066
|
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1091
|
-
}), 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 = {
|
|
1092
1068
|
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
1093
|
-
}, f.backendConnector = new
|
|
1069
|
+
}, f.backendConnector = new Qe(s(this.modules.backend), f.resourceStore, f, this.options), f.backendConnector.on("*", (d, ...c) => {
|
|
1094
1070
|
this.emit(d, ...c);
|
|
1095
|
-
}), 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) => {
|
|
1096
1072
|
this.emit(d, ...c);
|
|
1097
1073
|
}), this.modules.external.forEach((d) => {
|
|
1098
1074
|
d.init && d.init(this);
|
|
1099
1075
|
});
|
|
1100
1076
|
}
|
|
1101
|
-
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) {
|
|
1102
1078
|
const u = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
1103
1079
|
u.length > 0 && u[0] !== "dev" && (this.options.lng = u[0]);
|
|
1104
1080
|
}
|
|
@@ -1107,26 +1083,23 @@ class H extends Z {
|
|
|
1107
1083
|
}), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((u) => {
|
|
1108
1084
|
this[u] = (...h) => (this.store[u](...h), this);
|
|
1109
1085
|
});
|
|
1110
|
-
const a =
|
|
1086
|
+
const a = M(), l = () => {
|
|
1111
1087
|
const u = (h, f) => {
|
|
1112
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);
|
|
1113
1089
|
};
|
|
1114
|
-
if (this.languages && !this.isInitialized)
|
|
1115
|
-
return u(null, this.t.bind(this));
|
|
1090
|
+
if (this.languages && !this.isInitialized) return u(null, this.t.bind(this));
|
|
1116
1091
|
this.changeLanguage(this.options.lng, u);
|
|
1117
1092
|
};
|
|
1118
1093
|
return this.options.resources || !this.options.initAsync ? l() : setTimeout(l, 0), a;
|
|
1119
1094
|
}
|
|
1120
|
-
loadResources(e, t =
|
|
1095
|
+
loadResources(e, t = _) {
|
|
1121
1096
|
var n, r;
|
|
1122
1097
|
let i = t;
|
|
1123
1098
|
const s = g(e) ? e : this.language;
|
|
1124
1099
|
if (typeof e == "function" && (i = e), !this.options.resources || this.options.partialBundledLanguages) {
|
|
1125
|
-
if ((s == null ? void 0 : s.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0))
|
|
1126
|
-
return i();
|
|
1100
|
+
if ((s == null ? void 0 : s.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return i();
|
|
1127
1101
|
const a = [], l = (u) => {
|
|
1128
|
-
if (!u || u === "cimode")
|
|
1129
|
-
return;
|
|
1102
|
+
if (!u || u === "cimode") return;
|
|
1130
1103
|
this.services.languageUtils.toResolveHierarchy(u).forEach((f) => {
|
|
1131
1104
|
f !== "cimode" && a.indexOf(f) < 0 && a.push(f);
|
|
1132
1105
|
});
|
|
@@ -1138,17 +1111,15 @@ class H extends Z {
|
|
|
1138
1111
|
i(null);
|
|
1139
1112
|
}
|
|
1140
1113
|
reloadResources(e, t, i) {
|
|
1141
|
-
const s =
|
|
1142
|
-
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) => {
|
|
1143
1116
|
s.resolve(), i(n);
|
|
1144
1117
|
}), s;
|
|
1145
1118
|
}
|
|
1146
1119
|
use(e) {
|
|
1147
|
-
if (!e)
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
|
|
1151
|
-
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" && we.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
|
|
1120
|
+
if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
|
|
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" && ve.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
|
|
1152
1123
|
}
|
|
1153
1124
|
setResolvedLanguage(e) {
|
|
1154
1125
|
if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
|
|
@@ -1164,7 +1135,7 @@ class H extends Z {
|
|
|
1164
1135
|
}
|
|
1165
1136
|
changeLanguage(e, t) {
|
|
1166
1137
|
this.isLanguageChangingTo = e;
|
|
1167
|
-
const i =
|
|
1138
|
+
const i = M();
|
|
1168
1139
|
this.emit("languageChanging", e);
|
|
1169
1140
|
const s = (a) => {
|
|
1170
1141
|
this.language = a, this.languages = this.services.languageUtils.toResolveHierarchy(a), this.resolvedLanguage = void 0, this.setResolvedLanguage(a);
|
|
@@ -1207,21 +1178,19 @@ class H extends Z {
|
|
|
1207
1178
|
if (!this.languages || !this.languages.length)
|
|
1208
1179
|
return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
|
|
1209
1180
|
const i = t.lng || this.resolvedLanguage || this.languages[0], s = this.options ? this.options.fallbackLng : !1, n = this.languages[this.languages.length - 1];
|
|
1210
|
-
if (i.toLowerCase() === "cimode")
|
|
1211
|
-
return !0;
|
|
1181
|
+
if (i.toLowerCase() === "cimode") return !0;
|
|
1212
1182
|
const r = (a, l) => {
|
|
1213
1183
|
const u = this.services.backendConnector.state[`${a}|${l}`];
|
|
1214
1184
|
return u === -1 || u === 0 || u === 2;
|
|
1215
1185
|
};
|
|
1216
1186
|
if (t.precheck) {
|
|
1217
1187
|
const a = t.precheck(this, r);
|
|
1218
|
-
if (a !== void 0)
|
|
1219
|
-
return a;
|
|
1188
|
+
if (a !== void 0) return a;
|
|
1220
1189
|
}
|
|
1221
1190
|
return !!(this.hasResourceBundle(i, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || r(i, e) && (!s || r(n, e)));
|
|
1222
1191
|
}
|
|
1223
1192
|
loadNamespaces(e, t) {
|
|
1224
|
-
const i =
|
|
1193
|
+
const i = M();
|
|
1225
1194
|
return this.options.ns ? (g(e) && (e = [e]), e.forEach((s) => {
|
|
1226
1195
|
this.options.ns.indexOf(s) < 0 && this.options.ns.push(s);
|
|
1227
1196
|
}), this.loadResources((s) => {
|
|
@@ -1229,7 +1198,7 @@ class H extends Z {
|
|
|
1229
1198
|
}), i) : (t && t(), Promise.resolve());
|
|
1230
1199
|
}
|
|
1231
1200
|
loadLanguages(e, t) {
|
|
1232
|
-
const i =
|
|
1201
|
+
const i = M();
|
|
1233
1202
|
g(e) && (e = [e]);
|
|
1234
1203
|
const s = this.options.preload || [], n = e.filter((r) => s.indexOf(r) < 0 && this.services.languageUtils.isSupportedCode(r));
|
|
1235
1204
|
return n.length ? (this.options.preload = s.concat(n), this.loadResources((r) => {
|
|
@@ -1238,38 +1207,36 @@ class H extends Z {
|
|
|
1238
1207
|
}
|
|
1239
1208
|
dir(e) {
|
|
1240
1209
|
var s, n;
|
|
1241
|
-
if (e || (e = this.resolvedLanguage || (((s = this.languages) == null ? void 0 : s.length) > 0 ? this.languages[0] : this.language)), !e)
|
|
1242
|
-
return "rtl";
|
|
1210
|
+
if (e || (e = this.resolvedLanguage || (((s = this.languages) == null ? void 0 : s.length) > 0 ? this.languages[0] : this.language)), !e) return "rtl";
|
|
1243
1211
|
try {
|
|
1244
1212
|
const r = new Intl.Locale(e);
|
|
1245
1213
|
if (r && r.getTextInfo) {
|
|
1246
1214
|
const a = r.getTextInfo();
|
|
1247
|
-
if (a && a.direction)
|
|
1248
|
-
return a.direction;
|
|
1215
|
+
if (a && a.direction) return a.direction;
|
|
1249
1216
|
}
|
|
1250
1217
|
} catch (r) {
|
|
1251
1218
|
}
|
|
1252
|
-
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());
|
|
1253
1220
|
return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(i.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
1254
1221
|
}
|
|
1255
1222
|
static createInstance(e = {}, t) {
|
|
1256
|
-
return new
|
|
1223
|
+
return new z(e, t);
|
|
1257
1224
|
}
|
|
1258
|
-
cloneInstance(e = {}, t =
|
|
1225
|
+
cloneInstance(e = {}, t = _) {
|
|
1259
1226
|
const i = e.forkResourceStore;
|
|
1260
1227
|
i && delete e.forkResourceStore;
|
|
1261
1228
|
const s = O(p(p({}, this.options), e), {
|
|
1262
1229
|
isClone: !0
|
|
1263
|
-
}), n = new
|
|
1230
|
+
}), n = new z(s);
|
|
1264
1231
|
if ((e.debug !== void 0 || e.prefix !== void 0) && (n.logger = n.logger.clone(e)), ["store", "services", "language"].forEach((a) => {
|
|
1265
1232
|
n[a] = this[a];
|
|
1266
1233
|
}), n.services = p({}, this.services), n.services.utils = {
|
|
1267
1234
|
hasLoadedNamespace: n.hasLoadedNamespace.bind(n)
|
|
1268
1235
|
}, i) {
|
|
1269
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), {});
|
|
1270
|
-
n.store = new
|
|
1237
|
+
n.store = new he(a, s), n.services.resourceStore = n.store;
|
|
1271
1238
|
}
|
|
1272
|
-
return n.translator = new
|
|
1239
|
+
return n.translator = new Z(n.services, s), n.translator.on("*", (a, ...l) => {
|
|
1273
1240
|
n.emit(a, ...l);
|
|
1274
1241
|
}), n.init(s, t), n.translator.options = s, n.translator.backendConnector.services.utils = {
|
|
1275
1242
|
hasLoadedNamespace: n.hasLoadedNamespace.bind(n)
|
|
@@ -1285,8 +1252,8 @@ class H extends Z {
|
|
|
1285
1252
|
};
|
|
1286
1253
|
}
|
|
1287
1254
|
}
|
|
1288
|
-
const y =
|
|
1289
|
-
y.createInstance =
|
|
1255
|
+
const y = z.createInstance();
|
|
1256
|
+
y.createInstance = z.createInstance;
|
|
1290
1257
|
y.createInstance;
|
|
1291
1258
|
y.dir;
|
|
1292
1259
|
y.init;
|
|
@@ -1301,11 +1268,11 @@ y.setDefaultNamespace;
|
|
|
1301
1268
|
y.hasLoadedNamespace;
|
|
1302
1269
|
y.loadNamespaces;
|
|
1303
1270
|
y.loadLanguages;
|
|
1304
|
-
const
|
|
1271
|
+
const Ze = (o, e) => {
|
|
1305
1272
|
for (const t of e) {
|
|
1306
1273
|
const i = o.find(t);
|
|
1307
1274
|
i && i.each((s, n) => {
|
|
1308
|
-
const r =
|
|
1275
|
+
const r = $(n);
|
|
1309
1276
|
if (r.attr("data-i18n"))
|
|
1310
1277
|
return;
|
|
1311
1278
|
const a = r.text().trim();
|
|
@@ -1320,11 +1287,11 @@ const Ge = (o, e) => {
|
|
|
1320
1287
|
}));
|
|
1321
1288
|
});
|
|
1322
1289
|
}
|
|
1323
|
-
},
|
|
1290
|
+
}, Y = (o) => {
|
|
1324
1291
|
for (const e of o) {
|
|
1325
|
-
const t =
|
|
1292
|
+
const t = $(e);
|
|
1326
1293
|
t && t.each((i, s) => {
|
|
1327
|
-
const n =
|
|
1294
|
+
const n = $(s);
|
|
1328
1295
|
if (n.attr("data-i18n"))
|
|
1329
1296
|
return;
|
|
1330
1297
|
const r = n.text().trim();
|
|
@@ -1339,8 +1306,8 @@ const Ge = (o, e) => {
|
|
|
1339
1306
|
}));
|
|
1340
1307
|
});
|
|
1341
1308
|
}
|
|
1342
|
-
},
|
|
1343
|
-
|
|
1309
|
+
}, Xe = (o, e) => {
|
|
1310
|
+
Ze(e, [
|
|
1344
1311
|
".hiprint-option-item-label",
|
|
1345
1312
|
"textarea",
|
|
1346
1313
|
"input",
|
|
@@ -1351,7 +1318,7 @@ const Ge = (o, e) => {
|
|
|
1351
1318
|
".hiprint-option-title",
|
|
1352
1319
|
".hiprint-option-item-desc"
|
|
1353
1320
|
]);
|
|
1354
|
-
},
|
|
1321
|
+
}, qe = () => {
|
|
1355
1322
|
document.querySelectorAll("[data-i18n]").forEach((o) => {
|
|
1356
1323
|
const e = o.getAttribute("data-i18n");
|
|
1357
1324
|
if (!e.includes("[")) {
|
|
@@ -1365,19 +1332,19 @@ const Ge = (o, e) => {
|
|
|
1365
1332
|
}
|
|
1366
1333
|
});
|
|
1367
1334
|
};
|
|
1368
|
-
let
|
|
1369
|
-
const
|
|
1370
|
-
if (
|
|
1335
|
+
let Le = !1;
|
|
1336
|
+
const Oe = (o) => {
|
|
1337
|
+
if (Le)
|
|
1371
1338
|
return;
|
|
1372
|
-
|
|
1339
|
+
Le = !0, globalThis.hiprint.i18next = y, globalThis.hiprint.t = y.t;
|
|
1373
1340
|
const e = Object.keys(o.resources || {});
|
|
1374
|
-
globalThis.hiprint.languages = ["
|
|
1341
|
+
globalThis.hiprint.languages = ["简体中文", ...e], globalThis.hiprint.changeLanguage = (t, i) => {
|
|
1375
1342
|
y.changeLanguage(t, (s, n) => {
|
|
1376
|
-
i && i(s, n),
|
|
1343
|
+
i && i(s, n), qe();
|
|
1377
1344
|
});
|
|
1378
1345
|
};
|
|
1379
1346
|
};
|
|
1380
|
-
function
|
|
1347
|
+
function tt(o, e) {
|
|
1381
1348
|
y.init(p({}, o), (i, s) => {
|
|
1382
1349
|
e && e(y, s, i);
|
|
1383
1350
|
});
|
|
@@ -1389,49 +1356,50 @@ function et(o, e) {
|
|
|
1389
1356
|
{
|
|
1390
1357
|
hook: "ready",
|
|
1391
1358
|
name: "i18n set",
|
|
1392
|
-
description: "
|
|
1359
|
+
description: "添加 i18n 方法",
|
|
1393
1360
|
priority: 1,
|
|
1394
1361
|
run: () => {
|
|
1395
|
-
|
|
1362
|
+
Oe(o);
|
|
1396
1363
|
}
|
|
1397
1364
|
},
|
|
1398
1365
|
{
|
|
1399
1366
|
hook: "getOptionItem",
|
|
1400
1367
|
name: "i18n options",
|
|
1401
|
-
description: "
|
|
1368
|
+
description: "渲染元素属性时做多语言处理",
|
|
1402
1369
|
priority: 1,
|
|
1403
1370
|
run: (i) => {
|
|
1404
1371
|
if (i) {
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
"data-name": i.name
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
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;
|
|
1413
1381
|
}
|
|
1414
1382
|
}
|
|
1415
1383
|
},
|
|
1416
1384
|
{
|
|
1417
1385
|
hook: "onDesigned",
|
|
1418
1386
|
name: "i18n other selector",
|
|
1419
|
-
description: "
|
|
1387
|
+
description: "其他UI选择器多语言处理",
|
|
1420
1388
|
priority: 1,
|
|
1421
1389
|
run: ({ hiprint: i, designerUtils: s }) => {
|
|
1422
1390
|
var a;
|
|
1423
|
-
|
|
1391
|
+
Oe(o);
|
|
1424
1392
|
const n = (a = s.printTemplate) == null ? void 0 : a.id;
|
|
1425
1393
|
n && (globalThis.hinnn.event.on("PrintElementSelectEventKey_" + n, (l) => {
|
|
1426
1394
|
setTimeout(() => {
|
|
1427
|
-
|
|
1395
|
+
Y([".printSetting .prop-tab-items .tab-title"]);
|
|
1428
1396
|
}, 0);
|
|
1429
|
-
}),
|
|
1430
|
-
|
|
1397
|
+
}), $(".hiprint-printPaper.design").on("contextmenu", () => {
|
|
1398
|
+
Y([
|
|
1431
1399
|
".hicontextmenu .hicontextmenuitem .title span",
|
|
1432
1400
|
".hicontextmenu .hicontextmenuitem .nav"
|
|
1433
1401
|
]);
|
|
1434
|
-
})),
|
|
1402
|
+
})), Y([
|
|
1435
1403
|
".svp-header p",
|
|
1436
1404
|
".svp-tools .tool-name",
|
|
1437
1405
|
".svp-dragbox .header span",
|
|
@@ -1443,11 +1411,11 @@ function et(o, e) {
|
|
|
1443
1411
|
{
|
|
1444
1412
|
hook: "onPreview",
|
|
1445
1413
|
name: "i18n preview selector",
|
|
1446
|
-
description: "
|
|
1414
|
+
description: "组件内预览选择器多语言处理",
|
|
1447
1415
|
priority: 1,
|
|
1448
1416
|
run: (i) => {
|
|
1449
1417
|
setTimeout(() => {
|
|
1450
|
-
|
|
1418
|
+
Y([".preview-bar button span", ".printer-list-txt"]);
|
|
1451
1419
|
}, 0);
|
|
1452
1420
|
}
|
|
1453
1421
|
}
|
|
@@ -1456,6 +1424,6 @@ function et(o, e) {
|
|
|
1456
1424
|
};
|
|
1457
1425
|
}
|
|
1458
1426
|
export {
|
|
1459
|
-
|
|
1460
|
-
|
|
1427
|
+
tt as default,
|
|
1428
|
+
Y as translateBySelector
|
|
1461
1429
|
};
|