@sv-print/plugin-i18n 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +446 -430
- package/dist/index.umd.js +1 -1
- package/dist/translate-option.d.ts +2 -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 Ne = Object.defineProperty, Fe = Object.defineProperties;
|
|
2
|
+
var Te = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var re = Object.getOwnPropertySymbols;
|
|
4
|
+
var Ee = Object.prototype.hasOwnProperty, je = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ae = (a, e, t) => e in a ? Ne(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, p = (a, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}, O = (
|
|
13
|
-
const g = (
|
|
14
|
-
let
|
|
7
|
+
Ee.call(e, t) && ae(a, t, e[t]);
|
|
8
|
+
if (re)
|
|
9
|
+
for (var t of re(e))
|
|
10
|
+
je.call(e, t) && ae(a, t, e[t]);
|
|
11
|
+
return a;
|
|
12
|
+
}, O = (a, e) => Fe(a, Te(e));
|
|
13
|
+
const g = (a) => typeof a == "string", M = () => {
|
|
14
|
+
let a, e;
|
|
15
15
|
const t = new Promise((i, s) => {
|
|
16
|
-
|
|
16
|
+
a = i, e = s;
|
|
17
17
|
});
|
|
18
|
-
return t.resolve =
|
|
19
|
-
},
|
|
20
|
-
|
|
18
|
+
return t.resolve = a, t.reject = e, t;
|
|
19
|
+
}, oe = (a) => a == null ? "" : "" + a, Ie = (a, e, t) => {
|
|
20
|
+
a.forEach((i) => {
|
|
21
21
|
e[i] && (t[i] = e[i]);
|
|
22
22
|
});
|
|
23
|
-
},
|
|
23
|
+
}, De = /###/g, le = (a) => a && a.indexOf("###") > -1 ? a.replace(De, ".") : a, ue = (a) => !a || g(a), B = (a, 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 =
|
|
29
|
-
!
|
|
27
|
+
if (ue(a)) return {};
|
|
28
|
+
const n = le(i[s]);
|
|
29
|
+
!a[n] && t && (a[n] = new t()), Object.prototype.hasOwnProperty.call(a, n) ? a = a[n] : a = {}, ++s;
|
|
30
30
|
}
|
|
31
|
-
return
|
|
32
|
-
obj:
|
|
33
|
-
k:
|
|
31
|
+
return ue(a) ? {} : {
|
|
32
|
+
obj: a,
|
|
33
|
+
k: le(i[s])
|
|
34
34
|
};
|
|
35
|
-
},
|
|
35
|
+
}, he = (a, e, t) => {
|
|
36
36
|
const {
|
|
37
37
|
obj: i,
|
|
38
38
|
k: s
|
|
39
|
-
} =
|
|
39
|
+
} = B(a, 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),
|
|
45
|
-
for (;
|
|
46
|
-
n = `${r[r.length - 1]}.${n}`, r = r.slice(0, r.length - 1),
|
|
47
|
-
|
|
48
|
-
},
|
|
44
|
+
let n = e[e.length - 1], r = e.slice(0, e.length - 1), o = B(a, r, Object);
|
|
45
|
+
for (; o.obj === void 0 && r.length; )
|
|
46
|
+
n = `${r[r.length - 1]}.${n}`, r = r.slice(0, r.length - 1), o = B(a, r, Object), o != null && o.obj && typeof o.obj[`${o.k}.${n}`] != "undefined" && (o.obj = void 0);
|
|
47
|
+
o.obj[`${o.k}.${n}`] = t;
|
|
48
|
+
}, Ve = (a, e, t, i) => {
|
|
49
49
|
const {
|
|
50
50
|
obj: s,
|
|
51
51
|
k: n
|
|
52
|
-
} =
|
|
52
|
+
} = B(a, e, Object);
|
|
53
53
|
s[n] = s[n] || [], s[n].push(t);
|
|
54
|
-
},
|
|
54
|
+
}, Q = (a, e) => {
|
|
55
55
|
const {
|
|
56
56
|
obj: t,
|
|
57
57
|
k: i
|
|
58
|
-
} =
|
|
58
|
+
} = B(a, 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
|
+
}, Ae = (a, e, t) => {
|
|
62
|
+
const i = Q(a, t);
|
|
63
|
+
return i !== void 0 ? i : Q(e, t);
|
|
64
|
+
}, ve = (a, e, t) => {
|
|
65
65
|
for (const i in e)
|
|
66
|
-
i !== "__proto__" && i !== "constructor" && (i in
|
|
67
|
-
return
|
|
68
|
-
},
|
|
69
|
-
var
|
|
66
|
+
i !== "__proto__" && i !== "constructor" && (i in a ? g(a[i]) || a[i] instanceof String || g(e[i]) || e[i] instanceof String ? t && (a[i] = e[i]) : ve(a[i], e[i], t) : a[i] = e[i]);
|
|
67
|
+
return a;
|
|
68
|
+
}, V = (a) => a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
69
|
+
var Ke = {
|
|
70
70
|
"&": "&",
|
|
71
71
|
"<": "<",
|
|
72
72
|
">": ">",
|
|
@@ -74,8 +74,8 @@ var Ie = {
|
|
|
74
74
|
"'": "'",
|
|
75
75
|
"/": "/"
|
|
76
76
|
};
|
|
77
|
-
const
|
|
78
|
-
class
|
|
77
|
+
const Ue = (a) => g(a) ? a.replace(/[&<>"'\/]/g, (e) => Ke[e]) : a;
|
|
78
|
+
class Me {
|
|
79
79
|
constructor(e) {
|
|
80
80
|
this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
|
|
81
81
|
}
|
|
@@ -87,29 +87,29 @@ 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 He = [" ", ",", "?", "!", ";"], Be = new Me(20), ze = (a, e, t) => {
|
|
91
91
|
e = e || "", t = t || "";
|
|
92
|
-
const i =
|
|
92
|
+
const i = He.filter((r) => e.indexOf(r) < 0 && t.indexOf(r) < 0);
|
|
93
93
|
if (i.length === 0) return !0;
|
|
94
|
-
const s =
|
|
95
|
-
let n = !s.test(
|
|
94
|
+
const s = Be.getRegExp(`(${i.map((r) => r === "?" ? "\\?" : r).join("|")})`);
|
|
95
|
+
let n = !s.test(a);
|
|
96
96
|
if (!n) {
|
|
97
|
-
const r =
|
|
98
|
-
r > 0 && !s.test(
|
|
97
|
+
const r = a.indexOf(t);
|
|
98
|
+
r > 0 && !s.test(a.substring(0, r)) && (n = !0);
|
|
99
99
|
}
|
|
100
100
|
return n;
|
|
101
|
-
},
|
|
102
|
-
if (!
|
|
103
|
-
if (
|
|
104
|
-
return Object.prototype.hasOwnProperty.call(
|
|
101
|
+
}, ee = (a, e, t = ".") => {
|
|
102
|
+
if (!a) return;
|
|
103
|
+
if (a[e])
|
|
104
|
+
return Object.prototype.hasOwnProperty.call(a, e) ? a[e] : void 0;
|
|
105
105
|
const i = e.split(t);
|
|
106
|
-
let s =
|
|
106
|
+
let s = a;
|
|
107
107
|
for (let n = 0; n < i.length; ) {
|
|
108
108
|
if (!s || typeof s != "object")
|
|
109
109
|
return;
|
|
110
|
-
let r,
|
|
110
|
+
let r, o = "";
|
|
111
111
|
for (let l = n; l < i.length; ++l)
|
|
112
|
-
if (l !== n && (
|
|
112
|
+
if (l !== n && (o += t), o += i[l], r = s[o], r !== void 0) {
|
|
113
113
|
if (["string", "number", "boolean"].indexOf(typeof r) > -1 && l < i.length - 1)
|
|
114
114
|
continue;
|
|
115
115
|
n += l - n + 1;
|
|
@@ -118,28 +118,28 @@ const Ae = [" ", ",", "?", "!", ";"], Ke = new Ve(20), Ue = (o, e, t) => {
|
|
|
118
118
|
s = r;
|
|
119
119
|
}
|
|
120
120
|
return s;
|
|
121
|
-
},
|
|
121
|
+
}, z = (a) => a == null ? void 0 : a.replace("_", "-"), Je = {
|
|
122
122
|
type: "logger",
|
|
123
|
-
log(
|
|
124
|
-
this.output("log",
|
|
123
|
+
log(a) {
|
|
124
|
+
this.output("log", a);
|
|
125
125
|
},
|
|
126
|
-
warn(
|
|
127
|
-
this.output("warn",
|
|
126
|
+
warn(a) {
|
|
127
|
+
this.output("warn", a);
|
|
128
128
|
},
|
|
129
|
-
error(
|
|
130
|
-
this.output("error",
|
|
129
|
+
error(a) {
|
|
130
|
+
this.output("error", a);
|
|
131
131
|
},
|
|
132
|
-
output(
|
|
132
|
+
output(a, e) {
|
|
133
133
|
var t, i;
|
|
134
|
-
(i = (t = console == null ? void 0 : console[
|
|
134
|
+
(i = (t = console == null ? void 0 : console[a]) == 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 || Je, 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 fe extends
|
|
199
|
+
class fe extends X {
|
|
200
200
|
constructor(e, t = {
|
|
201
201
|
ns: ["translation"],
|
|
202
202
|
defaultNS: "translation"
|
|
@@ -211,19 +211,19 @@ class fe extends Z {
|
|
|
211
211
|
t > -1 && this.options.ns.splice(t, 1);
|
|
212
212
|
}
|
|
213
213
|
getResource(e, t, i, s = {}) {
|
|
214
|
-
var u,
|
|
214
|
+
var u, f;
|
|
215
215
|
const n = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, r = s.ignoreJSONStructure !== void 0 ? s.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
216
|
-
let
|
|
217
|
-
e.indexOf(".") > -1 ?
|
|
218
|
-
const l =
|
|
219
|
-
return !l && !t && !i && e.indexOf(".") > -1 && (e =
|
|
216
|
+
let o;
|
|
217
|
+
e.indexOf(".") > -1 ? o = e.split(".") : (o = [e, t], i && (Array.isArray(i) ? o.push(...i) : g(i) && n ? o.push(...i.split(n)) : o.push(i)));
|
|
218
|
+
const l = Q(this.data, o);
|
|
219
|
+
return !l && !t && !i && e.indexOf(".") > -1 && (e = o[0], t = o[1], i = o.slice(2).join(".")), l || !r || !g(i) ? l : ee((f = (u = this.data) == null ? void 0 : u[e]) == null ? void 0 : f[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
|
-
let
|
|
226
|
-
i && (
|
|
225
|
+
let o = [e, t];
|
|
226
|
+
i && (o = o.concat(r ? i.split(r) : i)), e.indexOf(".") > -1 && (o = e.split("."), s = t, t = o[1]), this.addNamespaces(t), he(this.data, o, s), n.silent || this.emit("added", e, t, i, s);
|
|
227
227
|
}
|
|
228
228
|
addResources(e, t, i, s = {
|
|
229
229
|
silent: !1
|
|
@@ -238,10 +238,10 @@ class fe extends Z {
|
|
|
238
238
|
silent: !1,
|
|
239
239
|
skipCopy: !1
|
|
240
240
|
}) {
|
|
241
|
-
let
|
|
242
|
-
e.indexOf(".") > -1 && (
|
|
243
|
-
let l =
|
|
244
|
-
r.skipCopy || (i = JSON.parse(JSON.stringify(i))), s ?
|
|
241
|
+
let o = [e, t];
|
|
242
|
+
e.indexOf(".") > -1 && (o = e.split("."), s = i, i = t, t = o[1]), this.addNamespaces(t);
|
|
243
|
+
let l = Q(this.data, o) || {};
|
|
244
|
+
r.skipCopy || (i = JSON.parse(JSON.stringify(i))), s ? ve(l, i, n) : l = p(p({}, l), i), he(this.data, o, 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,22 +263,22 @@ class fe extends Z {
|
|
|
263
263
|
return this.data;
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
var
|
|
266
|
+
var Ce = {
|
|
267
267
|
processors: {},
|
|
268
|
-
addPostProcessor(
|
|
269
|
-
this.processors[
|
|
268
|
+
addPostProcessor(a) {
|
|
269
|
+
this.processors[a.name] = a;
|
|
270
270
|
},
|
|
271
|
-
handle(
|
|
272
|
-
return
|
|
273
|
-
var r,
|
|
274
|
-
e = (
|
|
271
|
+
handle(a, e, t, i, s) {
|
|
272
|
+
return a.forEach((n) => {
|
|
273
|
+
var r, o;
|
|
274
|
+
e = (o = (r = this.processors[n]) == null ? void 0 : r.process(e, t, i, s)) != null ? o : e;
|
|
275
275
|
}), e;
|
|
276
276
|
}
|
|
277
277
|
};
|
|
278
|
-
const
|
|
279
|
-
class
|
|
278
|
+
const ce = {}, de = (a) => !g(a) && typeof a != "boolean" && typeof a != "number";
|
|
279
|
+
class Z extends X {
|
|
280
280
|
constructor(e, t = {}) {
|
|
281
|
-
super(),
|
|
281
|
+
super(), Ie(["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,8 +296,8 @@ 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,
|
|
300
|
-
if (r && !
|
|
299
|
+
const r = i && e.indexOf(i) > -1, o = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !ze(e, i, s);
|
|
300
|
+
if (r && !o) {
|
|
301
301
|
const l = e.match(this.interpolator.nestingRegexp);
|
|
302
302
|
if (l && l.length > 0)
|
|
303
303
|
return {
|
|
@@ -317,92 +317,92 @@ class G extends Z {
|
|
|
317
317
|
if (typeof s != "object" && this.options.overloadTranslationOptionHandler && (s = this.options.overloadTranslationOptionHandler(arguments)), typeof options == "object" && (s = p({}, s)), s || (s = {}), e == null) return "";
|
|
318
318
|
Array.isArray(e) || (e = [String(e)]);
|
|
319
319
|
const n = s.returnDetails !== void 0 ? s.returnDetails : this.options.returnDetails, r = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, {
|
|
320
|
-
key:
|
|
320
|
+
key: o,
|
|
321
321
|
namespaces: l
|
|
322
322
|
} = this.extractFromKey(e[e.length - 1], s), u = l[l.length - 1];
|
|
323
|
-
let
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
if ((
|
|
323
|
+
let f = s.nsSeparator !== void 0 ? s.nsSeparator : this.options.nsSeparator;
|
|
324
|
+
f === void 0 && (f = ":");
|
|
325
|
+
const h = s.lng || this.language, m = s.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
326
|
+
if ((h == null ? void 0 : h.toLowerCase()) === "cimode")
|
|
327
327
|
return m ? n ? {
|
|
328
|
-
res: `${u}${
|
|
329
|
-
usedKey:
|
|
330
|
-
exactUsedKey:
|
|
331
|
-
usedLng:
|
|
328
|
+
res: `${u}${f}${o}`,
|
|
329
|
+
usedKey: o,
|
|
330
|
+
exactUsedKey: o,
|
|
331
|
+
usedLng: h,
|
|
332
332
|
usedNS: u,
|
|
333
333
|
usedParams: this.getUsedParamsDetails(s)
|
|
334
|
-
} : `${u}${
|
|
335
|
-
res:
|
|
336
|
-
usedKey:
|
|
337
|
-
exactUsedKey:
|
|
338
|
-
usedLng:
|
|
334
|
+
} : `${u}${f}${o}` : n ? {
|
|
335
|
+
res: o,
|
|
336
|
+
usedKey: o,
|
|
337
|
+
exactUsedKey: o,
|
|
338
|
+
usedLng: h,
|
|
339
339
|
usedNS: u,
|
|
340
340
|
usedParams: this.getUsedParamsDetails(s)
|
|
341
|
-
} :
|
|
341
|
+
} : o;
|
|
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) ||
|
|
344
|
+
const x = (d == null ? void 0 : d.usedKey) || o, S = (d == null ? void 0 : d.exactUsedKey) || o, P = ["[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), T = Z.hasDefaultValue(s), _ = L ? this.pluralResolver.getSuffix(h, s.count, s) : "", E = s.ordinal && L ? this.pluralResolver.getSuffix(h, 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${_}`] || s[`defaultValue${E}`] || s.defaultValue;
|
|
347
347
|
let b = c;
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
if (
|
|
348
|
+
I && !c && T && (b = w);
|
|
349
|
+
const Re = de(b), ke = Object.prototype.toString.apply(b);
|
|
350
|
+
if (I && b && Re && P.indexOf(ke) < 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
|
-
})) : `key '${
|
|
356
|
-
return n ? (d.res =
|
|
355
|
+
})) : `key '${o} (${this.language})' returned an object instead of string.`;
|
|
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 j = `${
|
|
363
|
-
|
|
364
|
-
defaultValue:
|
|
359
|
+
const k = Array.isArray(b), R = k ? [] : {}, te = k ? S : x;
|
|
360
|
+
for (const N in b)
|
|
361
|
+
if (Object.prototype.hasOwnProperty.call(b, N)) {
|
|
362
|
+
const j = `${te}${r}${N}`;
|
|
363
|
+
T && !c ? R[N] = this.translate(j, O(p({}, s), {
|
|
364
|
+
defaultValue: de(w) ? w[N] : void 0,
|
|
365
365
|
joinArrays: !1,
|
|
366
366
|
ns: l
|
|
367
|
-
})) : R[
|
|
367
|
+
})) : R[N] = this.translate(j, O(p({}, s), {
|
|
368
368
|
joinArrays: !1,
|
|
369
369
|
ns: l
|
|
370
|
-
})), R[
|
|
370
|
+
})), R[N] === j && (R[N] = b[N]);
|
|
371
371
|
}
|
|
372
372
|
c = R;
|
|
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 (R ||
|
|
381
|
-
if (this.logger.log(j ? "updateKey" : "missingKey",
|
|
382
|
-
const v = this.resolve(
|
|
377
|
+
let k = !1, R = !1;
|
|
378
|
+
!this.isValidLookup(c) && T && (k = !0, c = w), this.isValidLookup(c) || (R = !0, c = o);
|
|
379
|
+
const N = (s.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && R ? void 0 : c, j = T && w !== c && this.options.updateMissing;
|
|
380
|
+
if (R || k || j) {
|
|
381
|
+
if (this.logger.log(j ? "updateKey" : "missingKey", h, u, o, j ? w : c), r) {
|
|
382
|
+
const v = this.resolve(o, 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 = T && U !== c ? U : N;
|
|
396
|
+
this.options.missingKeyHandler ? this.options.missingKeyHandler(v, u, D, se, j, s) : (ne = this.backendConnector) != null && ne.saveMissing && this.backendConnector.saveMissing(v, u, D, se, j, 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], o + U, s[`defaultValue${U}`] || w);
|
|
402
402
|
});
|
|
403
|
-
}) :
|
|
403
|
+
}) : ie(K, o, w));
|
|
404
404
|
}
|
|
405
|
-
c = this.extendTranslation(c, e, s, d, i), R && c ===
|
|
405
|
+
c = this.extendTranslation(c, e, s, d, i), R && c === o && this.options.appendNamespaceToMissingKey && (c = `${u}${f}${o}`), (R || k) && this.options.parseMissingKeyHandler && (c = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${u}${f}${o}` : o, k ? c : void 0, s));
|
|
406
406
|
}
|
|
407
407
|
return n ? (d.res = c, d.usedParams = this.getUsedParamsDetails(s), d) : c;
|
|
408
408
|
}
|
|
@@ -416,56 +416,56 @@ class G extends Z {
|
|
|
416
416
|
i.interpolation && this.interpolator.init(O(p({}, i), {
|
|
417
417
|
interpolation: p(p({}, this.options.interpolation), i.interpolation)
|
|
418
418
|
}));
|
|
419
|
-
const
|
|
420
|
-
let
|
|
421
|
-
if (
|
|
419
|
+
const f = g(e) && (((u = i == null ? void 0 : i.interpolation) == null ? void 0 : u.skipOnVariables) !== void 0 ? i.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
420
|
+
let h;
|
|
421
|
+
if (f) {
|
|
422
422
|
const d = e.match(this.interpolator.nestingRegexp);
|
|
423
|
-
|
|
423
|
+
h = d && d.length;
|
|
424
424
|
}
|
|
425
425
|
let m = i.replace && !g(i.replace) ? i.replace : i;
|
|
426
|
-
if (this.options.interpolation.defaultVariables && (m = p(p({}, this.options.interpolation.defaultVariables), m)), e = this.interpolator.interpolate(e, m, i.lng || this.language || s.usedLng, i),
|
|
426
|
+
if (this.options.interpolation.defaultVariables && (m = p(p({}, this.options.interpolation.defaultVariables), m)), e = this.interpolator.interpolate(e, m, i.lng || this.language || s.usedLng, i), f) {
|
|
427
427
|
const d = e.match(this.interpolator.nestingRegexp), c = d && d.length;
|
|
428
|
-
|
|
428
|
+
h < c && (i.nest = !1);
|
|
429
429
|
}
|
|
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
|
-
const r = i.postProcess || this.options.postProcess,
|
|
433
|
-
return e != null && (
|
|
432
|
+
const r = i.postProcess || this.options.postProcess, o = g(r) ? [r] : r;
|
|
433
|
+
return e != null && (o != null && o.length) && i.applyPostProcessor !== !1 && (e = Ce.handle(o, e, t, this.options && this.options.postProcessPassResolved ? p({
|
|
434
434
|
i18nResolved: O(p({}, s), {
|
|
435
435
|
usedParams: this.getUsedParamsDetails(i)
|
|
436
436
|
})
|
|
437
437
|
}, i) : i, this)), e;
|
|
438
438
|
}
|
|
439
439
|
resolve(e, t = {}) {
|
|
440
|
-
let i, s, n, r,
|
|
440
|
+
let i, s, n, r, o;
|
|
441
441
|
return g(e) && (e = [e]), e.forEach((l) => {
|
|
442
442
|
if (this.isValidLookup(i)) return;
|
|
443
|
-
const u = this.extractFromKey(l, t),
|
|
444
|
-
s =
|
|
445
|
-
let
|
|
446
|
-
this.options.fallbackNS && (
|
|
443
|
+
const u = this.extractFromKey(l, t), f = u.key;
|
|
444
|
+
s = f;
|
|
445
|
+
let h = u.namespaces;
|
|
446
|
+
this.options.fallbackNS && (h = h.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
|
-
|
|
449
|
-
var
|
|
450
|
-
this.isValidLookup(i) || (
|
|
451
|
-
var
|
|
448
|
+
h.forEach((S) => {
|
|
449
|
+
var P, C;
|
|
450
|
+
this.isValidLookup(i) || (o = S, !ce[`${x[0]}-${S}`] && ((P = this.utils) != null && P.hasLoadedNamespace) && !((C = this.utils) != null && C.hasLoadedNamespace(o)) && (ce[`${x[0]}-${S}`] = !0, this.logger.warn(`key "${s}" for languages "${x.join(", ")}" won't get resolved as namespace "${o}" 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 _;
|
|
452
452
|
if (this.isValidLookup(i)) return;
|
|
453
|
-
r =
|
|
454
|
-
const L = [
|
|
455
|
-
if ((
|
|
456
|
-
this.i18nFormat.addLookupKeys(L,
|
|
453
|
+
r = I;
|
|
454
|
+
const L = [f];
|
|
455
|
+
if ((_ = this.i18nFormat) != null && _.addLookupKeys)
|
|
456
|
+
this.i18nFormat.addLookupKeys(L, f, I, S, t);
|
|
457
457
|
else {
|
|
458
|
-
let
|
|
459
|
-
m && (
|
|
460
|
-
const
|
|
461
|
-
if (m && (L.push(
|
|
462
|
-
const b = `${
|
|
463
|
-
L.push(b), m && (L.push(b +
|
|
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(f + E), t.ordinal && E.indexOf(w) === 0 && L.push(f + E.replace(w, this.options.pluralSeparator)), d && L.push(f + A)), c) {
|
|
462
|
+
const b = `${f}${this.options.contextSeparator}${t.context}`;
|
|
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 T;
|
|
467
|
+
for (; T = L.pop(); )
|
|
468
|
+
this.isValidLookup(i) || (n = T, i = this.getResource(I, S, T, t));
|
|
469
469
|
}));
|
|
470
470
|
});
|
|
471
471
|
}), {
|
|
@@ -473,7 +473,7 @@ class G extends Z {
|
|
|
473
473
|
usedKey: s,
|
|
474
474
|
exactUsedKey: n,
|
|
475
475
|
usedLng: r,
|
|
476
|
-
usedNS:
|
|
476
|
+
usedNS: o
|
|
477
477
|
};
|
|
478
478
|
}
|
|
479
479
|
isValidLookup(e) {
|
|
@@ -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 = z(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 = z(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
|
-
},
|
|
576
|
-
select: (
|
|
575
|
+
}, me = {
|
|
576
|
+
select: (a) => a === 1 ? "one" : "other",
|
|
577
577
|
resolvedOptions: () => ({
|
|
578
578
|
pluralCategories: ["one", "other"]
|
|
579
579
|
})
|
|
580
580
|
};
|
|
581
|
-
class
|
|
581
|
+
class _e {
|
|
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 = z(e === "dev" ? "en" : e), s = t.ordinal ? "ordinal" : "cardinal", n = JSON.stringify({
|
|
593
593
|
cleanedCode: i,
|
|
594
594
|
type: s
|
|
595
595
|
});
|
|
@@ -600,10 +600,10 @@ class He {
|
|
|
600
600
|
r = new Intl.PluralRules(i, {
|
|
601
601
|
type: s
|
|
602
602
|
});
|
|
603
|
-
} catch (
|
|
603
|
+
} catch (o) {
|
|
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 = (a, e, t, i = ".", s = !0) => {
|
|
629
|
+
let n = Ae(a, e, t);
|
|
630
|
+
return !n && s && g(t) && (n = ee(a, t, i), n === void 0 && (n = ee(e, t, i))), n;
|
|
631
|
+
}, q = (a) => a.replace(/\$/g, "$$$$");
|
|
632
|
+
class We {
|
|
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 = {
|
|
@@ -644,20 +644,20 @@ class Be {
|
|
|
644
644
|
useRawValueToEscape: s,
|
|
645
645
|
prefix: n,
|
|
646
646
|
prefixEscaped: r,
|
|
647
|
-
suffix:
|
|
647
|
+
suffix: o,
|
|
648
648
|
suffixEscaped: l,
|
|
649
649
|
formatSeparator: u,
|
|
650
|
-
unescapeSuffix:
|
|
651
|
-
unescapePrefix:
|
|
650
|
+
unescapeSuffix: f,
|
|
651
|
+
unescapePrefix: h,
|
|
652
652
|
nestingPrefix: m,
|
|
653
653
|
nestingPrefixEscaped: d,
|
|
654
654
|
nestingSuffix: c,
|
|
655
655
|
nestingSuffixEscaped: x,
|
|
656
656
|
nestingOptionsSeparator: S,
|
|
657
|
-
maxReplaces:
|
|
657
|
+
maxReplaces: P,
|
|
658
658
|
alwaysFormat: C
|
|
659
659
|
} = e.interpolation;
|
|
660
|
-
this.escape = t !== void 0 ? t :
|
|
660
|
+
this.escape = t !== void 0 ? t : Ue, this.escapeValue = i !== void 0 ? i : !0, this.useRawValueToEscape = s !== void 0 ? s : !1, this.prefix = n ? V(n) : r || "{{", this.suffix = o ? V(o) : l || "}}", this.formatSeparator = u || ",", this.unescapePrefix = f ? "" : h || "-", this.unescapeSuffix = this.unescapePrefix ? "" : f || "", this.nestingPrefix = m ? V(m) : d || V("$t("), this.nestingSuffix = c ? V(c) : x || V(")"), this.nestingOptionsSeparator = S || ",", this.maxReplaces = P || 1e3, this.alwaysFormat = C !== void 0 ? C : !1, this.resetRegExp();
|
|
661
661
|
}
|
|
662
662
|
reset() {
|
|
663
663
|
this.options && this.init(this.options);
|
|
@@ -668,63 +668,63 @@ class Be {
|
|
|
668
668
|
}
|
|
669
669
|
interpolate(e, t, i, s) {
|
|
670
670
|
var d;
|
|
671
|
-
let n, r,
|
|
671
|
+
let n, r, o;
|
|
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(), P = x.join(this.formatSeparator).trim();
|
|
680
|
+
return this.format(xe(t, l, S, this.options.keySeparator, this.options.ignoreJSONStructure), P, i, O(p(p({}, s), t), {
|
|
681
681
|
interpolationkey: S
|
|
682
682
|
}));
|
|
683
683
|
};
|
|
684
684
|
this.resetRegExp();
|
|
685
|
-
const
|
|
685
|
+
const f = (s == null ? void 0 : s.missingInterpolationHandler) || this.options.missingInterpolationHandler, h = ((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
|
-
for (
|
|
693
|
+
for (o = 0; n = c.regex.exec(e); ) {
|
|
694
694
|
const x = n[1].trim();
|
|
695
695
|
if (r = u(x), r === void 0)
|
|
696
|
-
if (typeof
|
|
697
|
-
const
|
|
698
|
-
r = g(
|
|
696
|
+
if (typeof f == "function") {
|
|
697
|
+
const P = f(e, n, s);
|
|
698
|
+
r = g(P) ? P : "";
|
|
699
699
|
} else if (s && Object.prototype.hasOwnProperty.call(s, x))
|
|
700
700
|
r = "";
|
|
701
|
-
else if (
|
|
701
|
+
else if (h) {
|
|
702
702
|
r = n[0];
|
|
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
|
-
if (e = e.replace(n[0], S),
|
|
708
|
+
if (e = e.replace(n[0], S), h ? (c.regex.lastIndex += r.length, c.regex.lastIndex -= n[0].length) : c.regex.lastIndex = 0, o++, o >= this.maxReplaces)
|
|
709
709
|
break;
|
|
710
710
|
}
|
|
711
711
|
}), e;
|
|
712
712
|
}
|
|
713
713
|
nest(e, t, i = {}) {
|
|
714
714
|
let s, n, r;
|
|
715
|
-
const
|
|
715
|
+
const o = (l, u) => {
|
|
716
716
|
var x;
|
|
717
|
-
const
|
|
718
|
-
if (l.indexOf(
|
|
719
|
-
const
|
|
720
|
-
let m = `{${
|
|
721
|
-
l =
|
|
717
|
+
const f = this.nestingOptionsSeparator;
|
|
718
|
+
if (l.indexOf(f) < 0) return l;
|
|
719
|
+
const h = l.split(new RegExp(`${f}[ ]*{`));
|
|
720
|
+
let m = `{${h[1]}`;
|
|
721
|
+
l = h[0], m = this.interpolate(m, r);
|
|
722
722
|
const d = m.match(/'/g), c = m.match(/"/g);
|
|
723
723
|
(((x = d == null ? void 0 : d.length) != null ? x : 0) % 2 === 0 && !c || c.length % 2 !== 0) && (m = m.replace(/'/g, '"'));
|
|
724
724
|
try {
|
|
725
725
|
r = JSON.parse(m), u && (r = p(p({}, u), r));
|
|
726
726
|
} catch (S) {
|
|
727
|
-
return this.logger.warn(`failed parsing options string in nesting for key ${l}`, S), `${l}${
|
|
727
|
+
return this.logger.warn(`failed parsing options string in nesting for key ${l}`, S), `${l}${f}${m}`;
|
|
728
728
|
}
|
|
729
729
|
return r.defaultValue && r.defaultValue.indexOf(this.prefix) > -1 && delete r.defaultValue, l;
|
|
730
730
|
};
|
|
@@ -732,25 +732,25 @@ class Be {
|
|
|
732
732
|
let l = [];
|
|
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
|
-
if (u !== -1 && (l = s[1].slice(u).split(this.formatSeparator).map((
|
|
736
|
-
g(n) || (n =
|
|
735
|
+
if (u !== -1 && (l = s[1].slice(u).split(this.formatSeparator).map((f) => f.trim()).filter(Boolean), s[1] = s[1].slice(0, u)), n = t(o.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((f, h) => this.format(f, h, 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
|
|
744
|
-
let e =
|
|
743
|
+
const Ye = (a) => {
|
|
744
|
+
let e = a.toLowerCase().trim();
|
|
745
745
|
const t = {};
|
|
746
|
-
if (
|
|
747
|
-
const i =
|
|
746
|
+
if (a.indexOf("(") > -1) {
|
|
747
|
+
const i = a.split("(");
|
|
748
748
|
e = i[0].toLowerCase().trim();
|
|
749
749
|
const s = i[1].substring(0, i[1].length - 1);
|
|
750
750
|
e === "currency" && s.indexOf(":") < 0 ? t.currency || (t.currency = s.trim()) : e === "relativetime" && s.indexOf(":") < 0 ? t.range || (t.range = s.trim()) : s.split(";").forEach((r) => {
|
|
751
751
|
if (r) {
|
|
752
|
-
const [
|
|
753
|
-
t[
|
|
752
|
+
const [o, ...l] = r.split(":"), u = l.join(":").trim().replace(/^'+|'+$/g, ""), f = o.trim();
|
|
753
|
+
t[f] || (t[f] = u), u === "false" && (t[f] = !1), u === "true" && (t[f] = !0), isNaN(u) || (t[f] = parseInt(u, 10));
|
|
754
754
|
}
|
|
755
755
|
});
|
|
756
756
|
}
|
|
@@ -758,7 +758,7 @@ const ze = (o) => {
|
|
|
758
758
|
formatName: e,
|
|
759
759
|
formatOptions: t
|
|
760
760
|
};
|
|
761
|
-
},
|
|
761
|
+
}, ye = (a) => {
|
|
762
762
|
const e = {};
|
|
763
763
|
return (t, i, s) => {
|
|
764
764
|
let n = s;
|
|
@@ -766,41 +766,41 @@ const ze = (o) => {
|
|
|
766
766
|
[s.interpolationkey]: void 0
|
|
767
767
|
}));
|
|
768
768
|
const r = i + JSON.stringify(n);
|
|
769
|
-
let
|
|
770
|
-
return
|
|
769
|
+
let o = e[r];
|
|
770
|
+
return o || (o = a(z(i), s), e[r] = o), o(t);
|
|
771
771
|
};
|
|
772
|
-
},
|
|
773
|
-
class
|
|
772
|
+
}, Qe = (a) => (e, t, i) => a(z(t), i)(e);
|
|
773
|
+
class Ge {
|
|
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 : Qe;
|
|
782
782
|
this.formats = {
|
|
783
783
|
number: i((s, n) => {
|
|
784
784
|
const r = new Intl.NumberFormat(s, p({}, n));
|
|
785
|
-
return (
|
|
785
|
+
return (o) => r.format(o);
|
|
786
786
|
}),
|
|
787
787
|
currency: i((s, n) => {
|
|
788
788
|
const r = new Intl.NumberFormat(s, O(p({}, n), {
|
|
789
789
|
style: "currency"
|
|
790
790
|
}));
|
|
791
|
-
return (
|
|
791
|
+
return (o) => r.format(o);
|
|
792
792
|
}),
|
|
793
793
|
datetime: i((s, n) => {
|
|
794
794
|
const r = new Intl.DateTimeFormat(s, p({}, n));
|
|
795
|
-
return (
|
|
795
|
+
return (o) => r.format(o);
|
|
796
796
|
}),
|
|
797
797
|
relativetime: i((s, n) => {
|
|
798
798
|
const r = new Intl.RelativeTimeFormat(s, p({}, n));
|
|
799
|
-
return (
|
|
799
|
+
return (o) => r.format(o, n.range || "day");
|
|
800
800
|
}),
|
|
801
801
|
list: i((s, n) => {
|
|
802
802
|
const r = new Intl.ListFormat(s, p({}, n));
|
|
803
|
-
return (
|
|
803
|
+
return (o) => r.format(o);
|
|
804
804
|
})
|
|
805
805
|
};
|
|
806
806
|
}
|
|
@@ -808,51 +808,51 @@ 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);
|
|
815
|
-
if (n.length > 1 && n[0].indexOf("(") > 1 && n[0].indexOf(")") < 0 && n.find((
|
|
816
|
-
const
|
|
817
|
-
n[0] = [n[0], ...n.splice(1,
|
|
815
|
+
if (n.length > 1 && n[0].indexOf("(") > 1 && n[0].indexOf(")") < 0 && n.find((o) => o.indexOf(")") > -1)) {
|
|
816
|
+
const o = n.findIndex((l) => l.indexOf(")") > -1);
|
|
817
|
+
n[0] = [n[0], ...n.splice(1, o)].join(this.formatSeparator);
|
|
818
818
|
}
|
|
819
|
-
return n.reduce((
|
|
820
|
-
var
|
|
819
|
+
return n.reduce((o, l) => {
|
|
820
|
+
var h;
|
|
821
821
|
const {
|
|
822
822
|
formatName: u,
|
|
823
|
-
formatOptions:
|
|
824
|
-
} =
|
|
823
|
+
formatOptions: f
|
|
824
|
+
} = Ye(l);
|
|
825
825
|
if (this.formats[u]) {
|
|
826
|
-
let m =
|
|
826
|
+
let m = o;
|
|
827
827
|
try {
|
|
828
|
-
const d = ((
|
|
829
|
-
m = this.formats[u](
|
|
828
|
+
const d = ((h = s == null ? void 0 : s.formatParams) == null ? void 0 : h[s.interpolationkey]) || {}, c = d.locale || d.lng || s.locale || s.lng || i;
|
|
829
|
+
m = this.formats[u](o, c, p(p(p({}, f), s), d));
|
|
830
830
|
} catch (d) {
|
|
831
831
|
this.logger.warn(d);
|
|
832
832
|
}
|
|
833
833
|
return m;
|
|
834
834
|
} else
|
|
835
835
|
this.logger.warn(`there was no format function for ${u}`);
|
|
836
|
-
return
|
|
836
|
+
return o;
|
|
837
837
|
}, e);
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
const
|
|
841
|
-
|
|
840
|
+
const Ze = (a, e) => {
|
|
841
|
+
a.pending[e] !== void 0 && (delete a.pending[e], a.pendingCount--);
|
|
842
842
|
};
|
|
843
|
-
class
|
|
843
|
+
class Xe 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
|
-
const n = {}, r = {},
|
|
849
|
+
const n = {}, r = {}, o = {}, l = {};
|
|
850
850
|
return e.forEach((u) => {
|
|
851
|
-
let
|
|
852
|
-
t.forEach((
|
|
853
|
-
const m = `${u}|${
|
|
854
|
-
!i.reload && this.store.hasResourceBundle(u,
|
|
855
|
-
}),
|
|
851
|
+
let f = !0;
|
|
852
|
+
t.forEach((h) => {
|
|
853
|
+
const m = `${u}|${h}`;
|
|
854
|
+
!i.reload && this.store.hasResourceBundle(u, h) ? this.state[m] = 2 : this.state[m] < 0 || (this.state[m] === 1 ? r[m] === void 0 && (r[m] = !0) : (this.state[m] = 1, f = !1, r[m] === void 0 && (r[m] = !0), n[m] === void 0 && (n[m] = !0), l[h] === void 0 && (l[h] = !0)));
|
|
855
|
+
}), f || (o[u] = !0);
|
|
856
856
|
}), (Object.keys(n).length || Object.keys(r).length) && this.queue.push({
|
|
857
857
|
pending: r,
|
|
858
858
|
pendingCount: Object.keys(r).length,
|
|
@@ -862,7 +862,7 @@ class Ye extends Z {
|
|
|
862
862
|
}), {
|
|
863
863
|
toLoad: Object.keys(n),
|
|
864
864
|
pending: Object.keys(r),
|
|
865
|
-
toLoadLanguages: Object.keys(
|
|
865
|
+
toLoadLanguages: Object.keys(o),
|
|
866
866
|
toLoadNamespaces: Object.keys(l)
|
|
867
867
|
};
|
|
868
868
|
}
|
|
@@ -871,16 +871,16 @@ class Ye extends Z {
|
|
|
871
871
|
t && this.emit("failedLoading", n, r, t), !t && i && this.store.addResourceBundle(n, r, i, void 0, void 0, {
|
|
872
872
|
skipCopy: !0
|
|
873
873
|
}), this.state[e] = t ? -1 : 2, t && i && (this.state[e] = 0);
|
|
874
|
-
const
|
|
874
|
+
const o = {};
|
|
875
875
|
this.queue.forEach((l) => {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
|
|
876
|
+
Ve(l.loaded, [n], r), Ze(l, e), t && l.errors.push(t), l.pendingCount === 0 && !l.done && (Object.keys(l.loaded).forEach((u) => {
|
|
877
|
+
o[u] || (o[u] = {});
|
|
878
|
+
const f = l.loaded[u];
|
|
879
|
+
f.length && f.forEach((h) => {
|
|
880
|
+
o[u][h] === void 0 && (o[u][h] = !0);
|
|
881
881
|
});
|
|
882
882
|
}), l.done = !0, l.errors.length ? l.callback(l.errors) : l.callback());
|
|
883
|
-
}), this.emit("loaded",
|
|
883
|
+
}), this.emit("loaded", o), this.queue = this.queue.filter((l) => !l.done);
|
|
884
884
|
}
|
|
885
885
|
read(e, t, i, s = 0, n = this.retryTimeout, r) {
|
|
886
886
|
if (!e.length) return r(null, {});
|
|
@@ -896,29 +896,29 @@ class Ye extends Z {
|
|
|
896
896
|
return;
|
|
897
897
|
}
|
|
898
898
|
this.readingCalls++;
|
|
899
|
-
const
|
|
899
|
+
const o = (u, f) => {
|
|
900
900
|
if (this.readingCalls--, this.waitingReads.length > 0) {
|
|
901
|
-
const
|
|
902
|
-
this.read(
|
|
901
|
+
const h = this.waitingReads.shift();
|
|
902
|
+
this.read(h.lng, h.ns, h.fcName, h.tried, h.wait, h.callback);
|
|
903
903
|
}
|
|
904
|
-
if (u &&
|
|
904
|
+
if (u && f && s < this.maxRetries) {
|
|
905
905
|
setTimeout(() => {
|
|
906
906
|
this.read.call(this, e, t, i, s + 1, n * 2, r);
|
|
907
907
|
}, n);
|
|
908
908
|
return;
|
|
909
909
|
}
|
|
910
|
-
r(u,
|
|
910
|
+
r(u, f);
|
|
911
911
|
}, l = this.backend[i].bind(this.backend);
|
|
912
912
|
if (l.length === 2) {
|
|
913
913
|
try {
|
|
914
914
|
const u = l(e, t);
|
|
915
|
-
u && typeof u.then == "function" ? u.then((
|
|
915
|
+
u && typeof u.then == "function" ? u.then((f) => o(null, f)).catch(o) : o(null, u);
|
|
916
916
|
} catch (u) {
|
|
917
|
-
|
|
917
|
+
o(u);
|
|
918
918
|
}
|
|
919
919
|
return;
|
|
920
920
|
}
|
|
921
|
-
return l(e, t,
|
|
921
|
+
return l(e, t, o);
|
|
922
922
|
}
|
|
923
923
|
prepareLoading(e, t, i = {}, s) {
|
|
924
924
|
if (!this.backend)
|
|
@@ -941,14 +941,14 @@ class Ye extends Z {
|
|
|
941
941
|
}
|
|
942
942
|
loadOne(e, t = "") {
|
|
943
943
|
const i = e.split("|"), s = i[0], n = i[1];
|
|
944
|
-
this.read(s, n, "read", void 0, void 0, (r,
|
|
945
|
-
r && this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`, r), !r &&
|
|
944
|
+
this.read(s, n, "read", void 0, void 0, (r, o) => {
|
|
945
|
+
r && this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`, r), !r && o && this.logger.log(`${t}loaded namespace ${n} for language ${s}`, o), this.loaded(e, r, o);
|
|
946
946
|
});
|
|
947
947
|
}
|
|
948
|
-
saveMissing(e, t, i, s, n, r = {},
|
|
948
|
+
saveMissing(e, t, i, s, n, r = {}, o = () => {
|
|
949
949
|
}) {
|
|
950
|
-
var l, u,
|
|
951
|
-
if ((u = (l = this.services) == null ? void 0 : l.utils) != null && u.hasLoadedNamespace && !((
|
|
950
|
+
var l, u, f, h, m;
|
|
951
|
+
if ((u = (l = this.services) == null ? void 0 : l.utils) != null && u.hasLoadedNamespace && !((h = (f = this.services) == null ? void 0 : f.utils) != null && h.hasLoadedNamespace(t))) {
|
|
952
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!!!");
|
|
953
953
|
return;
|
|
954
954
|
}
|
|
@@ -960,18 +960,18 @@ class Ye extends Z {
|
|
|
960
960
|
if (c.length < 6)
|
|
961
961
|
try {
|
|
962
962
|
let x;
|
|
963
|
-
c.length === 5 ? x = c(e, t, i, s, d) : x = c(e, t, i, s), x && typeof x.then == "function" ? x.then((S) =>
|
|
963
|
+
c.length === 5 ? x = c(e, t, i, s, d) : x = c(e, t, i, s), x && typeof x.then == "function" ? x.then((S) => o(null, S)).catch(o) : o(null, x);
|
|
964
964
|
} catch (x) {
|
|
965
|
-
|
|
965
|
+
o(x);
|
|
966
966
|
}
|
|
967
967
|
else
|
|
968
|
-
c(e, t, i, s,
|
|
968
|
+
c(e, t, i, s, o, d);
|
|
969
969
|
}
|
|
970
970
|
!e || !e[0] || this.store.addResource(e[0], t, i, s);
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
|
-
const
|
|
974
|
+
const Se = () => ({
|
|
975
975
|
debug: !1,
|
|
976
976
|
initAsync: !0,
|
|
977
977
|
ns: ["translation"],
|
|
@@ -1004,10 +1004,10 @@ const ye = () => ({
|
|
|
1004
1004
|
parseMissingKeyHandler: !1,
|
|
1005
1005
|
appendNamespaceToMissingKey: !1,
|
|
1006
1006
|
appendNamespaceToCIMode: !1,
|
|
1007
|
-
overloadTranslationOptionHandler: (
|
|
1007
|
+
overloadTranslationOptionHandler: (a) => {
|
|
1008
1008
|
let e = {};
|
|
1009
|
-
if (typeof
|
|
1010
|
-
const t =
|
|
1009
|
+
if (typeof a[1] == "object" && (e = a[1]), g(a[1]) && (e.defaultValue = a[1]), g(a[2]) && (e.tDescription = a[2]), typeof a[2] == "object" || typeof a[3] == "object") {
|
|
1010
|
+
const t = a[3] || a[2];
|
|
1011
1011
|
Object.keys(t).forEach((i) => {
|
|
1012
1012
|
e[i] = t[i];
|
|
1013
1013
|
});
|
|
@@ -1016,7 +1016,7 @@ const ye = () => ({
|
|
|
1016
1016
|
},
|
|
1017
1017
|
interpolation: {
|
|
1018
1018
|
escapeValue: !0,
|
|
1019
|
-
format: (
|
|
1019
|
+
format: (a) => a,
|
|
1020
1020
|
prefix: "{{",
|
|
1021
1021
|
suffix: "}}",
|
|
1022
1022
|
formatSeparator: ",",
|
|
@@ -1028,20 +1028,20 @@ const ye = () => ({
|
|
|
1028
1028
|
skipOnVariables: !0
|
|
1029
1029
|
},
|
|
1030
1030
|
cacheInBuiltFormats: !0
|
|
1031
|
-
}),
|
|
1031
|
+
}), be = (a) => {
|
|
1032
1032
|
var e, t;
|
|
1033
|
-
return g(
|
|
1034
|
-
},
|
|
1035
|
-
},
|
|
1036
|
-
Object.getOwnPropertyNames(Object.getPrototypeOf(
|
|
1037
|
-
typeof
|
|
1033
|
+
return g(a.ns) && (a.ns = [a.ns]), g(a.fallbackLng) && (a.fallbackLng = [a.fallbackLng]), g(a.fallbackNS) && (a.fallbackNS = [a.fallbackNS]), ((t = (e = a.supportedLngs) == null ? void 0 : e.indexOf) == null ? void 0 : t.call(e, "cimode")) < 0 && (a.supportedLngs = a.supportedLngs.concat(["cimode"])), typeof a.initImmediate == "boolean" && (a.initAsync = a.initImmediate), a;
|
|
1034
|
+
}, Y = () => {
|
|
1035
|
+
}, qe = (a) => {
|
|
1036
|
+
Object.getOwnPropertyNames(Object.getPrototypeOf(a)).forEach((t) => {
|
|
1037
|
+
typeof a[t] == "function" && (a[t] = a[t].bind(a));
|
|
1038
1038
|
});
|
|
1039
1039
|
};
|
|
1040
|
-
class
|
|
1040
|
+
class J 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
|
+
}, qe(this), t && !this.isInitialized && !e.isClone) {
|
|
1045
1045
|
if (!this.options.initAsync)
|
|
1046
1046
|
return this.init(e, t), this;
|
|
1047
1047
|
setTimeout(() => {
|
|
@@ -1051,75 +1051,75 @@ 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
|
|
1060
|
+
this.modules.formatter ? u = this.modules.formatter : u = Ge;
|
|
1061
|
+
const f = new pe(this.options);
|
|
1062
1062
|
this.store = new fe(this.options.resources, this.options);
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1063
|
+
const h = this.services;
|
|
1064
|
+
h.logger = F, h.resourceStore = this.store, h.languageUtils = f, h.pluralResolver = new _e(f, {
|
|
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) && (
|
|
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) && (h.formatter = s(u), h.formatter.init && h.formatter.init(h, this.options), this.options.interpolation.format = h.formatter.format.bind(h.formatter)), h.interpolator = new We(this.options), h.utils = {
|
|
1068
1068
|
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
1069
|
-
},
|
|
1069
|
+
}, h.backendConnector = new Xe(s(this.modules.backend), h.resourceStore, h, this.options), h.backendConnector.on("*", (d, ...c) => {
|
|
1070
1070
|
this.emit(d, ...c);
|
|
1071
|
-
}), this.modules.languageDetector && (
|
|
1071
|
+
}), this.modules.languageDetector && (h.languageDetector = s(this.modules.languageDetector), h.languageDetector.init && h.languageDetector.init(h, this.options.detection, this.options)), this.modules.i18nFormat && (h.i18nFormat = s(this.modules.i18nFormat), h.i18nFormat.init && h.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 = Y), 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
|
}
|
|
1081
1081
|
!this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((u) => {
|
|
1082
|
-
this[u] = (...
|
|
1082
|
+
this[u] = (...f) => this.store[u](...f);
|
|
1083
1083
|
}), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((u) => {
|
|
1084
|
-
this[u] = (...
|
|
1084
|
+
this[u] = (...f) => (this.store[u](...f), this);
|
|
1085
1085
|
});
|
|
1086
|
-
const
|
|
1087
|
-
const u = (
|
|
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),
|
|
1086
|
+
const o = M(), l = () => {
|
|
1087
|
+
const u = (f, h) => {
|
|
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), o.resolve(h), t(f, h);
|
|
1089
1089
|
};
|
|
1090
1090
|
if (this.languages && !this.isInitialized) return u(null, this.t.bind(this));
|
|
1091
1091
|
this.changeLanguage(this.options.lng, u);
|
|
1092
1092
|
};
|
|
1093
|
-
return this.options.resources || !this.options.initAsync ? l() : setTimeout(l, 0),
|
|
1093
|
+
return this.options.resources || !this.options.initAsync ? l() : setTimeout(l, 0), o;
|
|
1094
1094
|
}
|
|
1095
|
-
loadResources(e, t =
|
|
1095
|
+
loadResources(e, t = Y) {
|
|
1096
1096
|
var n, r;
|
|
1097
1097
|
let i = t;
|
|
1098
1098
|
const s = g(e) ? e : this.language;
|
|
1099
1099
|
if (typeof e == "function" && (i = e), !this.options.resources || this.options.partialBundledLanguages) {
|
|
1100
1100
|
if ((s == null ? void 0 : s.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return i();
|
|
1101
|
-
const
|
|
1101
|
+
const o = [], l = (u) => {
|
|
1102
1102
|
if (!u || u === "cimode") return;
|
|
1103
|
-
this.services.languageUtils.toResolveHierarchy(u).forEach((
|
|
1104
|
-
|
|
1103
|
+
this.services.languageUtils.toResolveHierarchy(u).forEach((h) => {
|
|
1104
|
+
h !== "cimode" && o.indexOf(h) < 0 && o.push(h);
|
|
1105
1105
|
});
|
|
1106
1106
|
};
|
|
1107
|
-
s ? l(s) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((
|
|
1107
|
+
s ? l(s) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((f) => l(f)), (r = (n = this.options.preload) == null ? void 0 : n.forEach) == null || r.call(n, (u) => l(u)), this.services.backendConnector.load(o, this.options.ns, (u) => {
|
|
1108
1108
|
!u && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), i(u);
|
|
1109
1109
|
});
|
|
1110
1110
|
} else
|
|
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 = Y), 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" && Ce.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,29 +1135,29 @@ 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
|
-
const s = (
|
|
1141
|
-
this.language =
|
|
1142
|
-
}, n = (
|
|
1143
|
-
l ? this.isLanguageChangingTo === e && (s(l), this.translator.changeLanguage(l), this.isLanguageChangingTo = void 0, this.emit("languageChanged", l), this.logger.log("languageChanged", l)) : this.isLanguageChangingTo = void 0, i.resolve((...u) => this.t(...u)), t && t(
|
|
1144
|
-
}, r = (
|
|
1145
|
-
var
|
|
1146
|
-
!e && !
|
|
1147
|
-
const l = g(
|
|
1148
|
-
u && (this.language || s(u), this.translator.language || this.translator.changeLanguage(u), (
|
|
1140
|
+
const s = (o) => {
|
|
1141
|
+
this.language = o, this.languages = this.services.languageUtils.toResolveHierarchy(o), this.resolvedLanguage = void 0, this.setResolvedLanguage(o);
|
|
1142
|
+
}, n = (o, l) => {
|
|
1143
|
+
l ? this.isLanguageChangingTo === e && (s(l), this.translator.changeLanguage(l), this.isLanguageChangingTo = void 0, this.emit("languageChanged", l), this.logger.log("languageChanged", l)) : this.isLanguageChangingTo = void 0, i.resolve((...u) => this.t(...u)), t && t(o, (...u) => this.t(...u));
|
|
1144
|
+
}, r = (o) => {
|
|
1145
|
+
var f, h;
|
|
1146
|
+
!e && !o && this.services.languageDetector && (o = []);
|
|
1147
|
+
const l = g(o) ? o : o && o[0], u = this.store.hasLanguageSomeTranslations(l) ? l : this.services.languageUtils.getBestMatchFromCodes(g(o) ? [o] : o);
|
|
1148
|
+
u && (this.language || s(u), this.translator.language || this.translator.changeLanguage(u), (h = (f = this.services.languageDetector) == null ? void 0 : f.cacheUserLanguage) == null || h.call(f, u)), this.loadResources(u, (m) => {
|
|
1149
1149
|
n(m, u);
|
|
1150
1150
|
});
|
|
1151
1151
|
};
|
|
1152
1152
|
return !e && this.services.languageDetector && !this.services.languageDetector.async ? r(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(r) : this.services.languageDetector.detect(r) : r(e), i;
|
|
1153
1153
|
}
|
|
1154
1154
|
getFixedT(e, t, i) {
|
|
1155
|
-
const s = (n, r, ...
|
|
1155
|
+
const s = (n, r, ...o) => {
|
|
1156
1156
|
let l;
|
|
1157
|
-
typeof r != "object" ? l = this.options.overloadTranslationOptionHandler([n, r].concat(
|
|
1157
|
+
typeof r != "object" ? l = this.options.overloadTranslationOptionHandler([n, r].concat(o)) : l = p({}, r), l.lng = l.lng || s.lng, l.lngs = l.lngs || s.lngs, l.ns = l.ns || s.ns, l.keyPrefix !== "" && (l.keyPrefix = l.keyPrefix || i || s.keyPrefix);
|
|
1158
1158
|
const u = this.options.keySeparator || ".";
|
|
1159
|
-
let
|
|
1160
|
-
return l.keyPrefix && Array.isArray(n) ?
|
|
1159
|
+
let f;
|
|
1160
|
+
return l.keyPrefix && Array.isArray(n) ? f = n.map((h) => `${l.keyPrefix}${u}${h}`) : f = l.keyPrefix ? `${l.keyPrefix}${u}${n}` : n, this.t(f, l);
|
|
1161
1161
|
};
|
|
1162
1162
|
return g(e) ? s.lng = e : s.lngs = e, s.ns = t, s.keyPrefix = i, s;
|
|
1163
1163
|
}
|
|
@@ -1179,18 +1179,18 @@ class B extends Z {
|
|
|
1179
1179
|
return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
|
|
1180
1180
|
const i = t.lng || this.resolvedLanguage || this.languages[0], s = this.options ? this.options.fallbackLng : !1, n = this.languages[this.languages.length - 1];
|
|
1181
1181
|
if (i.toLowerCase() === "cimode") return !0;
|
|
1182
|
-
const r = (
|
|
1183
|
-
const u = this.services.backendConnector.state[`${
|
|
1182
|
+
const r = (o, l) => {
|
|
1183
|
+
const u = this.services.backendConnector.state[`${o}|${l}`];
|
|
1184
1184
|
return u === -1 || u === 0 || u === 2;
|
|
1185
1185
|
};
|
|
1186
1186
|
if (t.precheck) {
|
|
1187
|
-
const
|
|
1188
|
-
if (
|
|
1187
|
+
const o = t.precheck(this, r);
|
|
1188
|
+
if (o !== void 0) return o;
|
|
1189
1189
|
}
|
|
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) => {
|
|
@@ -1211,33 +1211,33 @@ class B extends Z {
|
|
|
1211
1211
|
try {
|
|
1212
1212
|
const r = new Intl.Locale(e);
|
|
1213
1213
|
if (r && r.getTextInfo) {
|
|
1214
|
-
const
|
|
1215
|
-
if (
|
|
1214
|
+
const o = r.getTextInfo();
|
|
1215
|
+
if (o && o.direction) return o.direction;
|
|
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 J(e, t);
|
|
1224
1224
|
}
|
|
1225
|
-
cloneInstance(e = {}, t =
|
|
1225
|
+
cloneInstance(e = {}, t = Y) {
|
|
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
|
|
1231
|
-
if ((e.debug !== void 0 || e.prefix !== void 0) && (n.logger = n.logger.clone(e)), ["store", "services", "language"].forEach((
|
|
1232
|
-
n[
|
|
1230
|
+
}), n = new J(s);
|
|
1231
|
+
if ((e.debug !== void 0 || e.prefix !== void 0) && (n.logger = n.logger.clone(e)), ["store", "services", "language"].forEach((o) => {
|
|
1232
|
+
n[o] = this[o];
|
|
1233
1233
|
}), n.services = p({}, this.services), n.services.utils = {
|
|
1234
1234
|
hasLoadedNamespace: n.hasLoadedNamespace.bind(n)
|
|
1235
1235
|
}, i) {
|
|
1236
|
-
const
|
|
1237
|
-
n.store = new fe(
|
|
1236
|
+
const o = Object.keys(this.store.data).reduce((l, u) => (l[u] = p({}, this.store.data[u]), l[u] = Object.keys(l[u]).reduce((f, h) => (f[h] = p({}, l[u][h]), f), l[u]), l), {});
|
|
1237
|
+
n.store = new fe(o, s), n.services.resourceStore = n.store;
|
|
1238
1238
|
}
|
|
1239
|
-
return n.translator = new
|
|
1240
|
-
n.emit(
|
|
1239
|
+
return n.translator = new Z(n.services, s), n.translator.on("*", (o, ...l) => {
|
|
1240
|
+
n.emit(o, ...l);
|
|
1241
1241
|
}), n.init(s, t), n.translator.options = s, n.translator.backendConnector.services.utils = {
|
|
1242
1242
|
hasLoadedNamespace: n.hasLoadedNamespace.bind(n)
|
|
1243
1243
|
}, n;
|
|
@@ -1252,8 +1252,8 @@ class B extends Z {
|
|
|
1252
1252
|
};
|
|
1253
1253
|
}
|
|
1254
1254
|
}
|
|
1255
|
-
const y =
|
|
1256
|
-
y.createInstance =
|
|
1255
|
+
const y = J.createInstance();
|
|
1256
|
+
y.createInstance = J.createInstance;
|
|
1257
1257
|
y.createInstance;
|
|
1258
1258
|
y.dir;
|
|
1259
1259
|
y.init;
|
|
@@ -1268,17 +1268,17 @@ y.setDefaultNamespace;
|
|
|
1268
1268
|
y.hasLoadedNamespace;
|
|
1269
1269
|
y.loadNamespaces;
|
|
1270
1270
|
y.loadLanguages;
|
|
1271
|
-
const
|
|
1271
|
+
const et = (a, e) => {
|
|
1272
1272
|
for (const t of e) {
|
|
1273
|
-
const i =
|
|
1273
|
+
const i = a.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
|
-
const
|
|
1279
|
-
|
|
1280
|
-
"data-i18n":
|
|
1281
|
-
}), r.text(y.t(
|
|
1278
|
+
const o = r.text().trim();
|
|
1279
|
+
o && (r.attr({
|
|
1280
|
+
"data-i18n": o
|
|
1281
|
+
}), r.text(y.t(o)));
|
|
1282
1282
|
const l = r.attr("placeholder");
|
|
1283
1283
|
l && (r.attr({
|
|
1284
1284
|
"data-i18n": "[placeholder]" + l
|
|
@@ -1287,65 +1287,78 @@ const Ge = (o, e) => {
|
|
|
1287
1287
|
}));
|
|
1288
1288
|
});
|
|
1289
1289
|
}
|
|
1290
|
-
},
|
|
1291
|
-
for (const e of
|
|
1292
|
-
const t =
|
|
1290
|
+
}, H = (a) => {
|
|
1291
|
+
for (const e of a) {
|
|
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();
|
|
1298
1298
|
r && (n.attr({
|
|
1299
1299
|
"data-i18n": r
|
|
1300
1300
|
}), n.text(y.t(r)));
|
|
1301
|
-
const
|
|
1302
|
-
|
|
1303
|
-
"data-i18n": "[placeholder]" +
|
|
1301
|
+
const o = n.attr("placeholder");
|
|
1302
|
+
o && (n.attr({
|
|
1303
|
+
"data-i18n": "[placeholder]" + o
|
|
1304
1304
|
}), n.attr({
|
|
1305
|
-
placeholder: y.t(
|
|
1305
|
+
placeholder: y.t(o)
|
|
1306
1306
|
}));
|
|
1307
1307
|
});
|
|
1308
1308
|
}
|
|
1309
|
-
},
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1309
|
+
}, $e = [
|
|
1310
|
+
".hiprint-option-item-label",
|
|
1311
|
+
"textarea",
|
|
1312
|
+
"input",
|
|
1313
|
+
"select option",
|
|
1314
|
+
".option",
|
|
1315
|
+
"button",
|
|
1316
|
+
"label",
|
|
1317
|
+
".hiprint-option-title",
|
|
1318
|
+
".hiprint-option-item-desc",
|
|
1319
|
+
".hiprint-multiselect-search",
|
|
1320
|
+
".hiprint-multiselect-custom-input",
|
|
1321
|
+
".hiprint-multiselect-trigger .hiprint-multiselect-text",
|
|
1322
|
+
".hiprint-multiselect-item span",
|
|
1323
|
+
".hiprint-multiselect-actions button"
|
|
1324
|
+
], tt = (a, e, t = $e) => {
|
|
1325
|
+
et(e, t);
|
|
1326
|
+
}, Pe = (a = "[data-i18n]") => {
|
|
1327
|
+
document.querySelectorAll(a).forEach((e) => {
|
|
1328
|
+
const t = e.getAttribute("data-i18n");
|
|
1329
|
+
if (!t.includes("[")) {
|
|
1330
|
+
e.textContent = y.t(t);
|
|
1326
1331
|
return;
|
|
1327
1332
|
}
|
|
1328
|
-
const
|
|
1329
|
-
if (
|
|
1330
|
-
const
|
|
1331
|
-
|
|
1333
|
+
const i = t.match(/\[([^\]]+)\](.+)/);
|
|
1334
|
+
if (i && i.length === 3) {
|
|
1335
|
+
const s = i[1], n = i[2];
|
|
1336
|
+
e.setAttribute(s, y.t(n));
|
|
1332
1337
|
}
|
|
1333
1338
|
});
|
|
1334
1339
|
};
|
|
1335
|
-
let
|
|
1336
|
-
const
|
|
1337
|
-
if (
|
|
1340
|
+
let Le = !1;
|
|
1341
|
+
const Oe = (a) => {
|
|
1342
|
+
if (Le)
|
|
1338
1343
|
return;
|
|
1339
|
-
|
|
1340
|
-
const e = Object.keys(
|
|
1344
|
+
Le = !0, globalThis.hiprint.i18next = y, globalThis.hiprint.t = y.t;
|
|
1345
|
+
const e = Object.keys(a.resources || {});
|
|
1341
1346
|
globalThis.hiprint.languages = ["简体中文", ...e], globalThis.hiprint.changeLanguage = (t, i) => {
|
|
1342
1347
|
y.changeLanguage(t, (s, n) => {
|
|
1343
|
-
i && i(s, n),
|
|
1348
|
+
i && i(s, n), Pe();
|
|
1344
1349
|
});
|
|
1345
1350
|
};
|
|
1351
|
+
}, we = (a) => {
|
|
1352
|
+
setTimeout(() => {
|
|
1353
|
+
Pe(".printSetting .hiprint-multiselect [data-i18n]"), $(".printSetting .hiprint-multiselect").length && $(".printSetting .hiprint-multiselect-trigger").off("click.multiselect-trigger").on("click.multiselect-trigger", () => {
|
|
1354
|
+
console.log("click multiselect"), setTimeout(() => {
|
|
1355
|
+
H((a == null ? void 0 : a.optionsSelectorList) || $e);
|
|
1356
|
+
}, 0);
|
|
1357
|
+
});
|
|
1358
|
+
}, 0);
|
|
1346
1359
|
};
|
|
1347
|
-
function
|
|
1348
|
-
y.init(p({},
|
|
1360
|
+
function st(a, e) {
|
|
1361
|
+
y.init(p({}, a), (i, s) => {
|
|
1349
1362
|
e && e(y, s, i);
|
|
1350
1363
|
});
|
|
1351
1364
|
let t = [];
|
|
@@ -1359,7 +1372,7 @@ function et(o, e) {
|
|
|
1359
1372
|
description: "添加 i18n 方法",
|
|
1360
1373
|
priority: 1,
|
|
1361
1374
|
run: () => {
|
|
1362
|
-
|
|
1375
|
+
Oe(a);
|
|
1363
1376
|
}
|
|
1364
1377
|
},
|
|
1365
1378
|
{
|
|
@@ -1369,14 +1382,15 @@ function et(o, e) {
|
|
|
1369
1382
|
priority: 1,
|
|
1370
1383
|
run: (i) => {
|
|
1371
1384
|
if (i) {
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
"data-name": i.name
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1385
|
+
if (!i._translationWrapped) {
|
|
1386
|
+
i._translationWrapped = !0;
|
|
1387
|
+
const s = i.createTarget;
|
|
1388
|
+
i.createTarget = function(...n) {
|
|
1389
|
+
const r = s.call(i, ...n);
|
|
1390
|
+
return t.indexOf(i.name) !== -1 && r.attr("data-name") || (r.attr({ "data-name": i.name }), tt(i, r, a == null ? void 0 : a.optionsSelectorList)), r;
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
return t.indexOf(i.name) === -1 && t.push(i.name), i;
|
|
1380
1394
|
}
|
|
1381
1395
|
}
|
|
1382
1396
|
},
|
|
@@ -1386,19 +1400,21 @@ function et(o, e) {
|
|
|
1386
1400
|
description: "其他UI选择器多语言处理",
|
|
1387
1401
|
priority: 1,
|
|
1388
1402
|
run: ({ hiprint: i, designerUtils: s }) => {
|
|
1389
|
-
var
|
|
1390
|
-
|
|
1391
|
-
const n = (
|
|
1392
|
-
n && (globalThis.hinnn.event.on("
|
|
1403
|
+
var o;
|
|
1404
|
+
Oe(a);
|
|
1405
|
+
const n = (o = s.printTemplate) == null ? void 0 : o.id;
|
|
1406
|
+
n && (a != null && a.onDesigned && (a == null || a.onDesigned(s)), globalThis.hinnn.event.on("BuildCustomOptionSettingEventKey_" + n, (l) => {
|
|
1407
|
+
a != null && a.onPanelSelected && (a == null || a.onPanelSelected()), we(a);
|
|
1408
|
+
}), globalThis.hinnn.event.on("PrintElementSelectEventKey_" + n, (l) => {
|
|
1393
1409
|
setTimeout(() => {
|
|
1394
|
-
|
|
1410
|
+
H([".printSetting .prop-tab-items .tab-title"]), we(a), a != null && a.onElementSelected && (a == null || a.onElementSelected(l));
|
|
1395
1411
|
}, 0);
|
|
1396
|
-
}),
|
|
1397
|
-
|
|
1412
|
+
}), $(".hiprint-printPaper.design").on("contextmenu", () => {
|
|
1413
|
+
H([
|
|
1398
1414
|
".hicontextmenu .hicontextmenuitem .title span",
|
|
1399
1415
|
".hicontextmenu .hicontextmenuitem .nav"
|
|
1400
1416
|
]);
|
|
1401
|
-
})),
|
|
1417
|
+
})), H([
|
|
1402
1418
|
".svp-header p",
|
|
1403
1419
|
".svp-tools .tool-name",
|
|
1404
1420
|
".svp-dragbox .header span",
|
|
@@ -1414,7 +1430,7 @@ function et(o, e) {
|
|
|
1414
1430
|
priority: 1,
|
|
1415
1431
|
run: (i) => {
|
|
1416
1432
|
setTimeout(() => {
|
|
1417
|
-
|
|
1433
|
+
H([".preview-bar button span", ".printer-list-txt"]);
|
|
1418
1434
|
}, 0);
|
|
1419
1435
|
}
|
|
1420
1436
|
}
|
|
@@ -1423,6 +1439,6 @@ function et(o, e) {
|
|
|
1423
1439
|
};
|
|
1424
1440
|
}
|
|
1425
1441
|
export {
|
|
1426
|
-
|
|
1427
|
-
|
|
1442
|
+
st as default,
|
|
1443
|
+
H as translateBySelector
|
|
1428
1444
|
};
|