@sv-print/plugin-i18n 0.1.6 → 0.1.8
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/README.md +18 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +702 -675
- package/dist/index.umd.js +1 -1
- package/dist/translate-option.d.ts +2 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Ne = Object.defineProperty, Te = Object.defineProperties;
|
|
2
|
+
var Fe = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var re = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var ae = (
|
|
4
|
+
var Ee = Object.prototype.hasOwnProperty, je = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ae = (r, e, t) => e in r ? Ne(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
7
|
+
Ee.call(e, t) && ae(r, t, e[t]);
|
|
8
8
|
if (re)
|
|
9
9
|
for (var t of re(e))
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}, O = (
|
|
13
|
-
const g = (
|
|
14
|
-
let
|
|
15
|
-
const t = new Promise((
|
|
16
|
-
|
|
10
|
+
je.call(e, t) && ae(r, t, e[t]);
|
|
11
|
+
return r;
|
|
12
|
+
}, O = (r, e) => Te(r, Fe(e));
|
|
13
|
+
const g = (r) => typeof r == "string", H = () => {
|
|
14
|
+
let r, e;
|
|
15
|
+
const t = new Promise((s, i) => {
|
|
16
|
+
r = s, e = i;
|
|
17
17
|
});
|
|
18
|
-
return t.resolve =
|
|
19
|
-
}, oe = (
|
|
20
|
-
|
|
21
|
-
e[
|
|
18
|
+
return t.resolve = r, t.reject = e, t;
|
|
19
|
+
}, oe = (r) => r == null ? "" : "" + r, Ie = (r, e, t) => {
|
|
20
|
+
r.forEach((s) => {
|
|
21
|
+
e[s] && (t[s] = e[s]);
|
|
22
22
|
});
|
|
23
|
-
},
|
|
24
|
-
const
|
|
25
|
-
let
|
|
26
|
-
for (;
|
|
27
|
-
if (ue(
|
|
28
|
-
const n = le(i
|
|
29
|
-
!
|
|
30
|
-
}
|
|
31
|
-
return ue(
|
|
32
|
-
obj:
|
|
33
|
-
k: le(i
|
|
23
|
+
}, De = /###/g, le = (r) => r && r.indexOf("###") > -1 ? r.replace(De, ".") : r, ue = (r) => !r || g(r), B = (r, e, t) => {
|
|
24
|
+
const s = g(e) ? e.split(".") : e;
|
|
25
|
+
let i = 0;
|
|
26
|
+
for (; i < s.length - 1; ) {
|
|
27
|
+
if (ue(r)) return {};
|
|
28
|
+
const n = le(s[i]);
|
|
29
|
+
!r[n] && t && (r[n] = new t()), Object.prototype.hasOwnProperty.call(r, n) ? r = r[n] : r = {}, ++i;
|
|
30
|
+
}
|
|
31
|
+
return ue(r) ? {} : {
|
|
32
|
+
obj: r,
|
|
33
|
+
k: le(s[i])
|
|
34
34
|
};
|
|
35
|
-
},
|
|
35
|
+
}, he = (r, e, t) => {
|
|
36
36
|
const {
|
|
37
|
-
obj:
|
|
38
|
-
k:
|
|
39
|
-
} =
|
|
40
|
-
if (
|
|
41
|
-
i
|
|
37
|
+
obj: s,
|
|
38
|
+
k: i
|
|
39
|
+
} = B(r, e, Object);
|
|
40
|
+
if (s !== void 0 || e.length === 1) {
|
|
41
|
+
s[i] = t;
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
let n = e[e.length - 1],
|
|
45
|
-
for (;
|
|
46
|
-
n = `${
|
|
47
|
-
|
|
48
|
-
},
|
|
44
|
+
let n = e[e.length - 1], a = e.slice(0, e.length - 1), o = B(r, a, Object);
|
|
45
|
+
for (; o.obj === void 0 && a.length; )
|
|
46
|
+
n = `${a[a.length - 1]}.${n}`, a = a.slice(0, a.length - 1), o = B(r, a, 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 = (r, e, t, s) => {
|
|
49
49
|
const {
|
|
50
|
-
obj:
|
|
50
|
+
obj: i,
|
|
51
51
|
k: n
|
|
52
|
-
} =
|
|
53
|
-
|
|
54
|
-
}, Q = (
|
|
52
|
+
} = B(r, e, Object);
|
|
53
|
+
i[n] = i[n] || [], i[n].push(t);
|
|
54
|
+
}, Q = (r, e) => {
|
|
55
55
|
const {
|
|
56
56
|
obj: t,
|
|
57
|
-
k:
|
|
58
|
-
} =
|
|
59
|
-
if (t && Object.prototype.hasOwnProperty.call(t,
|
|
60
|
-
return t[
|
|
61
|
-
},
|
|
62
|
-
const
|
|
63
|
-
return
|
|
64
|
-
},
|
|
65
|
-
for (const
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
}, V = (
|
|
69
|
-
var
|
|
57
|
+
k: s
|
|
58
|
+
} = B(r, e);
|
|
59
|
+
if (t && Object.prototype.hasOwnProperty.call(t, s))
|
|
60
|
+
return t[s];
|
|
61
|
+
}, Ae = (r, e, t) => {
|
|
62
|
+
const s = Q(r, t);
|
|
63
|
+
return s !== void 0 ? s : Q(e, t);
|
|
64
|
+
}, ve = (r, e, t) => {
|
|
65
|
+
for (const s in e)
|
|
66
|
+
s !== "__proto__" && s !== "constructor" && (s in r ? g(r[s]) || r[s] instanceof String || g(e[s]) || e[s] instanceof String ? t && (r[s] = e[s]) : ve(r[s], e[s], t) : r[s] = e[s]);
|
|
67
|
+
return r;
|
|
68
|
+
}, V = (r) => r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
69
|
+
var Ke = {
|
|
70
70
|
"&": "&",
|
|
71
71
|
"<": "<",
|
|
72
72
|
">": ">",
|
|
@@ -74,8 +74,8 @@ var De = {
|
|
|
74
74
|
"'": "'",
|
|
75
75
|
"/": "/"
|
|
76
76
|
};
|
|
77
|
-
const
|
|
78
|
-
class
|
|
77
|
+
const Ue = (r) => g(r) ? r.replace(/[&<>"'\/]/g, (e) => Ke[e]) : r;
|
|
78
|
+
class Me {
|
|
79
79
|
constructor(e) {
|
|
80
80
|
this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
|
|
81
81
|
}
|
|
@@ -83,55 +83,55 @@ class Ae {
|
|
|
83
83
|
const t = this.regExpMap.get(e);
|
|
84
84
|
if (t !== void 0)
|
|
85
85
|
return t;
|
|
86
|
-
const
|
|
87
|
-
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e,
|
|
86
|
+
const s = new RegExp(e);
|
|
87
|
+
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, s), this.regExpQueue.push(e), s;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
const
|
|
90
|
+
const He = [" ", ",", "?", "!", ";"], Be = new Me(20), ze = (r, e, t) => {
|
|
91
91
|
e = e || "", t = t || "";
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
94
|
-
const
|
|
95
|
-
let n = !
|
|
92
|
+
const s = He.filter((a) => e.indexOf(a) < 0 && t.indexOf(a) < 0);
|
|
93
|
+
if (s.length === 0) return !0;
|
|
94
|
+
const i = Be.getRegExp(`(${s.map((a) => a === "?" ? "\\?" : a).join("|")})`);
|
|
95
|
+
let n = !i.test(r);
|
|
96
96
|
if (!n) {
|
|
97
|
-
const
|
|
98
|
-
|
|
97
|
+
const a = r.indexOf(t);
|
|
98
|
+
a > 0 && !i.test(r.substring(0, a)) && (n = !0);
|
|
99
99
|
}
|
|
100
100
|
return n;
|
|
101
|
-
}, ee = (
|
|
102
|
-
if (!
|
|
103
|
-
if (
|
|
104
|
-
return Object.prototype.hasOwnProperty.call(
|
|
105
|
-
const
|
|
106
|
-
let
|
|
107
|
-
for (let n = 0; n <
|
|
108
|
-
if (!
|
|
101
|
+
}, ee = (r, e, t = ".") => {
|
|
102
|
+
if (!r) return;
|
|
103
|
+
if (r[e])
|
|
104
|
+
return Object.prototype.hasOwnProperty.call(r, e) ? r[e] : void 0;
|
|
105
|
+
const s = e.split(t);
|
|
106
|
+
let i = r;
|
|
107
|
+
for (let n = 0; n < s.length; ) {
|
|
108
|
+
if (!i || typeof i != "object")
|
|
109
109
|
return;
|
|
110
|
-
let
|
|
111
|
-
for (let l = n; l <
|
|
112
|
-
if (l !== n && (
|
|
113
|
-
if (["string", "number", "boolean"].indexOf(typeof
|
|
110
|
+
let a, o = "";
|
|
111
|
+
for (let l = n; l < s.length; ++l)
|
|
112
|
+
if (l !== n && (o += t), o += s[l], a = i[o], a !== void 0) {
|
|
113
|
+
if (["string", "number", "boolean"].indexOf(typeof a) > -1 && l < s.length - 1)
|
|
114
114
|
continue;
|
|
115
115
|
n += l - n + 1;
|
|
116
116
|
break;
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
i = a;
|
|
119
119
|
}
|
|
120
|
-
return
|
|
121
|
-
},
|
|
120
|
+
return i;
|
|
121
|
+
}, z = (r) => r == null ? void 0 : r.replace("_", "-"), Je = {
|
|
122
122
|
type: "logger",
|
|
123
|
-
log(
|
|
124
|
-
this.output("log",
|
|
123
|
+
log(r) {
|
|
124
|
+
this.output("log", r);
|
|
125
125
|
},
|
|
126
|
-
warn(
|
|
127
|
-
this.output("warn",
|
|
126
|
+
warn(r) {
|
|
127
|
+
this.output("warn", r);
|
|
128
128
|
},
|
|
129
|
-
error(
|
|
130
|
-
this.output("error",
|
|
129
|
+
error(r) {
|
|
130
|
+
this.output("error", r);
|
|
131
131
|
},
|
|
132
|
-
output(
|
|
133
|
-
var t,
|
|
134
|
-
(
|
|
132
|
+
output(r, e) {
|
|
133
|
+
var t, s;
|
|
134
|
+
(s = (t = console == null ? void 0 : console[r]) == null ? void 0 : t.apply) == null || s.call(t, console, e);
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
137
|
class G {
|
|
@@ -139,7 +139,7 @@ class G {
|
|
|
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);
|
|
@@ -153,8 +153,8 @@ class G {
|
|
|
153
153
|
deprecate(...e) {
|
|
154
154
|
return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
|
|
155
155
|
}
|
|
156
|
-
forward(e, t,
|
|
157
|
-
return
|
|
156
|
+
forward(e, t, s, i) {
|
|
157
|
+
return i && !this.debug ? null : (g(e[0]) && (e[0] = `${s}${this.prefix} ${e[0]}`), this.logger[t](e));
|
|
158
158
|
}
|
|
159
159
|
create(e) {
|
|
160
160
|
return new G(this.logger, p({
|
|
@@ -165,16 +165,16 @@ class G {
|
|
|
165
165
|
return e = e || this.options, e.prefix = e.prefix || this.prefix, new G(this.logger, e);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
var
|
|
168
|
+
var T = new G();
|
|
169
169
|
class X {
|
|
170
170
|
constructor() {
|
|
171
171
|
this.observers = {};
|
|
172
172
|
}
|
|
173
173
|
on(e, t) {
|
|
174
|
-
return e.split(" ").forEach((
|
|
175
|
-
this.observers[
|
|
176
|
-
const
|
|
177
|
-
this.observers[
|
|
174
|
+
return e.split(" ").forEach((s) => {
|
|
175
|
+
this.observers[s] || (this.observers[s] = /* @__PURE__ */ new Map());
|
|
176
|
+
const i = this.observers[s].get(t) || 0;
|
|
177
|
+
this.observers[s].set(t, i + 1);
|
|
178
178
|
}), this;
|
|
179
179
|
}
|
|
180
180
|
off(e, t) {
|
|
@@ -187,16 +187,16 @@ class X {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
emit(e, ...t) {
|
|
190
|
-
this.observers[e] && Array.from(this.observers[e].entries()).forEach(([
|
|
191
|
-
for (let
|
|
192
|
-
|
|
193
|
-
}), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([
|
|
194
|
-
for (let
|
|
195
|
-
|
|
190
|
+
this.observers[e] && Array.from(this.observers[e].entries()).forEach(([i, n]) => {
|
|
191
|
+
for (let a = 0; a < n; a++)
|
|
192
|
+
i(...t);
|
|
193
|
+
}), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([i, n]) => {
|
|
194
|
+
for (let a = 0; a < n; a++)
|
|
195
|
+
i.apply(i, [e, ...t]);
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
class
|
|
199
|
+
class fe extends X {
|
|
200
200
|
constructor(e, t = {
|
|
201
201
|
ns: ["translation"],
|
|
202
202
|
defaultNS: "translation"
|
|
@@ -210,38 +210,38 @@ class he extends X {
|
|
|
210
210
|
const t = this.options.ns.indexOf(e);
|
|
211
211
|
t > -1 && this.options.ns.splice(t, 1);
|
|
212
212
|
}
|
|
213
|
-
getResource(e, t,
|
|
214
|
-
var u,
|
|
215
|
-
const n =
|
|
216
|
-
let
|
|
217
|
-
e.indexOf(".") > -1 ?
|
|
218
|
-
const l = Q(this.data,
|
|
219
|
-
return !l && !t && !
|
|
213
|
+
getResource(e, t, s, i = {}) {
|
|
214
|
+
var u, f;
|
|
215
|
+
const n = i.keySeparator !== void 0 ? i.keySeparator : this.options.keySeparator, a = i.ignoreJSONStructure !== void 0 ? i.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
216
|
+
let o;
|
|
217
|
+
e.indexOf(".") > -1 ? o = e.split(".") : (o = [e, t], s && (Array.isArray(s) ? o.push(...s) : g(s) && n ? o.push(...s.split(n)) : o.push(s)));
|
|
218
|
+
const l = Q(this.data, o);
|
|
219
|
+
return !l && !t && !s && e.indexOf(".") > -1 && (e = o[0], t = o[1], s = o.slice(2).join(".")), l || !a || !g(s) ? l : ee((f = (u = this.data) == null ? void 0 : u[e]) == null ? void 0 : f[t], s, n);
|
|
220
220
|
}
|
|
221
|
-
addResource(e, t,
|
|
221
|
+
addResource(e, t, s, i, n = {
|
|
222
222
|
silent: !1
|
|
223
223
|
}) {
|
|
224
|
-
const
|
|
225
|
-
let
|
|
226
|
-
|
|
224
|
+
const a = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator;
|
|
225
|
+
let o = [e, t];
|
|
226
|
+
s && (o = o.concat(a ? s.split(a) : s)), e.indexOf(".") > -1 && (o = e.split("."), i = t, t = o[1]), this.addNamespaces(t), he(this.data, o, i), n.silent || this.emit("added", e, t, s, i);
|
|
227
227
|
}
|
|
228
|
-
addResources(e, t,
|
|
228
|
+
addResources(e, t, s, i = {
|
|
229
229
|
silent: !1
|
|
230
230
|
}) {
|
|
231
|
-
for (const n in
|
|
232
|
-
(g(
|
|
231
|
+
for (const n in s)
|
|
232
|
+
(g(s[n]) || Array.isArray(s[n])) && this.addResource(e, t, n, s[n], {
|
|
233
233
|
silent: !0
|
|
234
234
|
});
|
|
235
|
-
|
|
235
|
+
i.silent || this.emit("added", e, t, s);
|
|
236
236
|
}
|
|
237
|
-
addResourceBundle(e, t,
|
|
237
|
+
addResourceBundle(e, t, s, i, n, a = {
|
|
238
238
|
silent: !1,
|
|
239
239
|
skipCopy: !1
|
|
240
240
|
}) {
|
|
241
|
-
let
|
|
242
|
-
e.indexOf(".") > -1 && (
|
|
243
|
-
let l = Q(this.data,
|
|
244
|
-
|
|
241
|
+
let o = [e, t];
|
|
242
|
+
e.indexOf(".") > -1 && (o = e.split("."), i = s, s = t, t = o[1]), this.addNamespaces(t);
|
|
243
|
+
let l = Q(this.data, o) || {};
|
|
244
|
+
a.skipCopy || (s = JSON.parse(JSON.stringify(s))), i ? ve(l, s, n) : l = p(p({}, l), s), he(this.data, o, l), a.silent || this.emit("added", e, t, s);
|
|
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);
|
|
@@ -257,28 +257,28 @@ class he extends X {
|
|
|
257
257
|
}
|
|
258
258
|
hasLanguageSomeTranslations(e) {
|
|
259
259
|
const t = this.getDataByLanguage(e);
|
|
260
|
-
return !!(t && Object.keys(t) || []).find((
|
|
260
|
+
return !!(t && Object.keys(t) || []).find((i) => t[i] && Object.keys(t[i]).length > 0);
|
|
261
261
|
}
|
|
262
262
|
toJSON() {
|
|
263
263
|
return this.data;
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
var
|
|
266
|
+
var Ce = {
|
|
267
267
|
processors: {},
|
|
268
|
-
addPostProcessor(
|
|
269
|
-
this.processors[
|
|
268
|
+
addPostProcessor(r) {
|
|
269
|
+
this.processors[r.name] = r;
|
|
270
270
|
},
|
|
271
|
-
handle(
|
|
272
|
-
return
|
|
273
|
-
var
|
|
274
|
-
e = (
|
|
271
|
+
handle(r, e, t, s, i) {
|
|
272
|
+
return r.forEach((n) => {
|
|
273
|
+
var a, o;
|
|
274
|
+
e = (o = (a = this.processors[n]) == null ? void 0 : a.process(e, t, s, i)) != null ? o : e;
|
|
275
275
|
}), e;
|
|
276
276
|
}
|
|
277
277
|
};
|
|
278
|
-
const ce = {}, de = (
|
|
278
|
+
const ce = {}, de = (r) => !g(r) && typeof r != "boolean" && typeof r != "number";
|
|
279
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 = T.create("translator");
|
|
282
282
|
}
|
|
283
283
|
changeLanguage(e) {
|
|
284
284
|
e && (this.language = e);
|
|
@@ -286,232 +286,232 @@ class Z extends X {
|
|
|
286
286
|
exists(e, t = {
|
|
287
287
|
interpolation: {}
|
|
288
288
|
}) {
|
|
289
|
-
const
|
|
289
|
+
const s = p({}, t);
|
|
290
290
|
if (e == null) return !1;
|
|
291
|
-
const
|
|
292
|
-
return (
|
|
291
|
+
const i = this.resolve(e, s);
|
|
292
|
+
return (i == null ? void 0 : i.res) !== void 0;
|
|
293
293
|
}
|
|
294
294
|
extractFromKey(e, t) {
|
|
295
|
-
let
|
|
296
|
-
|
|
297
|
-
const
|
|
295
|
+
let s = t.nsSeparator !== void 0 ? t.nsSeparator : this.options.nsSeparator;
|
|
296
|
+
s === void 0 && (s = ":");
|
|
297
|
+
const i = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
|
|
298
298
|
let n = t.ns || this.options.defaultNS || [];
|
|
299
|
-
const
|
|
300
|
-
if (
|
|
299
|
+
const a = s && e.indexOf(s) > -1, o = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !ze(e, s, i);
|
|
300
|
+
if (a && !o) {
|
|
301
301
|
const l = e.match(this.interpolator.nestingRegexp);
|
|
302
302
|
if (l && l.length > 0)
|
|
303
303
|
return {
|
|
304
304
|
key: e,
|
|
305
305
|
namespaces: g(n) ? [n] : n
|
|
306
306
|
};
|
|
307
|
-
const u = e.split(
|
|
308
|
-
(
|
|
307
|
+
const u = e.split(s);
|
|
308
|
+
(s !== i || s === i && this.options.ns.indexOf(u[0]) > -1) && (n = u.shift()), e = u.join(i);
|
|
309
309
|
}
|
|
310
310
|
return {
|
|
311
311
|
key: e,
|
|
312
312
|
namespaces: g(n) ? [n] : n
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
|
-
translate(e, t,
|
|
316
|
-
let
|
|
317
|
-
if (typeof
|
|
315
|
+
translate(e, t, s) {
|
|
316
|
+
let i = typeof t == "object" ? p({}, t) : t;
|
|
317
|
+
if (typeof i != "object" && this.options.overloadTranslationOptionHandler && (i = this.options.overloadTranslationOptionHandler(arguments)), typeof options == "object" && (i = p({}, i)), i || (i = {}), e == null) return "";
|
|
318
318
|
Array.isArray(e) || (e = [String(e)]);
|
|
319
|
-
const n =
|
|
320
|
-
key:
|
|
319
|
+
const n = i.returnDetails !== void 0 ? i.returnDetails : this.options.returnDetails, a = i.keySeparator !== void 0 ? i.keySeparator : this.options.keySeparator, {
|
|
320
|
+
key: o,
|
|
321
321
|
namespaces: l
|
|
322
|
-
} = this.extractFromKey(e[e.length - 1],
|
|
323
|
-
let
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
if ((
|
|
322
|
+
} = this.extractFromKey(e[e.length - 1], i), u = l[l.length - 1];
|
|
323
|
+
let f = i.nsSeparator !== void 0 ? i.nsSeparator : this.options.nsSeparator;
|
|
324
|
+
f === void 0 && (f = ":");
|
|
325
|
+
const h = i.lng || this.language, m = i.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
|
-
usedParams: this.getUsedParamsDetails(
|
|
334
|
-
} : `${u}${
|
|
335
|
-
res:
|
|
336
|
-
usedKey:
|
|
337
|
-
exactUsedKey:
|
|
338
|
-
usedLng:
|
|
333
|
+
usedParams: this.getUsedParamsDetails(i)
|
|
334
|
+
} : `${u}${f}${o}` : n ? {
|
|
335
|
+
res: o,
|
|
336
|
+
usedKey: o,
|
|
337
|
+
exactUsedKey: o,
|
|
338
|
+
usedLng: h,
|
|
339
339
|
usedNS: u,
|
|
340
|
-
usedParams: this.getUsedParamsDetails(
|
|
341
|
-
} :
|
|
342
|
-
const d = this.resolve(e,
|
|
340
|
+
usedParams: this.getUsedParamsDetails(i)
|
|
341
|
+
} : o;
|
|
342
|
+
const d = this.resolve(e, i);
|
|
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 = i.joinArrays !== void 0 ? i.joinArrays : this.options.joinArrays, I = !this.i18nFormat || this.i18nFormat.handleAsObject, L = i.count !== void 0 && !g(i.count), F = Z.hasDefaultValue(i), _ = L ? this.pluralResolver.getSuffix(h, i.count, i) : "", E = i.ordinal && L ? this.pluralResolver.getSuffix(h, i.count, {
|
|
345
345
|
ordinal: !1
|
|
346
|
-
}) : "",
|
|
346
|
+
}) : "", K = L && !i.ordinal && i.count === 0, w = K && i[`defaultValue${this.options.pluralSeparator}zero`] || i[`defaultValue${_}`] || i[`defaultValue${E}`] || i.defaultValue;
|
|
347
347
|
let b = c;
|
|
348
|
-
I && !c &&
|
|
349
|
-
const
|
|
350
|
-
if (I && b &&
|
|
351
|
-
if (!
|
|
348
|
+
I && !c && F && (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
|
+
if (!i.returnObjects && !this.options.returnObjects) {
|
|
352
352
|
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
353
|
-
const k = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(x, b, O(p({},
|
|
353
|
+
const k = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(x, b, O(p({}, i), {
|
|
354
354
|
ns: l
|
|
355
|
-
})) : `key '${
|
|
356
|
-
return n ? (d.res = k, d.usedParams = this.getUsedParamsDetails(
|
|
355
|
+
})) : `key '${o} (${this.language})' returned an object instead of string.`;
|
|
356
|
+
return n ? (d.res = k, d.usedParams = this.getUsedParamsDetails(i), d) : k;
|
|
357
357
|
}
|
|
358
|
-
if (
|
|
359
|
-
const k = Array.isArray(b),
|
|
358
|
+
if (a) {
|
|
359
|
+
const k = Array.isArray(b), R = k ? [] : {}, te = k ? S : x;
|
|
360
360
|
for (const N in b)
|
|
361
361
|
if (Object.prototype.hasOwnProperty.call(b, N)) {
|
|
362
|
-
const
|
|
363
|
-
|
|
362
|
+
const j = `${te}${a}${N}`;
|
|
363
|
+
F && !c ? R[N] = this.translate(j, O(p({}, i), {
|
|
364
364
|
defaultValue: de(w) ? w[N] : void 0,
|
|
365
365
|
joinArrays: !1,
|
|
366
366
|
ns: l
|
|
367
|
-
})) :
|
|
367
|
+
})) : R[N] = this.translate(j, O(p({}, i), {
|
|
368
368
|
joinArrays: !1,
|
|
369
369
|
ns: l
|
|
370
|
-
})),
|
|
370
|
+
})), R[N] === j && (R[N] = b[N]);
|
|
371
371
|
}
|
|
372
|
-
c =
|
|
372
|
+
c = R;
|
|
373
373
|
}
|
|
374
374
|
} else if (I && g(C) && Array.isArray(c))
|
|
375
|
-
c = c.join(C), c && (c = this.extendTranslation(c, e,
|
|
375
|
+
c = c.join(C), c && (c = this.extendTranslation(c, e, i, s));
|
|
376
376
|
else {
|
|
377
|
-
let k = !1,
|
|
378
|
-
!this.isValidLookup(c) &&
|
|
379
|
-
const N = (
|
|
380
|
-
if (
|
|
381
|
-
if (this.logger.log(
|
|
382
|
-
const v = this.resolve(
|
|
377
|
+
let k = !1, R = !1;
|
|
378
|
+
!this.isValidLookup(c) && F && (k = !0, c = w), this.isValidLookup(c) || (R = !0, c = o);
|
|
379
|
+
const N = (i.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && R ? void 0 : c, j = F && w !== c && this.options.updateMissing;
|
|
380
|
+
if (R || k || j) {
|
|
381
|
+
if (this.logger.log(j ? "updateKey" : "missingKey", h, u, o, j ? w : c), a) {
|
|
382
|
+
const v = this.resolve(o, O(p({}, i), {
|
|
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 W = this.languageUtils.getFallbackCodes(this.options.fallbackLng,
|
|
387
|
+
let U = [];
|
|
388
|
+
const W = this.languageUtils.getFallbackCodes(this.options.fallbackLng, i.lng || this.language);
|
|
389
389
|
if (this.options.saveMissingTo === "fallback" && W && W[0])
|
|
390
390
|
for (let v = 0; v < W.length; v++)
|
|
391
|
-
|
|
392
|
-
else this.options.saveMissingTo === "all" ?
|
|
393
|
-
const
|
|
391
|
+
U.push(W[v]);
|
|
392
|
+
else this.options.saveMissingTo === "all" ? U = this.languageUtils.toResolveHierarchy(i.lng || this.language) : U.push(i.lng || this.language);
|
|
393
|
+
const se = (v, D, M) => {
|
|
394
394
|
var ne;
|
|
395
|
-
const
|
|
396
|
-
this.options.missingKeyHandler ? this.options.missingKeyHandler(v, u, D,
|
|
395
|
+
const ie = F && M !== c ? M : N;
|
|
396
|
+
this.options.missingKeyHandler ? this.options.missingKeyHandler(v, u, D, ie, j, i) : (ne = this.backendConnector) != null && ne.saveMissing && this.backendConnector.saveMissing(v, u, D, ie, j, i), this.emit("missingKey", v, u, D, c);
|
|
397
397
|
};
|
|
398
|
-
this.options.saveMissing && (this.options.saveMissingPlurals && L ?
|
|
399
|
-
const D = this.pluralResolver.getSuffixes(v,
|
|
400
|
-
|
|
401
|
-
|
|
398
|
+
this.options.saveMissing && (this.options.saveMissingPlurals && L ? U.forEach((v) => {
|
|
399
|
+
const D = this.pluralResolver.getSuffixes(v, i);
|
|
400
|
+
K && i[`defaultValue${this.options.pluralSeparator}zero`] && D.indexOf(`${this.options.pluralSeparator}zero`) < 0 && D.push(`${this.options.pluralSeparator}zero`), D.forEach((M) => {
|
|
401
|
+
se([v], o + M, i[`defaultValue${M}`] || w);
|
|
402
402
|
});
|
|
403
|
-
}) :
|
|
403
|
+
}) : se(U, o, w));
|
|
404
404
|
}
|
|
405
|
-
c = this.extendTranslation(c, e,
|
|
405
|
+
c = this.extendTranslation(c, e, i, d, s), 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, i));
|
|
406
406
|
}
|
|
407
|
-
return n ? (d.res = c, d.usedParams = this.getUsedParamsDetails(
|
|
407
|
+
return n ? (d.res = c, d.usedParams = this.getUsedParamsDetails(i), d) : c;
|
|
408
408
|
}
|
|
409
|
-
extendTranslation(e, t,
|
|
409
|
+
extendTranslation(e, t, s, i, n) {
|
|
410
410
|
var l, u;
|
|
411
411
|
if ((l = this.i18nFormat) != null && l.parse)
|
|
412
|
-
e = this.i18nFormat.parse(e, p(p({}, this.options.interpolation.defaultVariables),
|
|
413
|
-
resolved:
|
|
412
|
+
e = this.i18nFormat.parse(e, p(p({}, this.options.interpolation.defaultVariables), s), s.lng || this.language || i.usedLng, i.usedNS, i.usedKey, {
|
|
413
|
+
resolved: i
|
|
414
414
|
});
|
|
415
|
-
else if (!
|
|
416
|
-
|
|
417
|
-
interpolation: p(p({}, this.options.interpolation),
|
|
415
|
+
else if (!s.skipInterpolation) {
|
|
416
|
+
s.interpolation && this.interpolator.init(O(p({}, s), {
|
|
417
|
+
interpolation: p(p({}, this.options.interpolation), s.interpolation)
|
|
418
418
|
}));
|
|
419
|
-
const
|
|
420
|
-
let
|
|
421
|
-
if (
|
|
419
|
+
const f = g(e) && (((u = s == null ? void 0 : s.interpolation) == null ? void 0 : u.skipOnVariables) !== void 0 ? s.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
|
-
let m =
|
|
426
|
-
if (this.options.interpolation.defaultVariables && (m = p(p({}, this.options.interpolation.defaultVariables), m)), e = this.interpolator.interpolate(e, m,
|
|
425
|
+
let m = s.replace && !g(s.replace) ? s.replace : s;
|
|
426
|
+
if (this.options.interpolation.defaultVariables && (m = p(p({}, this.options.interpolation.defaultVariables), m)), e = this.interpolator.interpolate(e, m, s.lng || this.language || i.usedLng, s), f) {
|
|
427
427
|
const d = e.match(this.interpolator.nestingRegexp), c = d && d.length;
|
|
428
|
-
|
|
428
|
+
h < c && (s.nest = !1);
|
|
429
429
|
}
|
|
430
|
-
!
|
|
430
|
+
!s.lng && i && i.res && (s.lng = this.language || i.usedLng), s.nest !== !1 && (e = this.interpolator.nest(e, (...d) => (n == null ? void 0 : n[0]) === d[0] && !s.context ? (this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`), null) : this.translate(...d, t), s)), s.interpolation && this.interpolator.reset();
|
|
431
431
|
}
|
|
432
|
-
const
|
|
433
|
-
return e != null && (
|
|
434
|
-
i18nResolved: O(p({},
|
|
435
|
-
usedParams: this.getUsedParamsDetails(
|
|
432
|
+
const a = s.postProcess || this.options.postProcess, o = g(a) ? [a] : a;
|
|
433
|
+
return e != null && (o != null && o.length) && s.applyPostProcessor !== !1 && (e = Ce.handle(o, e, t, this.options && this.options.postProcessPassResolved ? p({
|
|
434
|
+
i18nResolved: O(p({}, i), {
|
|
435
|
+
usedParams: this.getUsedParamsDetails(s)
|
|
436
436
|
})
|
|
437
|
-
},
|
|
437
|
+
}, s) : s, this)), e;
|
|
438
438
|
}
|
|
439
439
|
resolve(e, t = {}) {
|
|
440
|
-
let
|
|
440
|
+
let s, i, n, a, o;
|
|
441
441
|
return g(e) && (e = [e]), e.forEach((l) => {
|
|
442
|
-
if (this.isValidLookup(
|
|
443
|
-
const u = this.extractFromKey(l, t),
|
|
444
|
-
|
|
445
|
-
let
|
|
446
|
-
this.options.fallbackNS && (
|
|
442
|
+
if (this.isValidLookup(s)) return;
|
|
443
|
+
const u = this.extractFromKey(l, t), f = u.key;
|
|
444
|
+
i = 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(
|
|
451
|
-
var
|
|
452
|
-
if (this.isValidLookup(
|
|
453
|
-
|
|
454
|
-
const L = [
|
|
455
|
-
if ((
|
|
456
|
-
this.i18nFormat.addLookupKeys(L,
|
|
448
|
+
h.forEach((S) => {
|
|
449
|
+
var P, C;
|
|
450
|
+
this.isValidLookup(s) || (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 "${i}" 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
|
+
if (this.isValidLookup(s)) return;
|
|
453
|
+
a = I;
|
|
454
|
+
const L = [f];
|
|
455
|
+
if ((_ = this.i18nFormat) != null && _.addLookupKeys)
|
|
456
|
+
this.i18nFormat.addLookupKeys(L, f, I, S, t);
|
|
457
457
|
else {
|
|
458
458
|
let E;
|
|
459
459
|
m && (E = this.pluralResolver.getSuffix(I, t.count, t));
|
|
460
|
-
const
|
|
461
|
-
if (m && (L.push(
|
|
462
|
-
const 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 +
|
|
460
|
+
const K = `${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 + K)), 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 + K));
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
let
|
|
467
|
-
for (;
|
|
468
|
-
this.isValidLookup(
|
|
466
|
+
let F;
|
|
467
|
+
for (; F = L.pop(); )
|
|
468
|
+
this.isValidLookup(s) || (n = F, s = this.getResource(I, S, F, t));
|
|
469
469
|
}));
|
|
470
470
|
});
|
|
471
471
|
}), {
|
|
472
|
-
res:
|
|
473
|
-
usedKey:
|
|
472
|
+
res: s,
|
|
473
|
+
usedKey: i,
|
|
474
474
|
exactUsedKey: n,
|
|
475
|
-
usedLng:
|
|
476
|
-
usedNS:
|
|
475
|
+
usedLng: a,
|
|
476
|
+
usedNS: o
|
|
477
477
|
};
|
|
478
478
|
}
|
|
479
479
|
isValidLookup(e) {
|
|
480
480
|
return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
|
|
481
481
|
}
|
|
482
|
-
getResource(e, t,
|
|
482
|
+
getResource(e, t, s, i = {}) {
|
|
483
483
|
var n;
|
|
484
|
-
return (n = this.i18nFormat) != null && n.getResource ? this.i18nFormat.getResource(e, t,
|
|
484
|
+
return (n = this.i18nFormat) != null && n.getResource ? this.i18nFormat.getResource(e, t, s, i) : this.resourceStore.getResource(e, t, s, i);
|
|
485
485
|
}
|
|
486
486
|
getUsedParamsDetails(e = {}) {
|
|
487
|
-
const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"],
|
|
488
|
-
let
|
|
489
|
-
if (
|
|
490
|
-
|
|
487
|
+
const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], s = e.replace && !g(e.replace);
|
|
488
|
+
let i = s ? e.replace : e;
|
|
489
|
+
if (s && typeof e.count != "undefined" && (i.count = e.count), this.options.interpolation.defaultVariables && (i = p(p({}, this.options.interpolation.defaultVariables), i)), !s) {
|
|
490
|
+
i = p({}, i);
|
|
491
491
|
for (const n of t)
|
|
492
|
-
delete
|
|
492
|
+
delete i[n];
|
|
493
493
|
}
|
|
494
|
-
return
|
|
494
|
+
return i;
|
|
495
495
|
}
|
|
496
496
|
static hasDefaultValue(e) {
|
|
497
497
|
const t = "defaultValue";
|
|
498
|
-
for (const
|
|
499
|
-
if (Object.prototype.hasOwnProperty.call(e,
|
|
498
|
+
for (const s in e)
|
|
499
|
+
if (Object.prototype.hasOwnProperty.call(e, s) && t === s.substring(0, t.length) && e[s] !== void 0)
|
|
500
500
|
return !0;
|
|
501
501
|
return !1;
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
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 = T.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
|
}
|
|
@@ -520,7 +520,7 @@ class pe {
|
|
|
520
520
|
let t;
|
|
521
521
|
try {
|
|
522
522
|
t = Intl.getCanonicalLocales(e)[0];
|
|
523
|
-
} catch (
|
|
523
|
+
} catch (s) {
|
|
524
524
|
}
|
|
525
525
|
return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
|
|
526
526
|
}
|
|
@@ -532,20 +532,20 @@ class pe {
|
|
|
532
532
|
getBestMatchFromCodes(e) {
|
|
533
533
|
if (!e) return null;
|
|
534
534
|
let t;
|
|
535
|
-
return e.forEach((
|
|
535
|
+
return e.forEach((s) => {
|
|
536
536
|
if (t) return;
|
|
537
|
-
const
|
|
538
|
-
(!this.options.supportedLngs || this.isSupportedCode(
|
|
539
|
-
}), !t && this.options.supportedLngs && e.forEach((
|
|
537
|
+
const i = this.formatLanguageCode(s);
|
|
538
|
+
(!this.options.supportedLngs || this.isSupportedCode(i)) && (t = i);
|
|
539
|
+
}), !t && this.options.supportedLngs && e.forEach((s) => {
|
|
540
540
|
if (t) return;
|
|
541
|
-
const
|
|
542
|
-
if (this.isSupportedCode(
|
|
543
|
-
const n = this.getLanguagePartFromCode(
|
|
541
|
+
const i = this.getScriptPartFromCode(s);
|
|
542
|
+
if (this.isSupportedCode(i)) return t = i;
|
|
543
|
+
const n = this.getLanguagePartFromCode(s);
|
|
544
544
|
if (this.isSupportedCode(n)) return t = n;
|
|
545
|
-
t = this.options.supportedLngs.find((
|
|
546
|
-
if (
|
|
547
|
-
if (!(
|
|
548
|
-
return
|
|
545
|
+
t = this.options.supportedLngs.find((a) => {
|
|
546
|
+
if (a === n) return a;
|
|
547
|
+
if (!(a.indexOf("-") < 0 && n.indexOf("-") < 0) && (a.indexOf("-") > 0 && n.indexOf("-") < 0 && a.substring(0, a.indexOf("-")) === n || a.indexOf(n) === 0 && n.length > 1))
|
|
548
|
+
return a;
|
|
549
549
|
});
|
|
550
550
|
}), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
|
|
551
551
|
}
|
|
@@ -553,16 +553,16 @@ class pe {
|
|
|
553
553
|
if (!e) return [];
|
|
554
554
|
if (typeof e == "function" && (e = e(t)), g(e) && (e = [e]), Array.isArray(e)) return e;
|
|
555
555
|
if (!t) return e.default || [];
|
|
556
|
-
let
|
|
557
|
-
return
|
|
556
|
+
let s = e[t];
|
|
557
|
+
return s || (s = e[this.getScriptPartFromCode(t)]), s || (s = e[this.formatLanguageCode(t)]), s || (s = e[this.getLanguagePartFromCode(t)]), s || (s = e.default), s || [];
|
|
558
558
|
}
|
|
559
559
|
toResolveHierarchy(e, t) {
|
|
560
|
-
const
|
|
561
|
-
|
|
560
|
+
const s = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), i = [], n = (a) => {
|
|
561
|
+
a && (this.isSupportedCode(a) ? i.push(a) : this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`));
|
|
562
562
|
};
|
|
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)),
|
|
564
|
-
|
|
565
|
-
}),
|
|
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)), s.forEach((a) => {
|
|
564
|
+
i.indexOf(a) < 0 && n(this.formatLanguageCode(a));
|
|
565
|
+
}), i;
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
const ge = {
|
|
@@ -573,14 +573,14 @@ const ge = {
|
|
|
573
573
|
many: 4,
|
|
574
574
|
other: 5
|
|
575
575
|
}, me = {
|
|
576
|
-
select: (
|
|
576
|
+
select: (r) => r === 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 = T.create("pluralResolver"), this.pluralRulesCache = {};
|
|
584
584
|
}
|
|
585
585
|
addRule(e, t) {
|
|
586
586
|
this.rules[e] = t;
|
|
@@ -589,50 +589,50 @@ class Be {
|
|
|
589
589
|
this.pluralRulesCache = {};
|
|
590
590
|
}
|
|
591
591
|
getRule(e, t = {}) {
|
|
592
|
-
const
|
|
593
|
-
cleanedCode:
|
|
594
|
-
type:
|
|
592
|
+
const s = z(e === "dev" ? "en" : e), i = t.ordinal ? "ordinal" : "cardinal", n = JSON.stringify({
|
|
593
|
+
cleanedCode: s,
|
|
594
|
+
type: i
|
|
595
595
|
});
|
|
596
596
|
if (n in this.pluralRulesCache)
|
|
597
597
|
return this.pluralRulesCache[n];
|
|
598
|
-
let
|
|
598
|
+
let a;
|
|
599
599
|
try {
|
|
600
|
-
|
|
601
|
-
type:
|
|
600
|
+
a = new Intl.PluralRules(s, {
|
|
601
|
+
type: i
|
|
602
602
|
});
|
|
603
|
-
} catch (
|
|
603
|
+
} catch (o) {
|
|
604
604
|
if (!Intl)
|
|
605
605
|
return this.logger.error("No Intl support, please use an Intl polyfill!"), me;
|
|
606
606
|
if (!e.match(/-|_/)) return me;
|
|
607
607
|
const l = this.languageUtils.getLanguagePartFromCode(e);
|
|
608
|
-
|
|
608
|
+
a = this.getRule(l, t);
|
|
609
609
|
}
|
|
610
|
-
return this.pluralRulesCache[n] =
|
|
610
|
+
return this.pluralRulesCache[n] = a, a;
|
|
611
611
|
}
|
|
612
612
|
needsPlural(e, t = {}) {
|
|
613
|
-
let
|
|
614
|
-
return
|
|
613
|
+
let s = this.getRule(e, t);
|
|
614
|
+
return s || (s = this.getRule("dev", t)), (s == null ? void 0 : s.resolvedOptions().pluralCategories.length) > 1;
|
|
615
615
|
}
|
|
616
|
-
getPluralFormsOfKey(e, t,
|
|
617
|
-
return this.getSuffixes(e,
|
|
616
|
+
getPluralFormsOfKey(e, t, s = {}) {
|
|
617
|
+
return this.getSuffixes(e, s).map((i) => `${t}${i}`);
|
|
618
618
|
}
|
|
619
619
|
getSuffixes(e, t = {}) {
|
|
620
|
-
let
|
|
621
|
-
return
|
|
620
|
+
let s = this.getRule(e, t);
|
|
621
|
+
return s || (s = this.getRule("dev", t)), s ? s.resolvedOptions().pluralCategories.sort((i, n) => ge[i] - ge[n]).map((i) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${i}`) : [];
|
|
622
622
|
}
|
|
623
|
-
getSuffix(e, t,
|
|
624
|
-
const
|
|
625
|
-
return
|
|
623
|
+
getSuffix(e, t, s = {}) {
|
|
624
|
+
const i = this.getRule(e, s);
|
|
625
|
+
return i ? `${this.options.prepend}${s.ordinal ? `ordinal${this.options.prepend}` : ""}${i.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, s));
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
|
-
const xe = (
|
|
629
|
-
let n =
|
|
630
|
-
return !n &&
|
|
631
|
-
}, q = (
|
|
632
|
-
class
|
|
628
|
+
const xe = (r, e, t, s = ".", i = !0) => {
|
|
629
|
+
let n = Ae(r, e, t);
|
|
630
|
+
return !n && i && g(t) && (n = ee(r, t, s), n === void 0 && (n = ee(e, t, s))), n;
|
|
631
|
+
}, q = (r) => r.replace(/\$/g, "$$$$");
|
|
632
|
+
class We {
|
|
633
633
|
constructor(e = {}) {
|
|
634
634
|
var t;
|
|
635
|
-
this.logger =
|
|
635
|
+
this.logger = T.create("interpolator"), this.options = e, this.format = ((t = e == null ? void 0 : e.interpolation) == null ? void 0 : t.format) || ((s) => s), this.init(e);
|
|
636
636
|
}
|
|
637
637
|
init(e = {}) {
|
|
638
638
|
e.interpolation || (e.interpolation = {
|
|
@@ -640,49 +640,49 @@ class ze {
|
|
|
640
640
|
});
|
|
641
641
|
const {
|
|
642
642
|
escape: t,
|
|
643
|
-
escapeValue:
|
|
644
|
-
useRawValueToEscape:
|
|
643
|
+
escapeValue: s,
|
|
644
|
+
useRawValueToEscape: i,
|
|
645
645
|
prefix: n,
|
|
646
|
-
prefixEscaped:
|
|
647
|
-
suffix:
|
|
646
|
+
prefixEscaped: a,
|
|
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 = s !== void 0 ? s : !0, this.useRawValueToEscape = i !== void 0 ? i : !1, this.prefix = n ? V(n) : a || "{{", 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);
|
|
664
664
|
}
|
|
665
665
|
resetRegExp() {
|
|
666
|
-
const e = (t,
|
|
666
|
+
const e = (t, s) => (t == null ? void 0 : t.source) === s ? (t.lastIndex = 0, t) : new RegExp(s, "g");
|
|
667
667
|
this.regexp = e(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = e(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = e(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
|
|
668
668
|
}
|
|
669
|
-
interpolate(e, t,
|
|
669
|
+
interpolate(e, t, s, i) {
|
|
670
670
|
var d;
|
|
671
|
-
let n,
|
|
671
|
+
let n, a, 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
674
|
const C = xe(t, l, c, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
675
|
-
return this.alwaysFormat ? this.format(C, void 0,
|
|
675
|
+
return this.alwaysFormat ? this.format(C, void 0, s, O(p(p({}, i), 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(xe(t, l, S, this.options.keySeparator, this.options.ignoreJSONStructure),
|
|
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, s, O(p(p({}, i), t), {
|
|
681
681
|
interpolationkey: S
|
|
682
682
|
}));
|
|
683
683
|
};
|
|
684
684
|
this.resetRegExp();
|
|
685
|
-
const
|
|
685
|
+
const f = (i == null ? void 0 : i.missingInterpolationHandler) || this.options.missingInterpolationHandler, h = ((d = i == null ? void 0 : i.interpolation) == null ? void 0 : d.skipOnVariables) !== void 0 ? i.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
686
686
|
return [{
|
|
687
687
|
regex: this.regexpUnescape,
|
|
688
688
|
safeValue: (c) => q(c)
|
|
@@ -690,67 +690,67 @@ class ze {
|
|
|
690
690
|
regex: this.regexp,
|
|
691
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
|
-
if (
|
|
696
|
-
if (typeof
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
} else if (
|
|
700
|
-
|
|
701
|
-
else if (
|
|
702
|
-
|
|
695
|
+
if (a = u(x), a === void 0)
|
|
696
|
+
if (typeof f == "function") {
|
|
697
|
+
const P = f(e, n, i);
|
|
698
|
+
a = g(P) ? P : "";
|
|
699
|
+
} else if (i && Object.prototype.hasOwnProperty.call(i, x))
|
|
700
|
+
a = "";
|
|
701
|
+
else if (h) {
|
|
702
|
+
a = n[0];
|
|
703
703
|
continue;
|
|
704
704
|
} else
|
|
705
|
-
this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),
|
|
706
|
-
else !g(
|
|
707
|
-
const S = c.safeValue(
|
|
708
|
-
if (e = e.replace(n[0], S),
|
|
705
|
+
this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`), a = "";
|
|
706
|
+
else !g(a) && !this.useRawValueToEscape && (a = oe(a));
|
|
707
|
+
const S = c.safeValue(a);
|
|
708
|
+
if (e = e.replace(n[0], S), h ? (c.regex.lastIndex += a.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
|
-
nest(e, t,
|
|
714
|
-
let
|
|
715
|
-
const
|
|
713
|
+
nest(e, t, s = {}) {
|
|
714
|
+
let i, n, a;
|
|
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, a);
|
|
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
|
+
a = JSON.parse(m), u && (a = p(p({}, u), a));
|
|
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
|
-
return
|
|
729
|
+
return a.defaultValue && a.defaultValue.indexOf(this.prefix) > -1 && delete a.defaultValue, l;
|
|
730
730
|
};
|
|
731
|
-
for (;
|
|
731
|
+
for (; i = this.nestingRegexp.exec(e); ) {
|
|
732
732
|
let l = [];
|
|
733
|
-
|
|
734
|
-
const u = /{.*}/.test(
|
|
735
|
-
if (u !== -1 && (l =
|
|
736
|
-
g(n) || (n = oe(n)), n || (this.logger.warn(`missed to resolve ${
|
|
737
|
-
interpolationkey:
|
|
738
|
-
})), n.trim())), e = e.replace(
|
|
733
|
+
a = p({}, s), a = a.replace && !g(a.replace) ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue;
|
|
734
|
+
const u = /{.*}/.test(i[1]) ? i[1].lastIndexOf("}") + 1 : i[1].indexOf(this.formatSeparator);
|
|
735
|
+
if (u !== -1 && (l = i[1].slice(u).split(this.formatSeparator).map((f) => f.trim()).filter(Boolean), i[1] = i[1].slice(0, u)), n = t(o.call(this, i[1].trim(), a), a), n && i[0] === e && !g(n)) return n;
|
|
736
|
+
g(n) || (n = oe(n)), n || (this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`), n = ""), l.length && (n = l.reduce((f, h) => this.format(f, h, s.lng, O(p({}, s), {
|
|
737
|
+
interpolationkey: i[1].trim()
|
|
738
|
+
})), n.trim())), e = e.replace(i[0], n), this.regexp.lastIndex = 0;
|
|
739
739
|
}
|
|
740
740
|
return e;
|
|
741
741
|
}
|
|
742
742
|
}
|
|
743
|
-
const
|
|
744
|
-
let e =
|
|
743
|
+
const Ye = (r) => {
|
|
744
|
+
let e = r.toLowerCase().trim();
|
|
745
745
|
const t = {};
|
|
746
|
-
if (
|
|
747
|
-
const
|
|
748
|
-
e =
|
|
749
|
-
const
|
|
750
|
-
e === "currency" &&
|
|
751
|
-
if (
|
|
752
|
-
const [
|
|
753
|
-
t[
|
|
746
|
+
if (r.indexOf("(") > -1) {
|
|
747
|
+
const s = r.split("(");
|
|
748
|
+
e = s[0].toLowerCase().trim();
|
|
749
|
+
const i = s[1].substring(0, s[1].length - 1);
|
|
750
|
+
e === "currency" && i.indexOf(":") < 0 ? t.currency || (t.currency = i.trim()) : e === "relativetime" && i.indexOf(":") < 0 ? t.range || (t.range = i.trim()) : i.split(";").forEach((a) => {
|
|
751
|
+
if (a) {
|
|
752
|
+
const [o, ...l] = a.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,49 +758,49 @@ const Je = (o) => {
|
|
|
758
758
|
formatName: e,
|
|
759
759
|
formatOptions: t
|
|
760
760
|
};
|
|
761
|
-
}, ye = (
|
|
761
|
+
}, ye = (r) => {
|
|
762
762
|
const e = {};
|
|
763
|
-
return (t,
|
|
764
|
-
let n =
|
|
765
|
-
|
|
766
|
-
[
|
|
763
|
+
return (t, s, i) => {
|
|
764
|
+
let n = i;
|
|
765
|
+
i && i.interpolationkey && i.formatParams && i.formatParams[i.interpolationkey] && i[i.interpolationkey] && (n = O(p({}, n), {
|
|
766
|
+
[i.interpolationkey]: void 0
|
|
767
767
|
}));
|
|
768
|
-
const
|
|
769
|
-
let
|
|
770
|
-
return
|
|
768
|
+
const a = s + JSON.stringify(n);
|
|
769
|
+
let o = e[a];
|
|
770
|
+
return o || (o = r(z(s), i), e[a] = o), o(t);
|
|
771
771
|
};
|
|
772
|
-
},
|
|
773
|
-
class
|
|
772
|
+
}, Qe = (r) => (e, t, s) => r(z(t), s)(e);
|
|
773
|
+
class Ge {
|
|
774
774
|
constructor(e = {}) {
|
|
775
|
-
this.logger =
|
|
775
|
+
this.logger = T.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
|
|
781
|
+
const s = t.cacheInBuiltFormats ? ye : Qe;
|
|
782
782
|
this.formats = {
|
|
783
|
-
number:
|
|
784
|
-
const
|
|
785
|
-
return (
|
|
783
|
+
number: s((i, n) => {
|
|
784
|
+
const a = new Intl.NumberFormat(i, p({}, n));
|
|
785
|
+
return (o) => a.format(o);
|
|
786
786
|
}),
|
|
787
|
-
currency:
|
|
788
|
-
const
|
|
787
|
+
currency: s((i, n) => {
|
|
788
|
+
const a = new Intl.NumberFormat(i, O(p({}, n), {
|
|
789
789
|
style: "currency"
|
|
790
790
|
}));
|
|
791
|
-
return (
|
|
791
|
+
return (o) => a.format(o);
|
|
792
792
|
}),
|
|
793
|
-
datetime:
|
|
794
|
-
const
|
|
795
|
-
return (
|
|
793
|
+
datetime: s((i, n) => {
|
|
794
|
+
const a = new Intl.DateTimeFormat(i, p({}, n));
|
|
795
|
+
return (o) => a.format(o);
|
|
796
796
|
}),
|
|
797
|
-
relativetime:
|
|
798
|
-
const
|
|
799
|
-
return (
|
|
797
|
+
relativetime: s((i, n) => {
|
|
798
|
+
const a = new Intl.RelativeTimeFormat(i, p({}, n));
|
|
799
|
+
return (o) => a.format(o, n.range || "day");
|
|
800
800
|
}),
|
|
801
|
-
list:
|
|
802
|
-
const
|
|
803
|
-
return (
|
|
801
|
+
list: s((i, n) => {
|
|
802
|
+
const a = new Intl.ListFormat(i, p({}, n));
|
|
803
|
+
return (o) => a.format(o);
|
|
804
804
|
})
|
|
805
805
|
};
|
|
806
806
|
}
|
|
@@ -810,164 +810,164 @@ class _e {
|
|
|
810
810
|
addCached(e, t) {
|
|
811
811
|
this.formats[e.toLowerCase().trim()] = ye(t);
|
|
812
812
|
}
|
|
813
|
-
format(e, t,
|
|
813
|
+
format(e, t, s, i = {}) {
|
|
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 = i == null ? void 0 : i.formatParams) == null ? void 0 : h[i.interpolationkey]) || {}, c = d.locale || d.lng || i.locale || i.lng || s;
|
|
829
|
+
m = this.formats[u](o, c, p(p(p({}, f), i), 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 = (r, e) => {
|
|
841
|
+
r.pending[e] !== void 0 && (delete r.pending[e], r.pendingCount--);
|
|
842
842
|
};
|
|
843
|
-
class
|
|
844
|
-
constructor(e, t,
|
|
845
|
-
var n,
|
|
846
|
-
super(), this.backend = e, this.store = t, this.services =
|
|
843
|
+
class Xe extends X {
|
|
844
|
+
constructor(e, t, s, i = {}) {
|
|
845
|
+
var n, a;
|
|
846
|
+
super(), this.backend = e, this.store = t, this.services = s, this.languageUtils = s.languageUtils, this.options = i, this.logger = T.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = i.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = i.maxRetries >= 0 ? i.maxRetries : 5, this.retryTimeout = i.retryTimeout >= 1 ? i.retryTimeout : 350, this.state = {}, this.queue = [], (a = (n = this.backend) == null ? void 0 : n.init) == null || a.call(n, s, i.backend, i);
|
|
847
847
|
}
|
|
848
|
-
queueLoad(e, t,
|
|
849
|
-
const n = {},
|
|
848
|
+
queueLoad(e, t, s, i) {
|
|
849
|
+
const n = {}, a = {}, o = {}, l = {};
|
|
850
850
|
return e.forEach((u) => {
|
|
851
|
-
let
|
|
852
|
-
t.forEach((
|
|
853
|
-
const m = `${u}|${
|
|
854
|
-
!
|
|
855
|
-
}),
|
|
856
|
-
}), (Object.keys(n).length || Object.keys(
|
|
857
|
-
pending:
|
|
858
|
-
pendingCount: Object.keys(
|
|
851
|
+
let f = !0;
|
|
852
|
+
t.forEach((h) => {
|
|
853
|
+
const m = `${u}|${h}`;
|
|
854
|
+
!s.reload && this.store.hasResourceBundle(u, h) ? this.state[m] = 2 : this.state[m] < 0 || (this.state[m] === 1 ? a[m] === void 0 && (a[m] = !0) : (this.state[m] = 1, f = !1, a[m] === void 0 && (a[m] = !0), n[m] === void 0 && (n[m] = !0), l[h] === void 0 && (l[h] = !0)));
|
|
855
|
+
}), f || (o[u] = !0);
|
|
856
|
+
}), (Object.keys(n).length || Object.keys(a).length) && this.queue.push({
|
|
857
|
+
pending: a,
|
|
858
|
+
pendingCount: Object.keys(a).length,
|
|
859
859
|
loaded: {},
|
|
860
860
|
errors: [],
|
|
861
|
-
callback:
|
|
861
|
+
callback: i
|
|
862
862
|
}), {
|
|
863
863
|
toLoad: Object.keys(n),
|
|
864
|
-
pending: Object.keys(
|
|
865
|
-
toLoadLanguages: Object.keys(
|
|
864
|
+
pending: Object.keys(a),
|
|
865
|
+
toLoadLanguages: Object.keys(o),
|
|
866
866
|
toLoadNamespaces: Object.keys(l)
|
|
867
867
|
};
|
|
868
868
|
}
|
|
869
|
-
loaded(e, t,
|
|
870
|
-
const
|
|
871
|
-
t && this.emit("failedLoading", n,
|
|
869
|
+
loaded(e, t, s) {
|
|
870
|
+
const i = e.split("|"), n = i[0], a = i[1];
|
|
871
|
+
t && this.emit("failedLoading", n, a, t), !t && s && this.store.addResourceBundle(n, a, s, void 0, void 0, {
|
|
872
872
|
skipCopy: !0
|
|
873
|
-
}), this.state[e] = t ? -1 : 2, t &&
|
|
874
|
-
const
|
|
873
|
+
}), this.state[e] = t ? -1 : 2, t && s && (this.state[e] = 0);
|
|
874
|
+
const o = {};
|
|
875
875
|
this.queue.forEach((l) => {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
|
|
876
|
+
Ve(l.loaded, [n], a), 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
|
-
read(e, t,
|
|
886
|
-
if (!e.length) return
|
|
885
|
+
read(e, t, s, i = 0, n = this.retryTimeout, a) {
|
|
886
|
+
if (!e.length) return a(null, {});
|
|
887
887
|
if (this.readingCalls >= this.maxParallelReads) {
|
|
888
888
|
this.waitingReads.push({
|
|
889
889
|
lng: e,
|
|
890
890
|
ns: t,
|
|
891
|
-
fcName:
|
|
892
|
-
tried:
|
|
891
|
+
fcName: s,
|
|
892
|
+
tried: i,
|
|
893
893
|
wait: n,
|
|
894
|
-
callback:
|
|
894
|
+
callback: a
|
|
895
895
|
});
|
|
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 && i < this.maxRetries) {
|
|
905
905
|
setTimeout(() => {
|
|
906
|
-
this.read.call(this, e, t,
|
|
906
|
+
this.read.call(this, e, t, s, i + 1, n * 2, a);
|
|
907
907
|
}, n);
|
|
908
908
|
return;
|
|
909
909
|
}
|
|
910
|
-
|
|
911
|
-
}, l = this.backend[
|
|
910
|
+
a(u, f);
|
|
911
|
+
}, l = this.backend[s].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
|
-
prepareLoading(e, t,
|
|
923
|
+
prepareLoading(e, t, s = {}, i) {
|
|
924
924
|
if (!this.backend)
|
|
925
|
-
return this.logger.warn("No backend was added via i18next.use. Will not load resources."),
|
|
925
|
+
return this.logger.warn("No backend was added via i18next.use. Will not load resources."), i && i();
|
|
926
926
|
g(e) && (e = this.languageUtils.toResolveHierarchy(e)), g(t) && (t = [t]);
|
|
927
|
-
const n = this.queueLoad(e, t,
|
|
927
|
+
const n = this.queueLoad(e, t, s, i);
|
|
928
928
|
if (!n.toLoad.length)
|
|
929
|
-
return n.pending.length ||
|
|
930
|
-
n.toLoad.forEach((
|
|
931
|
-
this.loadOne(
|
|
929
|
+
return n.pending.length || i(), null;
|
|
930
|
+
n.toLoad.forEach((a) => {
|
|
931
|
+
this.loadOne(a);
|
|
932
932
|
});
|
|
933
933
|
}
|
|
934
|
-
load(e, t,
|
|
935
|
-
this.prepareLoading(e, t, {},
|
|
934
|
+
load(e, t, s) {
|
|
935
|
+
this.prepareLoading(e, t, {}, s);
|
|
936
936
|
}
|
|
937
|
-
reload(e, t,
|
|
937
|
+
reload(e, t, s) {
|
|
938
938
|
this.prepareLoading(e, t, {
|
|
939
939
|
reload: !0
|
|
940
|
-
},
|
|
940
|
+
}, s);
|
|
941
941
|
}
|
|
942
942
|
loadOne(e, t = "") {
|
|
943
|
-
const
|
|
944
|
-
this.read(
|
|
945
|
-
|
|
943
|
+
const s = e.split("|"), i = s[0], n = s[1];
|
|
944
|
+
this.read(i, n, "read", void 0, void 0, (a, o) => {
|
|
945
|
+
a && this.logger.warn(`${t}loading namespace ${n} for language ${i} failed`, a), !a && o && this.logger.log(`${t}loaded namespace ${n} for language ${i}`, o), this.loaded(e, a, o);
|
|
946
946
|
});
|
|
947
947
|
}
|
|
948
|
-
saveMissing(e, t,
|
|
948
|
+
saveMissing(e, t, s, i, n, a = {}, o = () => {
|
|
949
949
|
}) {
|
|
950
|
-
var l, u,
|
|
951
|
-
if ((u = (l = this.services) == null ? void 0 : l.utils) != null && u.hasLoadedNamespace && !((
|
|
952
|
-
this.logger.warn(`did not save key "${
|
|
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
|
+
this.logger.warn(`did not save key "${s}" 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
|
}
|
|
955
|
-
if (!(
|
|
955
|
+
if (!(s == null || s === "")) {
|
|
956
956
|
if ((m = this.backend) != null && m.create) {
|
|
957
|
-
const d = O(p({},
|
|
957
|
+
const d = O(p({}, a), {
|
|
958
958
|
isUpdate: n
|
|
959
959
|
}), c = this.backend.create.bind(this.backend);
|
|
960
960
|
if (c.length < 6)
|
|
961
961
|
try {
|
|
962
962
|
let x;
|
|
963
|
-
c.length === 5 ? x = c(e, t,
|
|
963
|
+
c.length === 5 ? x = c(e, t, s, i, d) : x = c(e, t, s, i), 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,
|
|
968
|
+
c(e, t, s, i, o, d);
|
|
969
969
|
}
|
|
970
|
-
!e || !e[0] || this.store.addResource(e[0], t,
|
|
970
|
+
!e || !e[0] || this.store.addResource(e[0], t, s, i);
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
973
|
}
|
|
@@ -1004,19 +1004,19 @@ const Se = () => ({
|
|
|
1004
1004
|
parseMissingKeyHandler: !1,
|
|
1005
1005
|
appendNamespaceToMissingKey: !1,
|
|
1006
1006
|
appendNamespaceToCIMode: !1,
|
|
1007
|
-
overloadTranslationOptionHandler: (
|
|
1007
|
+
overloadTranslationOptionHandler: (r) => {
|
|
1008
1008
|
let e = {};
|
|
1009
|
-
if (typeof
|
|
1010
|
-
const t =
|
|
1011
|
-
Object.keys(t).forEach((
|
|
1012
|
-
e[
|
|
1009
|
+
if (typeof r[1] == "object" && (e = r[1]), g(r[1]) && (e.defaultValue = r[1]), g(r[2]) && (e.tDescription = r[2]), typeof r[2] == "object" || typeof r[3] == "object") {
|
|
1010
|
+
const t = r[3] || r[2];
|
|
1011
|
+
Object.keys(t).forEach((s) => {
|
|
1012
|
+
e[s] = t[s];
|
|
1013
1013
|
});
|
|
1014
1014
|
}
|
|
1015
1015
|
return e;
|
|
1016
1016
|
},
|
|
1017
1017
|
interpolation: {
|
|
1018
1018
|
escapeValue: !0,
|
|
1019
|
-
format: (
|
|
1019
|
+
format: (r) => r,
|
|
1020
1020
|
prefix: "{{",
|
|
1021
1021
|
suffix: "}}",
|
|
1022
1022
|
formatSeparator: ",",
|
|
@@ -1028,20 +1028,20 @@ const Se = () => ({
|
|
|
1028
1028
|
skipOnVariables: !0
|
|
1029
1029
|
},
|
|
1030
1030
|
cacheInBuiltFormats: !0
|
|
1031
|
-
}), be = (
|
|
1031
|
+
}), be = (r) => {
|
|
1032
1032
|
var e, t;
|
|
1033
|
-
return g(
|
|
1034
|
-
},
|
|
1035
|
-
},
|
|
1036
|
-
Object.getOwnPropertyNames(Object.getPrototypeOf(
|
|
1037
|
-
typeof
|
|
1033
|
+
return g(r.ns) && (r.ns = [r.ns]), g(r.fallbackLng) && (r.fallbackLng = [r.fallbackLng]), g(r.fallbackNS) && (r.fallbackNS = [r.fallbackNS]), ((t = (e = r.supportedLngs) == null ? void 0 : e.indexOf) == null ? void 0 : t.call(e, "cimode")) < 0 && (r.supportedLngs = r.supportedLngs.concat(["cimode"])), typeof r.initImmediate == "boolean" && (r.initAsync = r.initImmediate), r;
|
|
1034
|
+
}, Y = () => {
|
|
1035
|
+
}, qe = (r) => {
|
|
1036
|
+
Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach((t) => {
|
|
1037
|
+
typeof r[t] == "function" && (r[t] = r[t].bind(r));
|
|
1038
1038
|
});
|
|
1039
1039
|
};
|
|
1040
|
-
class
|
|
1040
|
+
class J extends X {
|
|
1041
1041
|
constructor(e = {}, t) {
|
|
1042
|
-
if (super(), this.options = be(e), this.services = {}, this.logger =
|
|
1042
|
+
if (super(), this.options = be(e), this.services = {}, this.logger = T, 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,82 +1051,82 @@ class z extends X {
|
|
|
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
|
|
1055
|
-
this.options = p(p(p({},
|
|
1056
|
-
const
|
|
1054
|
+
const s = Se();
|
|
1055
|
+
this.options = p(p(p({}, s), this.options), be(e)), this.options.interpolation = p(p({}, s.interpolation), this.options.interpolation), e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator);
|
|
1056
|
+
const i = (u) => u ? typeof u == "function" ? new u() : u : null;
|
|
1057
1057
|
if (!this.options.isClone) {
|
|
1058
|
-
this.modules.logger ?
|
|
1058
|
+
this.modules.logger ? T.init(i(this.modules.logger), this.options) : T.init(null, this.options);
|
|
1059
1059
|
let u;
|
|
1060
|
-
this.modules.formatter ? u = this.modules.formatter : u =
|
|
1061
|
-
const
|
|
1062
|
-
this.store = new
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1060
|
+
this.modules.formatter ? u = this.modules.formatter : u = Ge;
|
|
1061
|
+
const f = new pe(this.options);
|
|
1062
|
+
this.store = new fe(this.options.resources, this.options);
|
|
1063
|
+
const h = this.services;
|
|
1064
|
+
h.logger = T, 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 !==
|
|
1067
|
+
}), this.options.interpolation.format && this.options.interpolation.format !== s.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 === s.interpolation.format) && (h.formatter = i(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(i(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 = i(this.modules.languageDetector), h.languageDetector.init && h.languageDetector.init(h, this.options.detection, this.options)), this.modules.i18nFormat && (h.i18nFormat = i(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 = H(), 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),
|
|
1094
|
-
}
|
|
1095
|
-
loadResources(e, t =
|
|
1096
|
-
var n,
|
|
1097
|
-
let
|
|
1098
|
-
const
|
|
1099
|
-
if (typeof e == "function" && (
|
|
1100
|
-
if ((
|
|
1101
|
-
const
|
|
1093
|
+
return this.options.resources || !this.options.initAsync ? l() : setTimeout(l, 0), o;
|
|
1094
|
+
}
|
|
1095
|
+
loadResources(e, t = Y) {
|
|
1096
|
+
var n, a;
|
|
1097
|
+
let s = t;
|
|
1098
|
+
const i = g(e) ? e : this.language;
|
|
1099
|
+
if (typeof e == "function" && (s = e), !this.options.resources || this.options.partialBundledLanguages) {
|
|
1100
|
+
if ((i == null ? void 0 : i.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return s();
|
|
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
|
-
|
|
1108
|
-
!u && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language),
|
|
1107
|
+
i ? l(i) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((f) => l(f)), (a = (n = this.options.preload) == null ? void 0 : n.forEach) == null || a.call(n, (u) => l(u)), this.services.backendConnector.load(o, this.options.ns, (u) => {
|
|
1108
|
+
!u && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), s(u);
|
|
1109
1109
|
});
|
|
1110
1110
|
} else
|
|
1111
|
-
|
|
1111
|
+
s(null);
|
|
1112
1112
|
}
|
|
1113
|
-
reloadResources(e, t,
|
|
1114
|
-
const
|
|
1115
|
-
return typeof e == "function" && (
|
|
1116
|
-
|
|
1117
|
-
}),
|
|
1113
|
+
reloadResources(e, t, s) {
|
|
1114
|
+
const i = H();
|
|
1115
|
+
return typeof e == "function" && (s = e, e = void 0), typeof t == "function" && (s = t, t = void 0), e || (e = this.languages), t || (t = this.options.ns), s || (s = Y), this.services.backendConnector.reload(e, t, (n) => {
|
|
1116
|
+
i.resolve(), s(n);
|
|
1117
|
+
}), i;
|
|
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)) {
|
|
1126
1126
|
for (let t = 0; t < this.languages.length; t++) {
|
|
1127
|
-
const
|
|
1128
|
-
if (!(["cimode", "dev"].indexOf(
|
|
1129
|
-
this.resolvedLanguage =
|
|
1127
|
+
const s = this.languages[t];
|
|
1128
|
+
if (!(["cimode", "dev"].indexOf(s) > -1) && this.store.hasLanguageSomeTranslations(s)) {
|
|
1129
|
+
this.resolvedLanguage = s;
|
|
1130
1130
|
break;
|
|
1131
1131
|
}
|
|
1132
1132
|
}
|
|
@@ -1135,31 +1135,31 @@ class z extends X {
|
|
|
1135
1135
|
}
|
|
1136
1136
|
changeLanguage(e, t) {
|
|
1137
1137
|
this.isLanguageChangingTo = e;
|
|
1138
|
-
const
|
|
1138
|
+
const s = H();
|
|
1139
1139
|
this.emit("languageChanging", e);
|
|
1140
|
-
const
|
|
1141
|
-
this.language =
|
|
1142
|
-
}, n = (
|
|
1143
|
-
l ? this.isLanguageChangingTo === e && (
|
|
1144
|
-
},
|
|
1145
|
-
var
|
|
1146
|
-
!e && !
|
|
1147
|
-
const l = g(
|
|
1148
|
-
u && (this.language ||
|
|
1140
|
+
const i = (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 && (i(l), this.translator.changeLanguage(l), this.isLanguageChangingTo = void 0, this.emit("languageChanged", l), this.logger.log("languageChanged", l)) : this.isLanguageChangingTo = void 0, s.resolve((...u) => this.t(...u)), t && t(o, (...u) => this.t(...u));
|
|
1144
|
+
}, a = (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 || i(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
|
-
return !e && this.services.languageDetector && !this.services.languageDetector.async ?
|
|
1152
|
+
return !e && this.services.languageDetector && !this.services.languageDetector.async ? a(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(a) : this.services.languageDetector.detect(a) : a(e), s;
|
|
1153
1153
|
}
|
|
1154
|
-
getFixedT(e, t,
|
|
1155
|
-
const
|
|
1154
|
+
getFixedT(e, t, s) {
|
|
1155
|
+
const i = (n, a, ...o) => {
|
|
1156
1156
|
let l;
|
|
1157
|
-
typeof
|
|
1157
|
+
typeof a != "object" ? l = this.options.overloadTranslationOptionHandler([n, a].concat(o)) : l = p({}, a), l.lng = l.lng || i.lng, l.lngs = l.lngs || i.lngs, l.ns = l.ns || i.ns, l.keyPrefix !== "" && (l.keyPrefix = l.keyPrefix || s || i.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
|
-
return g(e) ?
|
|
1162
|
+
return g(e) ? i.lng = e : i.lngs = e, i.ns = t, i.keyPrefix = s, i;
|
|
1163
1163
|
}
|
|
1164
1164
|
t(...e) {
|
|
1165
1165
|
var t;
|
|
@@ -1177,68 +1177,68 @@ class z extends X {
|
|
|
1177
1177
|
return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
|
|
1178
1178
|
if (!this.languages || !this.languages.length)
|
|
1179
1179
|
return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
|
|
1180
|
-
const
|
|
1181
|
-
if (
|
|
1182
|
-
const
|
|
1183
|
-
const u = this.services.backendConnector.state[`${
|
|
1180
|
+
const s = t.lng || this.resolvedLanguage || this.languages[0], i = this.options ? this.options.fallbackLng : !1, n = this.languages[this.languages.length - 1];
|
|
1181
|
+
if (s.toLowerCase() === "cimode") return !0;
|
|
1182
|
+
const a = (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, a);
|
|
1188
|
+
if (o !== void 0) return o;
|
|
1189
1189
|
}
|
|
1190
|
-
return !!(this.hasResourceBundle(
|
|
1190
|
+
return !!(this.hasResourceBundle(s, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(s, e) && (!i || a(n, e)));
|
|
1191
1191
|
}
|
|
1192
1192
|
loadNamespaces(e, t) {
|
|
1193
|
-
const
|
|
1194
|
-
return this.options.ns ? (g(e) && (e = [e]), e.forEach((
|
|
1195
|
-
this.options.ns.indexOf(
|
|
1196
|
-
}), this.loadResources((
|
|
1197
|
-
|
|
1198
|
-
}),
|
|
1193
|
+
const s = H();
|
|
1194
|
+
return this.options.ns ? (g(e) && (e = [e]), e.forEach((i) => {
|
|
1195
|
+
this.options.ns.indexOf(i) < 0 && this.options.ns.push(i);
|
|
1196
|
+
}), this.loadResources((i) => {
|
|
1197
|
+
s.resolve(), t && t(i);
|
|
1198
|
+
}), s) : (t && t(), Promise.resolve());
|
|
1199
1199
|
}
|
|
1200
1200
|
loadLanguages(e, t) {
|
|
1201
|
-
const
|
|
1201
|
+
const s = H();
|
|
1202
1202
|
g(e) && (e = [e]);
|
|
1203
|
-
const
|
|
1204
|
-
return n.length ? (this.options.preload =
|
|
1205
|
-
|
|
1206
|
-
}),
|
|
1203
|
+
const i = this.options.preload || [], n = e.filter((a) => i.indexOf(a) < 0 && this.services.languageUtils.isSupportedCode(a));
|
|
1204
|
+
return n.length ? (this.options.preload = i.concat(n), this.loadResources((a) => {
|
|
1205
|
+
s.resolve(), t && t(a);
|
|
1206
|
+
}), s) : (t && t(), Promise.resolve());
|
|
1207
1207
|
}
|
|
1208
1208
|
dir(e) {
|
|
1209
|
-
var
|
|
1210
|
-
if (e || (e = this.resolvedLanguage || (((
|
|
1209
|
+
var i, n;
|
|
1210
|
+
if (e || (e = this.resolvedLanguage || (((i = this.languages) == null ? void 0 : i.length) > 0 ? this.languages[0] : this.language)), !e) return "rtl";
|
|
1211
1211
|
try {
|
|
1212
|
-
const
|
|
1213
|
-
if (
|
|
1214
|
-
const
|
|
1215
|
-
if (
|
|
1212
|
+
const a = new Intl.Locale(e);
|
|
1213
|
+
if (a && a.getTextInfo) {
|
|
1214
|
+
const o = a.getTextInfo();
|
|
1215
|
+
if (o && o.direction) return o.direction;
|
|
1216
1216
|
}
|
|
1217
|
-
} catch (
|
|
1217
|
+
} catch (a) {
|
|
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"],
|
|
1220
|
-
return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(
|
|
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"], s = ((n = this.services) == null ? void 0 : n.languageUtils) || new pe(Se());
|
|
1220
|
+
return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(s.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 =
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1228
|
-
const
|
|
1225
|
+
cloneInstance(e = {}, t = Y) {
|
|
1226
|
+
const s = e.forkResourceStore;
|
|
1227
|
+
s && delete e.forkResourceStore;
|
|
1228
|
+
const i = 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(i);
|
|
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
|
-
},
|
|
1236
|
-
const
|
|
1237
|
-
n.store = new
|
|
1235
|
+
}, s) {
|
|
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, i), n.services.resourceStore = n.store;
|
|
1238
1238
|
}
|
|
1239
|
-
return n.translator = new Z(n.services,
|
|
1240
|
-
n.emit(
|
|
1241
|
-
}), n.init(
|
|
1239
|
+
return n.translator = new Z(n.services, i), n.translator.on("*", (o, ...l) => {
|
|
1240
|
+
n.emit(o, ...l);
|
|
1241
|
+
}), n.init(i, t), n.translator.options = i, n.translator.backendConnector.services.utils = {
|
|
1242
1242
|
hasLoadedNamespace: n.hasLoadedNamespace.bind(n)
|
|
1243
1243
|
}, n;
|
|
1244
1244
|
}
|
|
@@ -1252,8 +1252,8 @@ class z extends X {
|
|
|
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,85 +1268,98 @@ y.setDefaultNamespace;
|
|
|
1268
1268
|
y.hasLoadedNamespace;
|
|
1269
1269
|
y.loadNamespaces;
|
|
1270
1270
|
y.loadLanguages;
|
|
1271
|
-
const
|
|
1271
|
+
const et = (r, e) => {
|
|
1272
1272
|
for (const t of e) {
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
const
|
|
1276
|
-
if (
|
|
1273
|
+
const s = r.find(t);
|
|
1274
|
+
s && s.each((i, n) => {
|
|
1275
|
+
const a = $(n);
|
|
1276
|
+
if (a.attr("data-i18n"))
|
|
1277
1277
|
return;
|
|
1278
|
-
const
|
|
1279
|
-
|
|
1280
|
-
"data-i18n":
|
|
1281
|
-
}),
|
|
1282
|
-
const l =
|
|
1283
|
-
l && (
|
|
1278
|
+
const o = a.text().trim();
|
|
1279
|
+
o && (a.attr({
|
|
1280
|
+
"data-i18n": o
|
|
1281
|
+
}), a.text(y.t(o)));
|
|
1282
|
+
const l = a.attr("placeholder");
|
|
1283
|
+
l && (a.attr({
|
|
1284
1284
|
"data-i18n": "[placeholder]" + l
|
|
1285
|
-
}),
|
|
1285
|
+
}), a.attr({
|
|
1286
1286
|
placeholder: y.t(l)
|
|
1287
1287
|
}));
|
|
1288
1288
|
});
|
|
1289
1289
|
}
|
|
1290
|
-
},
|
|
1291
|
-
for (const e of
|
|
1290
|
+
}, A = (r) => {
|
|
1291
|
+
for (const e of r) {
|
|
1292
1292
|
const t = $(e);
|
|
1293
|
-
t && t.each((
|
|
1294
|
-
const n = $(
|
|
1293
|
+
t && t.each((s, i) => {
|
|
1294
|
+
const n = $(i);
|
|
1295
1295
|
if (n.attr("data-i18n"))
|
|
1296
1296
|
return;
|
|
1297
|
-
const
|
|
1298
|
-
r && (n.attr({
|
|
1299
|
-
"data-i18n": r
|
|
1300
|
-
}), n.text(y.t(r)));
|
|
1301
|
-
const a = n.attr("placeholder");
|
|
1297
|
+
const a = n.text().trim();
|
|
1302
1298
|
a && (n.attr({
|
|
1303
|
-
"data-i18n":
|
|
1299
|
+
"data-i18n": a
|
|
1300
|
+
}), n.text(y.t(a)));
|
|
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
|
+
}, Pe = [
|
|
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 = (r, e, t = Pe) => {
|
|
1325
|
+
et(e, t);
|
|
1326
|
+
}, $e = (r = "[data-i18n]") => {
|
|
1327
|
+
document.querySelectorAll(r).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 i =
|
|
1331
|
-
|
|
1333
|
+
const s = t.match(/\[([^\]]+)\](.+)/);
|
|
1334
|
+
if (s && s.length === 3) {
|
|
1335
|
+
const i = s[1], n = s[2];
|
|
1336
|
+
e.setAttribute(i, y.t(n));
|
|
1332
1337
|
}
|
|
1333
1338
|
});
|
|
1334
1339
|
};
|
|
1335
1340
|
let Le = !1;
|
|
1336
|
-
const Oe = (
|
|
1341
|
+
const Oe = (r) => {
|
|
1337
1342
|
if (Le)
|
|
1338
1343
|
return;
|
|
1339
1344
|
Le = !0, globalThis.hiprint.i18next = y, globalThis.hiprint.t = y.t;
|
|
1340
|
-
const e = Object.keys(
|
|
1341
|
-
globalThis.hiprint.languages = ["简体中文", ...e], globalThis.hiprint.changeLanguage = (t,
|
|
1342
|
-
y.changeLanguage(t, (
|
|
1343
|
-
|
|
1345
|
+
const e = Object.keys(r.resources || {});
|
|
1346
|
+
globalThis.hiprint.languages = ["简体中文", ...e], globalThis.hiprint.changeLanguage = (t, s) => {
|
|
1347
|
+
y.changeLanguage(t, (i, n) => {
|
|
1348
|
+
s && s(i, n), $e();
|
|
1344
1349
|
});
|
|
1345
1350
|
};
|
|
1351
|
+
}, we = (r) => {
|
|
1352
|
+
setTimeout(() => {
|
|
1353
|
+
$e(".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
|
+
A((r == null ? void 0 : r.optionsSelectorList) || Pe);
|
|
1356
|
+
}, 0);
|
|
1357
|
+
});
|
|
1358
|
+
}, 0);
|
|
1346
1359
|
};
|
|
1347
|
-
function
|
|
1348
|
-
y.init(p({},
|
|
1349
|
-
e && e(y,
|
|
1360
|
+
function it(r, e) {
|
|
1361
|
+
y.init(p({}, r), (s, i) => {
|
|
1362
|
+
e && e(y, i, s);
|
|
1350
1363
|
});
|
|
1351
1364
|
let t = [];
|
|
1352
1365
|
return {
|
|
@@ -1359,7 +1372,7 @@ function tt(o, e) {
|
|
|
1359
1372
|
description: "添加 i18n 方法",
|
|
1360
1373
|
priority: 1,
|
|
1361
1374
|
run: () => {
|
|
1362
|
-
Oe(
|
|
1375
|
+
Oe(r);
|
|
1363
1376
|
}
|
|
1364
1377
|
},
|
|
1365
1378
|
{
|
|
@@ -1367,17 +1380,17 @@ function tt(o, e) {
|
|
|
1367
1380
|
name: "i18n options",
|
|
1368
1381
|
description: "渲染元素属性时做多语言处理",
|
|
1369
1382
|
priority: 1,
|
|
1370
|
-
run: (
|
|
1371
|
-
if (
|
|
1372
|
-
if (!
|
|
1373
|
-
|
|
1374
|
-
const
|
|
1375
|
-
|
|
1376
|
-
const
|
|
1377
|
-
return t.indexOf(
|
|
1383
|
+
run: (s) => {
|
|
1384
|
+
if (s) {
|
|
1385
|
+
if (!s._translationWrapped) {
|
|
1386
|
+
s._translationWrapped = !0;
|
|
1387
|
+
const i = s.createTarget;
|
|
1388
|
+
s.createTarget = function(...n) {
|
|
1389
|
+
const a = i.call(s, ...n);
|
|
1390
|
+
return t.indexOf(s.name) !== -1 && a.attr("data-name") || (a.attr({ "data-name": s.name }), tt(s, a, r == null ? void 0 : r.optionsSelectorList)), a;
|
|
1378
1391
|
};
|
|
1379
1392
|
}
|
|
1380
|
-
return t.indexOf(
|
|
1393
|
+
return t.indexOf(s.name) === -1 && t.push(s.name), s;
|
|
1381
1394
|
}
|
|
1382
1395
|
}
|
|
1383
1396
|
},
|
|
@@ -1385,27 +1398,41 @@ function tt(o, e) {
|
|
|
1385
1398
|
hook: "onDesigned",
|
|
1386
1399
|
name: "i18n other selector",
|
|
1387
1400
|
description: "其他UI选择器多语言处理",
|
|
1388
|
-
priority:
|
|
1389
|
-
run: ({ hiprint:
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
+
priority: 9,
|
|
1402
|
+
run: ({ hiprint: s, designerUtils: i }) => {
|
|
1403
|
+
Oe(r), setTimeout(() => {
|
|
1404
|
+
var o;
|
|
1405
|
+
const n = (o = i.printTemplate) == null ? void 0 : o.id;
|
|
1406
|
+
n && (r != null && r.onDesigned && (r == null || r.onDesigned(i)), globalThis.hinnn.event.on("BuildCustomOptionSettingEventKey_" + n, (l) => {
|
|
1407
|
+
r != null && r.onPanelSelected && (r == null || r.onPanelSelected()), we(r);
|
|
1408
|
+
}), globalThis.hinnn.event.on("PrintElementSelectEventKey_" + n, (l) => {
|
|
1409
|
+
setTimeout(() => {
|
|
1410
|
+
A([".printSetting .prop-tab-items .tab-title"]), we(r), r != null && r.onElementSelected && (r == null || r.onElementSelected(l));
|
|
1411
|
+
}, 0);
|
|
1412
|
+
}), $(".hiprint-printPaper.design").on("contextmenu", () => {
|
|
1413
|
+
A([
|
|
1414
|
+
".hicontextmenu .hicontextmenuitem .title span",
|
|
1415
|
+
".hicontextmenu .hicontextmenuitem .nav"
|
|
1416
|
+
]);
|
|
1417
|
+
})), A([
|
|
1418
|
+
".svp-header p",
|
|
1419
|
+
".svp-tools .tool-name",
|
|
1420
|
+
".svp-dragbox .header span",
|
|
1421
|
+
".preview-bar button span",
|
|
1422
|
+
".printer-list-txt"
|
|
1401
1423
|
]);
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1424
|
+
}, (r == null ? void 0 : r.onDesignedDelay) || 600);
|
|
1425
|
+
}
|
|
1426
|
+
},
|
|
1427
|
+
{
|
|
1428
|
+
hook: "onSettings",
|
|
1429
|
+
name: "i18n settings",
|
|
1430
|
+
description: "设置选择器多语言处理",
|
|
1431
|
+
priority: 1,
|
|
1432
|
+
run: (s) => {
|
|
1433
|
+
s.type == "show" && setTimeout(() => {
|
|
1434
|
+
A([".settings-body .svp-tab"]);
|
|
1435
|
+
}, 0), r != null && r.onSettings && (r == null || r.onSettings(s));
|
|
1409
1436
|
}
|
|
1410
1437
|
},
|
|
1411
1438
|
{
|
|
@@ -1413,10 +1440,10 @@ function tt(o, e) {
|
|
|
1413
1440
|
name: "i18n preview selector",
|
|
1414
1441
|
description: "组件内预览选择器多语言处理",
|
|
1415
1442
|
priority: 1,
|
|
1416
|
-
run: (
|
|
1443
|
+
run: (s) => {
|
|
1417
1444
|
setTimeout(() => {
|
|
1418
|
-
|
|
1419
|
-
}, 0);
|
|
1445
|
+
A([".preview-bar button span", ".printer-list-txt"]);
|
|
1446
|
+
}, (r == null ? void 0 : r.onPreviewDelay) || 0), r != null && r.onPreview && (r == null || r.onPreview(s));
|
|
1420
1447
|
}
|
|
1421
1448
|
}
|
|
1422
1449
|
],
|
|
@@ -1424,6 +1451,6 @@ function tt(o, e) {
|
|
|
1424
1451
|
};
|
|
1425
1452
|
}
|
|
1426
1453
|
export {
|
|
1427
|
-
|
|
1428
|
-
|
|
1454
|
+
it as default,
|
|
1455
|
+
A as translateBySelector
|
|
1429
1456
|
};
|