@elia-assistant/chatui 1.0.26 → 2.0.0
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 +111 -17
- package/dist/App.d.ts +0 -1
- package/dist/chat-store.js +141 -139
- package/dist/chatui.iife.js +30 -31
- package/dist/chunks/{middleware-Brf3TxqP.js → middleware-BG8DEvI8.js} +28 -23
- package/dist/chunks/{settingsStore-JRogtJV3.js → settingsStore-DzpdfGcd.js} +41 -40
- package/dist/createChat.d.ts +17 -0
- package/dist/i18n.d.ts +8 -2
- package/dist/iife.d.ts +2 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +3664 -2257
- package/dist/lib/storage.d.ts +7 -3
- package/dist/store/StoreContext.d.ts +32 -0
- package/dist/store/chatStore.d.ts +8 -3
- package/dist/store/settingsStore.d.ts +10 -3
- package/dist/store.js +2 -2
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunks/i18n-DS9aLar5.js +0 -1321
|
@@ -1,1321 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, n) => {
|
|
3
|
-
let r = {};
|
|
4
|
-
for (var i in e) t(r, i, {
|
|
5
|
-
get: e[i],
|
|
6
|
-
enumerable: !0
|
|
7
|
-
});
|
|
8
|
-
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
-
}, c = (e, i, o, s) => {
|
|
10
|
-
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
11
|
-
get: ((e) => i[e]).bind(null, d),
|
|
12
|
-
enumerable: !(s = n(i, d)) || s.enumerable
|
|
13
|
-
});
|
|
14
|
-
return e;
|
|
15
|
-
}, l = (n, r, a) => (a = n == null ? {} : e(i(n)), c(r || !n || !n.__esModule ? t(a, "default", {
|
|
16
|
-
value: n,
|
|
17
|
-
enumerable: !0
|
|
18
|
-
}) : a, n)), u = (e) => typeof e == "string", d = () => {
|
|
19
|
-
let e, t, n = new Promise((n, r) => {
|
|
20
|
-
e = n, t = r;
|
|
21
|
-
});
|
|
22
|
-
return n.resolve = e, n.reject = t, n;
|
|
23
|
-
}, f = (e) => e == null ? "" : "" + e, p = (e, t, n) => {
|
|
24
|
-
e.forEach((e) => {
|
|
25
|
-
t[e] && (n[e] = t[e]);
|
|
26
|
-
});
|
|
27
|
-
}, m = /###/g, h = (e) => e && e.indexOf("###") > -1 ? e.replace(m, ".") : e, g = (e) => !e || u(e), _ = (e, t, n) => {
|
|
28
|
-
let r = u(t) ? t.split(".") : t, i = 0;
|
|
29
|
-
for (; i < r.length - 1;) {
|
|
30
|
-
if (g(e)) return {};
|
|
31
|
-
let t = h(r[i]);
|
|
32
|
-
!e[t] && n && (e[t] = new n()), e = Object.prototype.hasOwnProperty.call(e, t) ? e[t] : {}, ++i;
|
|
33
|
-
}
|
|
34
|
-
return g(e) ? {} : {
|
|
35
|
-
obj: e,
|
|
36
|
-
k: h(r[i])
|
|
37
|
-
};
|
|
38
|
-
}, v = (e, t, n) => {
|
|
39
|
-
let { obj: r, k: i } = _(e, t, Object);
|
|
40
|
-
if (r !== void 0 || t.length === 1) {
|
|
41
|
-
r[i] = n;
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
let a = t[t.length - 1], o = t.slice(0, t.length - 1), s = _(e, o, Object);
|
|
45
|
-
for (; s.obj === void 0 && o.length;) a = `${o[o.length - 1]}.${a}`, o = o.slice(0, o.length - 1), s = _(e, o, Object), s?.obj && s.obj[`${s.k}.${a}`] !== void 0 && (s.obj = void 0);
|
|
46
|
-
s.obj[`${s.k}.${a}`] = n;
|
|
47
|
-
}, y = (e, t, n, r) => {
|
|
48
|
-
let { obj: i, k: a } = _(e, t, Object);
|
|
49
|
-
i[a] = i[a] || [], i[a].push(n);
|
|
50
|
-
}, b = (e, t) => {
|
|
51
|
-
let { obj: n, k: r } = _(e, t);
|
|
52
|
-
if (n && Object.prototype.hasOwnProperty.call(n, r)) return n[r];
|
|
53
|
-
}, x = (e, t, n) => {
|
|
54
|
-
let r = b(e, n);
|
|
55
|
-
return r === void 0 ? b(t, n) : r;
|
|
56
|
-
}, S = (e, t, n) => {
|
|
57
|
-
for (let r in t) r !== "__proto__" && r !== "constructor" && (r in e ? u(e[r]) || e[r] instanceof String || u(t[r]) || t[r] instanceof String ? n && (e[r] = t[r]) : S(e[r], t[r], n) : e[r] = t[r]);
|
|
58
|
-
return e;
|
|
59
|
-
}, C = (e) => e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), w = {
|
|
60
|
-
"&": "&",
|
|
61
|
-
"<": "<",
|
|
62
|
-
">": ">",
|
|
63
|
-
"\"": """,
|
|
64
|
-
"'": "'",
|
|
65
|
-
"/": "/"
|
|
66
|
-
}, T = (e) => u(e) ? e.replace(/[&<>"'\/]/g, (e) => w[e]) : e, E = class {
|
|
67
|
-
constructor(e) {
|
|
68
|
-
this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
|
|
69
|
-
}
|
|
70
|
-
getRegExp(e) {
|
|
71
|
-
let t = this.regExpMap.get(e);
|
|
72
|
-
if (t !== void 0) return t;
|
|
73
|
-
let n = new RegExp(e);
|
|
74
|
-
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, n), this.regExpQueue.push(e), n;
|
|
75
|
-
}
|
|
76
|
-
}, D = [
|
|
77
|
-
" ",
|
|
78
|
-
",",
|
|
79
|
-
"?",
|
|
80
|
-
"!",
|
|
81
|
-
";"
|
|
82
|
-
], ee = new E(20), O = (e, t, n) => {
|
|
83
|
-
t ||= "", n ||= "";
|
|
84
|
-
let r = D.filter((e) => t.indexOf(e) < 0 && n.indexOf(e) < 0);
|
|
85
|
-
if (r.length === 0) return !0;
|
|
86
|
-
let i = ee.getRegExp(`(${r.map((e) => e === "?" ? "\\?" : e).join("|")})`), a = !i.test(e);
|
|
87
|
-
if (!a) {
|
|
88
|
-
let t = e.indexOf(n);
|
|
89
|
-
t > 0 && !i.test(e.substring(0, t)) && (a = !0);
|
|
90
|
-
}
|
|
91
|
-
return a;
|
|
92
|
-
}, k = (e, t, n = ".") => {
|
|
93
|
-
if (!e) return;
|
|
94
|
-
if (e[t]) return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
|
|
95
|
-
let r = t.split(n), i = e;
|
|
96
|
-
for (let e = 0; e < r.length;) {
|
|
97
|
-
if (!i || typeof i != "object") return;
|
|
98
|
-
let t, a = "";
|
|
99
|
-
for (let o = e; o < r.length; ++o) if (o !== e && (a += n), a += r[o], t = i[a], t !== void 0) {
|
|
100
|
-
if ([
|
|
101
|
-
"string",
|
|
102
|
-
"number",
|
|
103
|
-
"boolean"
|
|
104
|
-
].indexOf(typeof t) > -1 && o < r.length - 1) continue;
|
|
105
|
-
e += o - e + 1;
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
i = t;
|
|
109
|
-
}
|
|
110
|
-
return i;
|
|
111
|
-
}, A = (e) => e?.replace(/_/g, "-"), te = {
|
|
112
|
-
type: "logger",
|
|
113
|
-
log(e) {
|
|
114
|
-
this.output("log", e);
|
|
115
|
-
},
|
|
116
|
-
warn(e) {
|
|
117
|
-
this.output("warn", e);
|
|
118
|
-
},
|
|
119
|
-
error(e) {
|
|
120
|
-
this.output("error", e);
|
|
121
|
-
},
|
|
122
|
-
output(e, t) {
|
|
123
|
-
console?.[e]?.apply?.(console, t);
|
|
124
|
-
}
|
|
125
|
-
}, j = new class e {
|
|
126
|
-
constructor(e, t = {}) {
|
|
127
|
-
this.init(e, t);
|
|
128
|
-
}
|
|
129
|
-
init(e, t = {}) {
|
|
130
|
-
this.prefix = t.prefix || "i18next:", this.logger = e || te, this.options = t, this.debug = t.debug;
|
|
131
|
-
}
|
|
132
|
-
log(...e) {
|
|
133
|
-
return this.forward(e, "log", "", !0);
|
|
134
|
-
}
|
|
135
|
-
warn(...e) {
|
|
136
|
-
return this.forward(e, "warn", "", !0);
|
|
137
|
-
}
|
|
138
|
-
error(...e) {
|
|
139
|
-
return this.forward(e, "error", "");
|
|
140
|
-
}
|
|
141
|
-
deprecate(...e) {
|
|
142
|
-
return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
|
|
143
|
-
}
|
|
144
|
-
forward(e, t, n, r) {
|
|
145
|
-
return r && !this.debug ? null : (u(e[0]) && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[t](e));
|
|
146
|
-
}
|
|
147
|
-
create(t) {
|
|
148
|
-
return new e(this.logger, {
|
|
149
|
-
prefix: `${this.prefix}:${t}:`,
|
|
150
|
-
...this.options
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
clone(t) {
|
|
154
|
-
return t ||= this.options, t.prefix = t.prefix || this.prefix, new e(this.logger, t);
|
|
155
|
-
}
|
|
156
|
-
}(), M = class {
|
|
157
|
-
constructor() {
|
|
158
|
-
this.observers = {};
|
|
159
|
-
}
|
|
160
|
-
on(e, t) {
|
|
161
|
-
return e.split(" ").forEach((e) => {
|
|
162
|
-
this.observers[e] || (this.observers[e] = /* @__PURE__ */ new Map());
|
|
163
|
-
let n = this.observers[e].get(t) || 0;
|
|
164
|
-
this.observers[e].set(t, n + 1);
|
|
165
|
-
}), this;
|
|
166
|
-
}
|
|
167
|
-
off(e, t) {
|
|
168
|
-
if (this.observers[e]) {
|
|
169
|
-
if (!t) {
|
|
170
|
-
delete this.observers[e];
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
this.observers[e].delete(t);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
emit(e, ...t) {
|
|
177
|
-
this.observers[e] && Array.from(this.observers[e].entries()).forEach(([e, n]) => {
|
|
178
|
-
for (let r = 0; r < n; r++) e(...t);
|
|
179
|
-
}), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([n, r]) => {
|
|
180
|
-
for (let i = 0; i < r; i++) n.apply(n, [e, ...t]);
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}, N = class extends M {
|
|
184
|
-
constructor(e, t = {
|
|
185
|
-
ns: ["translation"],
|
|
186
|
-
defaultNS: "translation"
|
|
187
|
-
}) {
|
|
188
|
-
super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
|
|
189
|
-
}
|
|
190
|
-
addNamespaces(e) {
|
|
191
|
-
this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
|
|
192
|
-
}
|
|
193
|
-
removeNamespaces(e) {
|
|
194
|
-
let t = this.options.ns.indexOf(e);
|
|
195
|
-
t > -1 && this.options.ns.splice(t, 1);
|
|
196
|
-
}
|
|
197
|
-
getResource(e, t, n, r = {}) {
|
|
198
|
-
let i = r.keySeparator === void 0 ? this.options.keySeparator : r.keySeparator, a = r.ignoreJSONStructure === void 0 ? this.options.ignoreJSONStructure : r.ignoreJSONStructure, o;
|
|
199
|
-
e.indexOf(".") > -1 ? o = e.split(".") : (o = [e, t], n && (Array.isArray(n) ? o.push(...n) : u(n) && i ? o.push(...n.split(i)) : o.push(n)));
|
|
200
|
-
let s = b(this.data, o);
|
|
201
|
-
return !s && !t && !n && e.indexOf(".") > -1 && (e = o[0], t = o[1], n = o.slice(2).join(".")), s || !a || !u(n) ? s : k(this.data?.[e]?.[t], n, i);
|
|
202
|
-
}
|
|
203
|
-
addResource(e, t, n, r, i = { silent: !1 }) {
|
|
204
|
-
let a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = [e, t];
|
|
205
|
-
n && (o = o.concat(a ? n.split(a) : n)), e.indexOf(".") > -1 && (o = e.split("."), r = t, t = o[1]), this.addNamespaces(t), v(this.data, o, r), i.silent || this.emit("added", e, t, n, r);
|
|
206
|
-
}
|
|
207
|
-
addResources(e, t, n, r = { silent: !1 }) {
|
|
208
|
-
for (let r in n) (u(n[r]) || Array.isArray(n[r])) && this.addResource(e, t, r, n[r], { silent: !0 });
|
|
209
|
-
r.silent || this.emit("added", e, t, n);
|
|
210
|
-
}
|
|
211
|
-
addResourceBundle(e, t, n, r, i, a = {
|
|
212
|
-
silent: !1,
|
|
213
|
-
skipCopy: !1
|
|
214
|
-
}) {
|
|
215
|
-
let o = [e, t];
|
|
216
|
-
e.indexOf(".") > -1 && (o = e.split("."), r = n, n = t, t = o[1]), this.addNamespaces(t);
|
|
217
|
-
let s = b(this.data, o) || {};
|
|
218
|
-
a.skipCopy || (n = JSON.parse(JSON.stringify(n))), r ? S(s, n, i) : s = {
|
|
219
|
-
...s,
|
|
220
|
-
...n
|
|
221
|
-
}, v(this.data, o, s), a.silent || this.emit("added", e, t, n);
|
|
222
|
-
}
|
|
223
|
-
removeResourceBundle(e, t) {
|
|
224
|
-
this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
|
|
225
|
-
}
|
|
226
|
-
hasResourceBundle(e, t) {
|
|
227
|
-
return this.getResource(e, t) !== void 0;
|
|
228
|
-
}
|
|
229
|
-
getResourceBundle(e, t) {
|
|
230
|
-
return t ||= this.options.defaultNS, this.getResource(e, t);
|
|
231
|
-
}
|
|
232
|
-
getDataByLanguage(e) {
|
|
233
|
-
return this.data[e];
|
|
234
|
-
}
|
|
235
|
-
hasLanguageSomeTranslations(e) {
|
|
236
|
-
let t = this.getDataByLanguage(e);
|
|
237
|
-
return !!(t && Object.keys(t) || []).find((e) => t[e] && Object.keys(t[e]).length > 0);
|
|
238
|
-
}
|
|
239
|
-
toJSON() {
|
|
240
|
-
return this.data;
|
|
241
|
-
}
|
|
242
|
-
}, P = {
|
|
243
|
-
processors: {},
|
|
244
|
-
addPostProcessor(e) {
|
|
245
|
-
this.processors[e.name] = e;
|
|
246
|
-
},
|
|
247
|
-
handle(e, t, n, r, i) {
|
|
248
|
-
return e.forEach((e) => {
|
|
249
|
-
t = this.processors[e]?.process(t, n, r, i) ?? t;
|
|
250
|
-
}), t;
|
|
251
|
-
}
|
|
252
|
-
}, F = Symbol("i18next/PATH_KEY");
|
|
253
|
-
function ne() {
|
|
254
|
-
let e = [], t = Object.create(null), n;
|
|
255
|
-
return t.get = (r, i) => (n?.revoke?.(), i === F ? e : (e.push(i), n = Proxy.revocable(r, t), n.proxy)), Proxy.revocable(Object.create(null), t).proxy;
|
|
256
|
-
}
|
|
257
|
-
function I(e, t) {
|
|
258
|
-
let { [F]: n } = e(ne()), r = t?.keySeparator ?? ".", i = t?.nsSeparator ?? ":";
|
|
259
|
-
if (n.length > 1 && i) {
|
|
260
|
-
let e = t?.ns, a = Array.isArray(e) ? e : null;
|
|
261
|
-
if (a && a.length > 1 && a.slice(1).includes(n[0])) return `${n[0]}${i}${n.slice(1).join(r)}`;
|
|
262
|
-
}
|
|
263
|
-
return n.join(r);
|
|
264
|
-
}
|
|
265
|
-
var L = {}, R = (e) => !u(e) && typeof e != "boolean" && typeof e != "number", z = class e extends M {
|
|
266
|
-
constructor(e, t = {}) {
|
|
267
|
-
super(), p([
|
|
268
|
-
"resourceStore",
|
|
269
|
-
"languageUtils",
|
|
270
|
-
"pluralResolver",
|
|
271
|
-
"interpolator",
|
|
272
|
-
"backendConnector",
|
|
273
|
-
"i18nFormat",
|
|
274
|
-
"utils"
|
|
275
|
-
], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = j.create("translator");
|
|
276
|
-
}
|
|
277
|
-
changeLanguage(e) {
|
|
278
|
-
e && (this.language = e);
|
|
279
|
-
}
|
|
280
|
-
exists(e, t = { interpolation: {} }) {
|
|
281
|
-
let n = { ...t };
|
|
282
|
-
if (e == null) return !1;
|
|
283
|
-
let r = this.resolve(e, n);
|
|
284
|
-
if (r?.res === void 0) return !1;
|
|
285
|
-
let i = R(r.res);
|
|
286
|
-
return !(n.returnObjects === !1 && i);
|
|
287
|
-
}
|
|
288
|
-
extractFromKey(e, t) {
|
|
289
|
-
let n = t.nsSeparator === void 0 ? this.options.nsSeparator : t.nsSeparator;
|
|
290
|
-
n === void 0 && (n = ":");
|
|
291
|
-
let r = t.keySeparator === void 0 ? this.options.keySeparator : t.keySeparator, i = t.ns || this.options.defaultNS || [], a = n && e.indexOf(n) > -1, o = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !O(e, n, r);
|
|
292
|
-
if (a && !o) {
|
|
293
|
-
let t = e.match(this.interpolator.nestingRegexp);
|
|
294
|
-
if (t && t.length > 0) return {
|
|
295
|
-
key: e,
|
|
296
|
-
namespaces: u(i) ? [i] : i
|
|
297
|
-
};
|
|
298
|
-
let a = e.split(n);
|
|
299
|
-
(n !== r || n === r && this.options.ns.indexOf(a[0]) > -1) && (i = a.shift()), e = a.join(r);
|
|
300
|
-
}
|
|
301
|
-
return {
|
|
302
|
-
key: e,
|
|
303
|
-
namespaces: u(i) ? [i] : i
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
translate(t, n, r) {
|
|
307
|
-
let i = typeof n == "object" ? { ...n } : n;
|
|
308
|
-
if (typeof i != "object" && this.options.overloadTranslationOptionHandler && (i = this.options.overloadTranslationOptionHandler(arguments)), typeof i == "object" && (i = { ...i }), i ||= {}, t == null) return "";
|
|
309
|
-
typeof t == "function" && (t = I(t, {
|
|
310
|
-
...this.options,
|
|
311
|
-
...i
|
|
312
|
-
})), Array.isArray(t) || (t = [String(t)]), t = t.map((e) => typeof e == "function" ? I(e, {
|
|
313
|
-
...this.options,
|
|
314
|
-
...i
|
|
315
|
-
}) : String(e));
|
|
316
|
-
let a = i.returnDetails === void 0 ? this.options.returnDetails : i.returnDetails, o = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, { key: s, namespaces: c } = this.extractFromKey(t[t.length - 1], i), l = c[c.length - 1], d = i.nsSeparator === void 0 ? this.options.nsSeparator : i.nsSeparator;
|
|
317
|
-
d === void 0 && (d = ":");
|
|
318
|
-
let f = i.lng || this.language, p = i.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
319
|
-
if (f?.toLowerCase() === "cimode") return p ? a ? {
|
|
320
|
-
res: `${l}${d}${s}`,
|
|
321
|
-
usedKey: s,
|
|
322
|
-
exactUsedKey: s,
|
|
323
|
-
usedLng: f,
|
|
324
|
-
usedNS: l,
|
|
325
|
-
usedParams: this.getUsedParamsDetails(i)
|
|
326
|
-
} : `${l}${d}${s}` : a ? {
|
|
327
|
-
res: s,
|
|
328
|
-
usedKey: s,
|
|
329
|
-
exactUsedKey: s,
|
|
330
|
-
usedLng: f,
|
|
331
|
-
usedNS: l,
|
|
332
|
-
usedParams: this.getUsedParamsDetails(i)
|
|
333
|
-
} : s;
|
|
334
|
-
let m = this.resolve(t, i), h = m?.res, g = m?.usedKey || s, _ = m?.exactUsedKey || s, v = [
|
|
335
|
-
"[object Number]",
|
|
336
|
-
"[object Function]",
|
|
337
|
-
"[object RegExp]"
|
|
338
|
-
], y = i.joinArrays === void 0 ? this.options.joinArrays : i.joinArrays, b = !this.i18nFormat || this.i18nFormat.handleAsObject, x = i.count !== void 0 && !u(i.count), S = e.hasDefaultValue(i), C = x ? this.pluralResolver.getSuffix(f, i.count, i) : "", w = i.ordinal && x ? this.pluralResolver.getSuffix(f, i.count, { ordinal: !1 }) : "", T = x && !i.ordinal && i.count === 0, E = T && i[`defaultValue${this.options.pluralSeparator}zero`] || i[`defaultValue${C}`] || i[`defaultValue${w}`] || i.defaultValue, D = h;
|
|
339
|
-
b && !h && S && (D = E);
|
|
340
|
-
let ee = R(D), O = Object.prototype.toString.apply(D);
|
|
341
|
-
if (b && D && ee && v.indexOf(O) < 0 && !(u(y) && Array.isArray(D))) {
|
|
342
|
-
if (!i.returnObjects && !this.options.returnObjects) {
|
|
343
|
-
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
344
|
-
let e = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(g, D, {
|
|
345
|
-
...i,
|
|
346
|
-
ns: c
|
|
347
|
-
}) : `key '${s} (${this.language})' returned an object instead of string.`;
|
|
348
|
-
return a ? (m.res = e, m.usedParams = this.getUsedParamsDetails(i), m) : e;
|
|
349
|
-
}
|
|
350
|
-
if (o) {
|
|
351
|
-
let e = Array.isArray(D), t = e ? [] : {}, n = e ? _ : g;
|
|
352
|
-
for (let e in D) if (Object.prototype.hasOwnProperty.call(D, e)) {
|
|
353
|
-
let r = `${n}${o}${e}`;
|
|
354
|
-
S && !h ? t[e] = this.translate(r, {
|
|
355
|
-
...i,
|
|
356
|
-
defaultValue: R(E) ? E[e] : void 0,
|
|
357
|
-
joinArrays: !1,
|
|
358
|
-
ns: c
|
|
359
|
-
}) : t[e] = this.translate(r, {
|
|
360
|
-
...i,
|
|
361
|
-
joinArrays: !1,
|
|
362
|
-
ns: c
|
|
363
|
-
}), t[e] === r && (t[e] = D[e]);
|
|
364
|
-
}
|
|
365
|
-
h = t;
|
|
366
|
-
}
|
|
367
|
-
} else if (b && u(y) && Array.isArray(h)) h = h.join(y), h &&= this.extendTranslation(h, t, i, r);
|
|
368
|
-
else {
|
|
369
|
-
let e = !1, n = !1;
|
|
370
|
-
!this.isValidLookup(h) && S && (e = !0, h = E), this.isValidLookup(h) || (n = !0, h = s);
|
|
371
|
-
let a = (i.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && n ? void 0 : h, c = S && E !== h && this.options.updateMissing;
|
|
372
|
-
if (n || e || c) {
|
|
373
|
-
if (this.logger.log(c ? "updateKey" : "missingKey", f, l, s, c ? E : h), o) {
|
|
374
|
-
let e = this.resolve(s, {
|
|
375
|
-
...i,
|
|
376
|
-
keySeparator: !1
|
|
377
|
-
});
|
|
378
|
-
e && e.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.");
|
|
379
|
-
}
|
|
380
|
-
let e = [], t = this.languageUtils.getFallbackCodes(this.options.fallbackLng, i.lng || this.language);
|
|
381
|
-
if (this.options.saveMissingTo === "fallback" && t && t[0]) for (let n = 0; n < t.length; n++) e.push(t[n]);
|
|
382
|
-
else this.options.saveMissingTo === "all" ? e = this.languageUtils.toResolveHierarchy(i.lng || this.language) : e.push(i.lng || this.language);
|
|
383
|
-
let n = (e, t, n) => {
|
|
384
|
-
let r = S && n !== h ? n : a;
|
|
385
|
-
this.options.missingKeyHandler ? this.options.missingKeyHandler(e, l, t, r, c, i) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(e, l, t, r, c, i), this.emit("missingKey", e, l, t, h);
|
|
386
|
-
};
|
|
387
|
-
this.options.saveMissing && (this.options.saveMissingPlurals && x ? e.forEach((e) => {
|
|
388
|
-
let t = this.pluralResolver.getSuffixes(e, i);
|
|
389
|
-
T && i[`defaultValue${this.options.pluralSeparator}zero`] && t.indexOf(`${this.options.pluralSeparator}zero`) < 0 && t.push(`${this.options.pluralSeparator}zero`), t.forEach((t) => {
|
|
390
|
-
n([e], s + t, i[`defaultValue${t}`] || E);
|
|
391
|
-
});
|
|
392
|
-
}) : n(e, s, E));
|
|
393
|
-
}
|
|
394
|
-
h = this.extendTranslation(h, t, i, m, r), n && h === s && this.options.appendNamespaceToMissingKey && (h = `${l}${d}${s}`), (n || e) && this.options.parseMissingKeyHandler && (h = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${l}${d}${s}` : s, e ? h : void 0, i));
|
|
395
|
-
}
|
|
396
|
-
return a ? (m.res = h, m.usedParams = this.getUsedParamsDetails(i), m) : h;
|
|
397
|
-
}
|
|
398
|
-
extendTranslation(e, t, n, r, i) {
|
|
399
|
-
if (this.i18nFormat?.parse) e = this.i18nFormat.parse(e, {
|
|
400
|
-
...this.options.interpolation.defaultVariables,
|
|
401
|
-
...n
|
|
402
|
-
}, n.lng || this.language || r.usedLng, r.usedNS, r.usedKey, { resolved: r });
|
|
403
|
-
else if (!n.skipInterpolation) {
|
|
404
|
-
n.interpolation && this.interpolator.init({
|
|
405
|
-
...n,
|
|
406
|
-
interpolation: {
|
|
407
|
-
...this.options.interpolation,
|
|
408
|
-
...n.interpolation
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
let a = u(e) && (n?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : n.interpolation.skipOnVariables), o;
|
|
412
|
-
if (a) {
|
|
413
|
-
let t = e.match(this.interpolator.nestingRegexp);
|
|
414
|
-
o = t && t.length;
|
|
415
|
-
}
|
|
416
|
-
let s = n.replace && !u(n.replace) ? n.replace : n;
|
|
417
|
-
if (this.options.interpolation.defaultVariables && (s = {
|
|
418
|
-
...this.options.interpolation.defaultVariables,
|
|
419
|
-
...s
|
|
420
|
-
}), e = this.interpolator.interpolate(e, s, n.lng || this.language || r.usedLng, n), a) {
|
|
421
|
-
let t = e.match(this.interpolator.nestingRegexp), r = t && t.length;
|
|
422
|
-
o < r && (n.nest = !1);
|
|
423
|
-
}
|
|
424
|
-
!n.lng && r && r.res && (n.lng = this.language || r.usedLng), n.nest !== !1 && (e = this.interpolator.nest(e, (...e) => i?.[0] === e[0] && !n.context ? (this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`), null) : this.translate(...e, t), n)), n.interpolation && this.interpolator.reset();
|
|
425
|
-
}
|
|
426
|
-
let a = n.postProcess || this.options.postProcess, o = u(a) ? [a] : a;
|
|
427
|
-
return e != null && o?.length && n.applyPostProcessor !== !1 && (e = P.handle(o, e, t, this.options && this.options.postProcessPassResolved ? {
|
|
428
|
-
i18nResolved: {
|
|
429
|
-
...r,
|
|
430
|
-
usedParams: this.getUsedParamsDetails(n)
|
|
431
|
-
},
|
|
432
|
-
...n
|
|
433
|
-
} : n, this)), e;
|
|
434
|
-
}
|
|
435
|
-
resolve(e, t = {}) {
|
|
436
|
-
let n, r, i, a, o;
|
|
437
|
-
return u(e) && (e = [e]), Array.isArray(e) && (e = e.map((e) => typeof e == "function" ? I(e, {
|
|
438
|
-
...this.options,
|
|
439
|
-
...t
|
|
440
|
-
}) : e)), e.forEach((e) => {
|
|
441
|
-
if (this.isValidLookup(n)) return;
|
|
442
|
-
let s = this.extractFromKey(e, t), c = s.key;
|
|
443
|
-
r = c;
|
|
444
|
-
let l = s.namespaces;
|
|
445
|
-
this.options.fallbackNS && (l = l.concat(this.options.fallbackNS));
|
|
446
|
-
let d = t.count !== void 0 && !u(t.count), f = d && !t.ordinal && t.count === 0, p = t.context !== void 0 && (u(t.context) || typeof t.context == "number") && t.context !== "", m = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
|
|
447
|
-
l.forEach((e) => {
|
|
448
|
-
this.isValidLookup(n) || (o = e, !L[`${m[0]}-${e}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(o) && (L[`${m[0]}-${e}`] = !0, this.logger.warn(`key "${r}" for languages "${m.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!!!")), m.forEach((r) => {
|
|
449
|
-
if (this.isValidLookup(n)) return;
|
|
450
|
-
a = r;
|
|
451
|
-
let o = [c];
|
|
452
|
-
if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(o, c, r, e, t);
|
|
453
|
-
else {
|
|
454
|
-
let e;
|
|
455
|
-
d && (e = this.pluralResolver.getSuffix(r, t.count, t));
|
|
456
|
-
let n = `${this.options.pluralSeparator}zero`, i = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
457
|
-
if (d && (t.ordinal && e.indexOf(i) === 0 && o.push(c + e.replace(i, this.options.pluralSeparator)), o.push(c + e), f && o.push(c + n)), p) {
|
|
458
|
-
let r = `${c}${this.options.contextSeparator || "_"}${t.context}`;
|
|
459
|
-
o.push(r), d && (t.ordinal && e.indexOf(i) === 0 && o.push(r + e.replace(i, this.options.pluralSeparator)), o.push(r + e), f && o.push(r + n));
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
let s;
|
|
463
|
-
for (; s = o.pop();) this.isValidLookup(n) || (i = s, n = this.getResource(r, e, s, t));
|
|
464
|
-
}));
|
|
465
|
-
});
|
|
466
|
-
}), {
|
|
467
|
-
res: n,
|
|
468
|
-
usedKey: r,
|
|
469
|
-
exactUsedKey: i,
|
|
470
|
-
usedLng: a,
|
|
471
|
-
usedNS: o
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
isValidLookup(e) {
|
|
475
|
-
return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
|
|
476
|
-
}
|
|
477
|
-
getResource(e, t, n, r = {}) {
|
|
478
|
-
return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, n, r) : this.resourceStore.getResource(e, t, n, r);
|
|
479
|
-
}
|
|
480
|
-
getUsedParamsDetails(e = {}) {
|
|
481
|
-
let t = [
|
|
482
|
-
"defaultValue",
|
|
483
|
-
"ordinal",
|
|
484
|
-
"context",
|
|
485
|
-
"replace",
|
|
486
|
-
"lng",
|
|
487
|
-
"lngs",
|
|
488
|
-
"fallbackLng",
|
|
489
|
-
"ns",
|
|
490
|
-
"keySeparator",
|
|
491
|
-
"nsSeparator",
|
|
492
|
-
"returnObjects",
|
|
493
|
-
"returnDetails",
|
|
494
|
-
"joinArrays",
|
|
495
|
-
"postProcess",
|
|
496
|
-
"interpolation"
|
|
497
|
-
], n = e.replace && !u(e.replace), r = n ? e.replace : e;
|
|
498
|
-
if (n && e.count !== void 0 && (r.count = e.count), this.options.interpolation.defaultVariables && (r = {
|
|
499
|
-
...this.options.interpolation.defaultVariables,
|
|
500
|
-
...r
|
|
501
|
-
}), !n) {
|
|
502
|
-
r = { ...r };
|
|
503
|
-
for (let e of t) delete r[e];
|
|
504
|
-
}
|
|
505
|
-
return r;
|
|
506
|
-
}
|
|
507
|
-
static hasDefaultValue(e) {
|
|
508
|
-
for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && t.substring(0, 12) === "defaultValue" && e[t] !== void 0) return !0;
|
|
509
|
-
return !1;
|
|
510
|
-
}
|
|
511
|
-
}, B = class {
|
|
512
|
-
constructor(e) {
|
|
513
|
-
this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = j.create("languageUtils");
|
|
514
|
-
}
|
|
515
|
-
getScriptPartFromCode(e) {
|
|
516
|
-
if (e = A(e), !e || e.indexOf("-") < 0) return null;
|
|
517
|
-
let t = e.split("-");
|
|
518
|
-
return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
|
|
519
|
-
}
|
|
520
|
-
getLanguagePartFromCode(e) {
|
|
521
|
-
if (e = A(e), !e || e.indexOf("-") < 0) return e;
|
|
522
|
-
let t = e.split("-");
|
|
523
|
-
return this.formatLanguageCode(t[0]);
|
|
524
|
-
}
|
|
525
|
-
formatLanguageCode(e) {
|
|
526
|
-
if (u(e) && e.indexOf("-") > -1) {
|
|
527
|
-
let t;
|
|
528
|
-
try {
|
|
529
|
-
t = Intl.getCanonicalLocales(e)[0];
|
|
530
|
-
} catch {}
|
|
531
|
-
return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
|
|
532
|
-
}
|
|
533
|
-
return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
|
|
534
|
-
}
|
|
535
|
-
isSupportedCode(e) {
|
|
536
|
-
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
|
|
537
|
-
}
|
|
538
|
-
getBestMatchFromCodes(e) {
|
|
539
|
-
if (!e) return null;
|
|
540
|
-
let t;
|
|
541
|
-
return e.forEach((e) => {
|
|
542
|
-
if (t) return;
|
|
543
|
-
let n = this.formatLanguageCode(e);
|
|
544
|
-
(!this.options.supportedLngs || this.isSupportedCode(n)) && (t = n);
|
|
545
|
-
}), !t && this.options.supportedLngs && e.forEach((e) => {
|
|
546
|
-
if (t) return;
|
|
547
|
-
let n = this.getScriptPartFromCode(e);
|
|
548
|
-
if (this.isSupportedCode(n)) return t = n;
|
|
549
|
-
let r = this.getLanguagePartFromCode(e);
|
|
550
|
-
if (this.isSupportedCode(r)) return t = r;
|
|
551
|
-
t = this.options.supportedLngs.find((e) => {
|
|
552
|
-
if (e === r || !(e.indexOf("-") < 0 && r.indexOf("-") < 0) && (e.indexOf("-") > 0 && r.indexOf("-") < 0 && e.substring(0, e.indexOf("-")) === r || e.indexOf(r) === 0 && r.length > 1)) return e;
|
|
553
|
-
});
|
|
554
|
-
}), t ||= this.getFallbackCodes(this.options.fallbackLng)[0], t;
|
|
555
|
-
}
|
|
556
|
-
getFallbackCodes(e, t) {
|
|
557
|
-
if (!e) return [];
|
|
558
|
-
if (typeof e == "function" && (e = e(t)), u(e) && (e = [e]), Array.isArray(e)) return e;
|
|
559
|
-
if (!t) return e.default || [];
|
|
560
|
-
let n = e[t];
|
|
561
|
-
return n ||= e[this.getScriptPartFromCode(t)], n ||= e[this.formatLanguageCode(t)], n ||= e[this.getLanguagePartFromCode(t)], n ||= e.default, n || [];
|
|
562
|
-
}
|
|
563
|
-
toResolveHierarchy(e, t) {
|
|
564
|
-
let n = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), r = [], i = (e) => {
|
|
565
|
-
e && (this.isSupportedCode(e) ? r.push(e) : this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`));
|
|
566
|
-
};
|
|
567
|
-
return u(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && i(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && i(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && i(this.getLanguagePartFromCode(e))) : u(e) && i(this.formatLanguageCode(e)), n.forEach((e) => {
|
|
568
|
-
r.indexOf(e) < 0 && i(this.formatLanguageCode(e));
|
|
569
|
-
}), r;
|
|
570
|
-
}
|
|
571
|
-
}, V = {
|
|
572
|
-
zero: 0,
|
|
573
|
-
one: 1,
|
|
574
|
-
two: 2,
|
|
575
|
-
few: 3,
|
|
576
|
-
many: 4,
|
|
577
|
-
other: 5
|
|
578
|
-
}, H = {
|
|
579
|
-
select: (e) => e === 1 ? "one" : "other",
|
|
580
|
-
resolvedOptions: () => ({ pluralCategories: ["one", "other"] })
|
|
581
|
-
}, re = class {
|
|
582
|
-
constructor(e, t = {}) {
|
|
583
|
-
this.languageUtils = e, this.options = t, this.logger = j.create("pluralResolver"), this.pluralRulesCache = {};
|
|
584
|
-
}
|
|
585
|
-
clearCache() {
|
|
586
|
-
this.pluralRulesCache = {};
|
|
587
|
-
}
|
|
588
|
-
getRule(e, t = {}) {
|
|
589
|
-
let n = A(e === "dev" ? "en" : e), r = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({
|
|
590
|
-
cleanedCode: n,
|
|
591
|
-
type: r
|
|
592
|
-
});
|
|
593
|
-
if (i in this.pluralRulesCache) return this.pluralRulesCache[i];
|
|
594
|
-
let a;
|
|
595
|
-
try {
|
|
596
|
-
a = new Intl.PluralRules(n, { type: r });
|
|
597
|
-
} catch {
|
|
598
|
-
if (typeof Intl > "u") return this.logger.error("No Intl support, please use an Intl polyfill!"), H;
|
|
599
|
-
if (!e.match(/-|_/)) return H;
|
|
600
|
-
let n = this.languageUtils.getLanguagePartFromCode(e);
|
|
601
|
-
a = this.getRule(n, t);
|
|
602
|
-
}
|
|
603
|
-
return this.pluralRulesCache[i] = a, a;
|
|
604
|
-
}
|
|
605
|
-
needsPlural(e, t = {}) {
|
|
606
|
-
let n = this.getRule(e, t);
|
|
607
|
-
return n ||= this.getRule("dev", t), n?.resolvedOptions().pluralCategories.length > 1;
|
|
608
|
-
}
|
|
609
|
-
getPluralFormsOfKey(e, t, n = {}) {
|
|
610
|
-
return this.getSuffixes(e, n).map((e) => `${t}${e}`);
|
|
611
|
-
}
|
|
612
|
-
getSuffixes(e, t = {}) {
|
|
613
|
-
let n = this.getRule(e, t);
|
|
614
|
-
return n ||= this.getRule("dev", t), n ? n.resolvedOptions().pluralCategories.sort((e, t) => V[e] - V[t]).map((e) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${e}`) : [];
|
|
615
|
-
}
|
|
616
|
-
getSuffix(e, t, n = {}) {
|
|
617
|
-
let r = this.getRule(e, n);
|
|
618
|
-
return r ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${r.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, n));
|
|
619
|
-
}
|
|
620
|
-
}, U = (e, t, n, r = ".", i = !0) => {
|
|
621
|
-
let a = x(e, t, n);
|
|
622
|
-
return !a && i && u(n) && (a = k(e, n, r), a === void 0 && (a = k(t, n, r))), a;
|
|
623
|
-
}, W = (e) => e.replace(/\$/g, "$$$$"), G = class {
|
|
624
|
-
constructor(e = {}) {
|
|
625
|
-
this.logger = j.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((e) => e), this.init(e);
|
|
626
|
-
}
|
|
627
|
-
init(e = {}) {
|
|
628
|
-
e.interpolation ||= { escapeValue: !0 };
|
|
629
|
-
let { escape: t, escapeValue: n, useRawValueToEscape: r, prefix: i, prefixEscaped: a, suffix: o, suffixEscaped: s, formatSeparator: c, unescapeSuffix: l, unescapePrefix: u, nestingPrefix: d, nestingPrefixEscaped: f, nestingSuffix: p, nestingSuffixEscaped: m, nestingOptionsSeparator: h, maxReplaces: g, alwaysFormat: _ } = e.interpolation;
|
|
630
|
-
this.escape = t === void 0 ? T : t, this.escapeValue = n === void 0 ? !0 : n, this.useRawValueToEscape = r === void 0 ? !1 : r, this.prefix = i ? C(i) : a || "{{", this.suffix = o ? C(o) : s || "}}", this.formatSeparator = c || ",", this.unescapePrefix = l ? "" : u || "-", this.unescapeSuffix = this.unescapePrefix ? "" : l || "", this.nestingPrefix = d ? C(d) : f || C("$t("), this.nestingSuffix = p ? C(p) : m || C(")"), this.nestingOptionsSeparator = h || ",", this.maxReplaces = g || 1e3, this.alwaysFormat = _ === void 0 ? !1 : _, this.resetRegExp();
|
|
631
|
-
}
|
|
632
|
-
reset() {
|
|
633
|
-
this.options && this.init(this.options);
|
|
634
|
-
}
|
|
635
|
-
resetRegExp() {
|
|
636
|
-
let e = (e, t) => e?.source === t ? (e.lastIndex = 0, e) : new RegExp(t, "g");
|
|
637
|
-
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}`);
|
|
638
|
-
}
|
|
639
|
-
interpolate(e, t, n, r) {
|
|
640
|
-
let i, a, o, s = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, c = (e) => {
|
|
641
|
-
if (e.indexOf(this.formatSeparator) < 0) {
|
|
642
|
-
let i = U(t, s, e, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
643
|
-
return this.alwaysFormat ? this.format(i, void 0, n, {
|
|
644
|
-
...r,
|
|
645
|
-
...t,
|
|
646
|
-
interpolationkey: e
|
|
647
|
-
}) : i;
|
|
648
|
-
}
|
|
649
|
-
let i = e.split(this.formatSeparator), a = i.shift().trim(), o = i.join(this.formatSeparator).trim();
|
|
650
|
-
return this.format(U(t, s, a, this.options.keySeparator, this.options.ignoreJSONStructure), o, n, {
|
|
651
|
-
...r,
|
|
652
|
-
...t,
|
|
653
|
-
interpolationkey: a
|
|
654
|
-
});
|
|
655
|
-
};
|
|
656
|
-
this.resetRegExp();
|
|
657
|
-
let l = r?.missingInterpolationHandler || this.options.missingInterpolationHandler, d = r?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : r.interpolation.skipOnVariables;
|
|
658
|
-
return [{
|
|
659
|
-
regex: this.regexpUnescape,
|
|
660
|
-
safeValue: (e) => W(e)
|
|
661
|
-
}, {
|
|
662
|
-
regex: this.regexp,
|
|
663
|
-
safeValue: (e) => this.escapeValue ? W(this.escape(e)) : W(e)
|
|
664
|
-
}].forEach((t) => {
|
|
665
|
-
for (o = 0; i = t.regex.exec(e);) {
|
|
666
|
-
let n = i[1].trim();
|
|
667
|
-
if (a = c(n), a === void 0) if (typeof l == "function") {
|
|
668
|
-
let t = l(e, i, r);
|
|
669
|
-
a = u(t) ? t : "";
|
|
670
|
-
} else if (r && Object.prototype.hasOwnProperty.call(r, n)) a = "";
|
|
671
|
-
else if (d) {
|
|
672
|
-
a = i[0];
|
|
673
|
-
continue;
|
|
674
|
-
} else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`), a = "";
|
|
675
|
-
else !u(a) && !this.useRawValueToEscape && (a = f(a));
|
|
676
|
-
let s = t.safeValue(a);
|
|
677
|
-
if (e = e.replace(i[0], s), d ? (t.regex.lastIndex += a.length, t.regex.lastIndex -= i[0].length) : t.regex.lastIndex = 0, o++, o >= this.maxReplaces) break;
|
|
678
|
-
}
|
|
679
|
-
}), e;
|
|
680
|
-
}
|
|
681
|
-
nest(e, t, n = {}) {
|
|
682
|
-
let r, i, a, o = (e, t) => {
|
|
683
|
-
let n = this.nestingOptionsSeparator;
|
|
684
|
-
if (e.indexOf(n) < 0) return e;
|
|
685
|
-
let r = e.split(RegExp(`${C(n)}[ ]*{`)), i = `{${r[1]}`;
|
|
686
|
-
e = r[0], i = this.interpolate(i, a);
|
|
687
|
-
let o = i.match(/'/g), s = i.match(/"/g);
|
|
688
|
-
((o?.length ?? 0) % 2 == 0 && !s || (s?.length ?? 0) % 2 != 0) && (i = i.replace(/'/g, "\""));
|
|
689
|
-
try {
|
|
690
|
-
a = JSON.parse(i), t && (a = {
|
|
691
|
-
...t,
|
|
692
|
-
...a
|
|
693
|
-
});
|
|
694
|
-
} catch (t) {
|
|
695
|
-
return this.logger.warn(`failed parsing options string in nesting for key ${e}`, t), `${e}${n}${i}`;
|
|
696
|
-
}
|
|
697
|
-
return a.defaultValue && a.defaultValue.indexOf(this.prefix) > -1 && delete a.defaultValue, e;
|
|
698
|
-
};
|
|
699
|
-
for (; r = this.nestingRegexp.exec(e);) {
|
|
700
|
-
let s = [];
|
|
701
|
-
a = { ...n }, a = a.replace && !u(a.replace) ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue;
|
|
702
|
-
let c = /{.*}/.test(r[1]) ? r[1].lastIndexOf("}") + 1 : r[1].indexOf(this.formatSeparator);
|
|
703
|
-
if (c !== -1 && (s = r[1].slice(c).split(this.formatSeparator).map((e) => e.trim()).filter(Boolean), r[1] = r[1].slice(0, c)), i = t(o.call(this, r[1].trim(), a), a), i && r[0] === e && !u(i)) return i;
|
|
704
|
-
u(i) || (i = f(i)), i ||= (this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`), ""), s.length && (i = s.reduce((e, t) => this.format(e, t, n.lng, {
|
|
705
|
-
...n,
|
|
706
|
-
interpolationkey: r[1].trim()
|
|
707
|
-
}), i.trim())), e = e.replace(r[0], i), this.regexp.lastIndex = 0;
|
|
708
|
-
}
|
|
709
|
-
return e;
|
|
710
|
-
}
|
|
711
|
-
}, ie = (e) => {
|
|
712
|
-
let t = e.toLowerCase().trim(), n = {};
|
|
713
|
-
if (e.indexOf("(") > -1) {
|
|
714
|
-
let r = e.split("(");
|
|
715
|
-
t = r[0].toLowerCase().trim();
|
|
716
|
-
let i = r[1].substring(0, r[1].length - 1);
|
|
717
|
-
t === "currency" && i.indexOf(":") < 0 ? n.currency ||= i.trim() : t === "relativetime" && i.indexOf(":") < 0 ? n.range ||= i.trim() : i.split(";").forEach((e) => {
|
|
718
|
-
if (e) {
|
|
719
|
-
let [t, ...r] = e.split(":"), i = r.join(":").trim().replace(/^'+|'+$/g, ""), a = t.trim();
|
|
720
|
-
n[a] || (n[a] = i), i === "false" && (n[a] = !1), i === "true" && (n[a] = !0), isNaN(i) || (n[a] = parseInt(i, 10));
|
|
721
|
-
}
|
|
722
|
-
});
|
|
723
|
-
}
|
|
724
|
-
return {
|
|
725
|
-
formatName: t,
|
|
726
|
-
formatOptions: n
|
|
727
|
-
};
|
|
728
|
-
}, K = (e) => {
|
|
729
|
-
let t = {};
|
|
730
|
-
return (n, r, i) => {
|
|
731
|
-
let a = i;
|
|
732
|
-
i && i.interpolationkey && i.formatParams && i.formatParams[i.interpolationkey] && i[i.interpolationkey] && (a = {
|
|
733
|
-
...a,
|
|
734
|
-
[i.interpolationkey]: void 0
|
|
735
|
-
});
|
|
736
|
-
let o = r + JSON.stringify(a), s = t[o];
|
|
737
|
-
return s || (s = e(A(r), i), t[o] = s), s(n);
|
|
738
|
-
};
|
|
739
|
-
}, ae = (e) => (t, n, r) => e(A(n), r)(t), oe = class {
|
|
740
|
-
constructor(e = {}) {
|
|
741
|
-
this.logger = j.create("formatter"), this.options = e, this.init(e);
|
|
742
|
-
}
|
|
743
|
-
init(e, t = { interpolation: {} }) {
|
|
744
|
-
this.formatSeparator = t.interpolation.formatSeparator || ",";
|
|
745
|
-
let n = t.cacheInBuiltFormats ? K : ae;
|
|
746
|
-
this.formats = {
|
|
747
|
-
number: n((e, t) => {
|
|
748
|
-
let n = new Intl.NumberFormat(e, { ...t });
|
|
749
|
-
return (e) => n.format(e);
|
|
750
|
-
}),
|
|
751
|
-
currency: n((e, t) => {
|
|
752
|
-
let n = new Intl.NumberFormat(e, {
|
|
753
|
-
...t,
|
|
754
|
-
style: "currency"
|
|
755
|
-
});
|
|
756
|
-
return (e) => n.format(e);
|
|
757
|
-
}),
|
|
758
|
-
datetime: n((e, t) => {
|
|
759
|
-
let n = new Intl.DateTimeFormat(e, { ...t });
|
|
760
|
-
return (e) => n.format(e);
|
|
761
|
-
}),
|
|
762
|
-
relativetime: n((e, t) => {
|
|
763
|
-
let n = new Intl.RelativeTimeFormat(e, { ...t });
|
|
764
|
-
return (e) => n.format(e, t.range || "day");
|
|
765
|
-
}),
|
|
766
|
-
list: n((e, t) => {
|
|
767
|
-
let n = new Intl.ListFormat(e, { ...t });
|
|
768
|
-
return (e) => n.format(e);
|
|
769
|
-
})
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
add(e, t) {
|
|
773
|
-
this.formats[e.toLowerCase().trim()] = t;
|
|
774
|
-
}
|
|
775
|
-
addCached(e, t) {
|
|
776
|
-
this.formats[e.toLowerCase().trim()] = K(t);
|
|
777
|
-
}
|
|
778
|
-
format(e, t, n, r = {}) {
|
|
779
|
-
let i = t.split(this.formatSeparator);
|
|
780
|
-
if (i.length > 1 && i[0].indexOf("(") > 1 && i[0].indexOf(")") < 0 && i.find((e) => e.indexOf(")") > -1)) {
|
|
781
|
-
let e = i.findIndex((e) => e.indexOf(")") > -1);
|
|
782
|
-
i[0] = [i[0], ...i.splice(1, e)].join(this.formatSeparator);
|
|
783
|
-
}
|
|
784
|
-
return i.reduce((e, t) => {
|
|
785
|
-
let { formatName: i, formatOptions: a } = ie(t);
|
|
786
|
-
if (this.formats[i]) {
|
|
787
|
-
let t = e;
|
|
788
|
-
try {
|
|
789
|
-
let o = r?.formatParams?.[r.interpolationkey] || {}, s = o.locale || o.lng || r.locale || r.lng || n;
|
|
790
|
-
t = this.formats[i](e, s, {
|
|
791
|
-
...a,
|
|
792
|
-
...r,
|
|
793
|
-
...o
|
|
794
|
-
});
|
|
795
|
-
} catch (e) {
|
|
796
|
-
this.logger.warn(e);
|
|
797
|
-
}
|
|
798
|
-
return t;
|
|
799
|
-
} else this.logger.warn(`there was no format function for ${i}`);
|
|
800
|
-
return e;
|
|
801
|
-
}, e);
|
|
802
|
-
}
|
|
803
|
-
}, se = (e, t) => {
|
|
804
|
-
e.pending[t] !== void 0 && (delete e.pending[t], e.pendingCount--);
|
|
805
|
-
}, ce = class extends M {
|
|
806
|
-
constructor(e, t, n, r = {}) {
|
|
807
|
-
super(), this.backend = e, this.store = t, this.services = n, this.languageUtils = n.languageUtils, this.options = r, this.logger = j.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = r.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = r.maxRetries >= 0 ? r.maxRetries : 5, this.retryTimeout = r.retryTimeout >= 1 ? r.retryTimeout : 350, this.state = {}, this.queue = [], this.backend?.init?.(n, r.backend, r);
|
|
808
|
-
}
|
|
809
|
-
queueLoad(e, t, n, r) {
|
|
810
|
-
let i = {}, a = {}, o = {}, s = {};
|
|
811
|
-
return e.forEach((e) => {
|
|
812
|
-
let r = !0;
|
|
813
|
-
t.forEach((t) => {
|
|
814
|
-
let o = `${e}|${t}`;
|
|
815
|
-
!n.reload && this.store.hasResourceBundle(e, t) ? this.state[o] = 2 : this.state[o] < 0 || (this.state[o] === 1 ? a[o] === void 0 && (a[o] = !0) : (this.state[o] = 1, r = !1, a[o] === void 0 && (a[o] = !0), i[o] === void 0 && (i[o] = !0), s[t] === void 0 && (s[t] = !0)));
|
|
816
|
-
}), r || (o[e] = !0);
|
|
817
|
-
}), (Object.keys(i).length || Object.keys(a).length) && this.queue.push({
|
|
818
|
-
pending: a,
|
|
819
|
-
pendingCount: Object.keys(a).length,
|
|
820
|
-
loaded: {},
|
|
821
|
-
errors: [],
|
|
822
|
-
callback: r
|
|
823
|
-
}), {
|
|
824
|
-
toLoad: Object.keys(i),
|
|
825
|
-
pending: Object.keys(a),
|
|
826
|
-
toLoadLanguages: Object.keys(o),
|
|
827
|
-
toLoadNamespaces: Object.keys(s)
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
loaded(e, t, n) {
|
|
831
|
-
let r = e.split("|"), i = r[0], a = r[1];
|
|
832
|
-
t && this.emit("failedLoading", i, a, t), !t && n && this.store.addResourceBundle(i, a, n, void 0, void 0, { skipCopy: !0 }), this.state[e] = t ? -1 : 2, t && n && (this.state[e] = 0);
|
|
833
|
-
let o = {};
|
|
834
|
-
this.queue.forEach((n) => {
|
|
835
|
-
y(n.loaded, [i], a), se(n, e), t && n.errors.push(t), n.pendingCount === 0 && !n.done && (Object.keys(n.loaded).forEach((e) => {
|
|
836
|
-
o[e] || (o[e] = {});
|
|
837
|
-
let t = n.loaded[e];
|
|
838
|
-
t.length && t.forEach((t) => {
|
|
839
|
-
o[e][t] === void 0 && (o[e][t] = !0);
|
|
840
|
-
});
|
|
841
|
-
}), n.done = !0, n.errors.length ? n.callback(n.errors) : n.callback());
|
|
842
|
-
}), this.emit("loaded", o), this.queue = this.queue.filter((e) => !e.done);
|
|
843
|
-
}
|
|
844
|
-
read(e, t, n, r = 0, i = this.retryTimeout, a) {
|
|
845
|
-
if (!e.length) return a(null, {});
|
|
846
|
-
if (this.readingCalls >= this.maxParallelReads) {
|
|
847
|
-
this.waitingReads.push({
|
|
848
|
-
lng: e,
|
|
849
|
-
ns: t,
|
|
850
|
-
fcName: n,
|
|
851
|
-
tried: r,
|
|
852
|
-
wait: i,
|
|
853
|
-
callback: a
|
|
854
|
-
});
|
|
855
|
-
return;
|
|
856
|
-
}
|
|
857
|
-
this.readingCalls++;
|
|
858
|
-
let o = (o, s) => {
|
|
859
|
-
if (this.readingCalls--, this.waitingReads.length > 0) {
|
|
860
|
-
let e = this.waitingReads.shift();
|
|
861
|
-
this.read(e.lng, e.ns, e.fcName, e.tried, e.wait, e.callback);
|
|
862
|
-
}
|
|
863
|
-
if (o && s && r < this.maxRetries) {
|
|
864
|
-
setTimeout(() => {
|
|
865
|
-
this.read.call(this, e, t, n, r + 1, i * 2, a);
|
|
866
|
-
}, i);
|
|
867
|
-
return;
|
|
868
|
-
}
|
|
869
|
-
a(o, s);
|
|
870
|
-
}, s = this.backend[n].bind(this.backend);
|
|
871
|
-
if (s.length === 2) {
|
|
872
|
-
try {
|
|
873
|
-
let n = s(e, t);
|
|
874
|
-
n && typeof n.then == "function" ? n.then((e) => o(null, e)).catch(o) : o(null, n);
|
|
875
|
-
} catch (e) {
|
|
876
|
-
o(e);
|
|
877
|
-
}
|
|
878
|
-
return;
|
|
879
|
-
}
|
|
880
|
-
return s(e, t, o);
|
|
881
|
-
}
|
|
882
|
-
prepareLoading(e, t, n = {}, r) {
|
|
883
|
-
if (!this.backend) return this.logger.warn("No backend was added via i18next.use. Will not load resources."), r && r();
|
|
884
|
-
u(e) && (e = this.languageUtils.toResolveHierarchy(e)), u(t) && (t = [t]);
|
|
885
|
-
let i = this.queueLoad(e, t, n, r);
|
|
886
|
-
if (!i.toLoad.length) return i.pending.length || r(), null;
|
|
887
|
-
i.toLoad.forEach((e) => {
|
|
888
|
-
this.loadOne(e);
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
load(e, t, n) {
|
|
892
|
-
this.prepareLoading(e, t, {}, n);
|
|
893
|
-
}
|
|
894
|
-
reload(e, t, n) {
|
|
895
|
-
this.prepareLoading(e, t, { reload: !0 }, n);
|
|
896
|
-
}
|
|
897
|
-
loadOne(e, t = "") {
|
|
898
|
-
let n = e.split("|"), r = n[0], i = n[1];
|
|
899
|
-
this.read(r, i, "read", void 0, void 0, (n, a) => {
|
|
900
|
-
n && this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`, n), !n && a && this.logger.log(`${t}loaded namespace ${i} for language ${r}`, a), this.loaded(e, n, a);
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
saveMissing(e, t, n, r, i, a = {}, o = () => {}) {
|
|
904
|
-
if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) {
|
|
905
|
-
this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
|
|
906
|
-
return;
|
|
907
|
-
}
|
|
908
|
-
if (!(n == null || n === "")) {
|
|
909
|
-
if (this.backend?.create) {
|
|
910
|
-
let s = {
|
|
911
|
-
...a,
|
|
912
|
-
isUpdate: i
|
|
913
|
-
}, c = this.backend.create.bind(this.backend);
|
|
914
|
-
if (c.length < 6) try {
|
|
915
|
-
let i;
|
|
916
|
-
i = c.length === 5 ? c(e, t, n, r, s) : c(e, t, n, r), i && typeof i.then == "function" ? i.then((e) => o(null, e)).catch(o) : o(null, i);
|
|
917
|
-
} catch (e) {
|
|
918
|
-
o(e);
|
|
919
|
-
}
|
|
920
|
-
else c(e, t, n, r, o, s);
|
|
921
|
-
}
|
|
922
|
-
!e || !e[0] || this.store.addResource(e[0], t, n, r);
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
}, q = () => ({
|
|
926
|
-
debug: !1,
|
|
927
|
-
initAsync: !0,
|
|
928
|
-
ns: ["translation"],
|
|
929
|
-
defaultNS: ["translation"],
|
|
930
|
-
fallbackLng: ["dev"],
|
|
931
|
-
fallbackNS: !1,
|
|
932
|
-
supportedLngs: !1,
|
|
933
|
-
nonExplicitSupportedLngs: !1,
|
|
934
|
-
load: "all",
|
|
935
|
-
preload: !1,
|
|
936
|
-
simplifyPluralSuffix: !0,
|
|
937
|
-
keySeparator: ".",
|
|
938
|
-
nsSeparator: ":",
|
|
939
|
-
pluralSeparator: "_",
|
|
940
|
-
contextSeparator: "_",
|
|
941
|
-
partialBundledLanguages: !1,
|
|
942
|
-
saveMissing: !1,
|
|
943
|
-
updateMissing: !1,
|
|
944
|
-
saveMissingTo: "fallback",
|
|
945
|
-
saveMissingPlurals: !0,
|
|
946
|
-
missingKeyHandler: !1,
|
|
947
|
-
missingInterpolationHandler: !1,
|
|
948
|
-
postProcess: !1,
|
|
949
|
-
postProcessPassResolved: !1,
|
|
950
|
-
returnNull: !1,
|
|
951
|
-
returnEmptyString: !0,
|
|
952
|
-
returnObjects: !1,
|
|
953
|
-
joinArrays: !1,
|
|
954
|
-
returnedObjectHandler: !1,
|
|
955
|
-
parseMissingKeyHandler: !1,
|
|
956
|
-
appendNamespaceToMissingKey: !1,
|
|
957
|
-
appendNamespaceToCIMode: !1,
|
|
958
|
-
overloadTranslationOptionHandler: (e) => {
|
|
959
|
-
let t = {};
|
|
960
|
-
if (typeof e[1] == "object" && (t = e[1]), u(e[1]) && (t.defaultValue = e[1]), u(e[2]) && (t.tDescription = e[2]), typeof e[2] == "object" || typeof e[3] == "object") {
|
|
961
|
-
let n = e[3] || e[2];
|
|
962
|
-
Object.keys(n).forEach((e) => {
|
|
963
|
-
t[e] = n[e];
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
return t;
|
|
967
|
-
},
|
|
968
|
-
interpolation: {
|
|
969
|
-
escapeValue: !0,
|
|
970
|
-
format: (e) => e,
|
|
971
|
-
prefix: "{{",
|
|
972
|
-
suffix: "}}",
|
|
973
|
-
formatSeparator: ",",
|
|
974
|
-
unescapePrefix: "-",
|
|
975
|
-
nestingPrefix: "$t(",
|
|
976
|
-
nestingSuffix: ")",
|
|
977
|
-
nestingOptionsSeparator: ",",
|
|
978
|
-
maxReplaces: 1e3,
|
|
979
|
-
skipOnVariables: !0
|
|
980
|
-
},
|
|
981
|
-
cacheInBuiltFormats: !0
|
|
982
|
-
}), J = (e) => (u(e.ns) && (e.ns = [e.ns]), u(e.fallbackLng) && (e.fallbackLng = [e.fallbackLng]), u(e.fallbackNS) && (e.fallbackNS = [e.fallbackNS]), e.supportedLngs?.indexOf?.("cimode") < 0 && (e.supportedLngs = e.supportedLngs.concat(["cimode"])), typeof e.initImmediate == "boolean" && (e.initAsync = e.initImmediate), e), Y = () => {}, le = (e) => {
|
|
983
|
-
Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((t) => {
|
|
984
|
-
typeof e[t] == "function" && (e[t] = e[t].bind(e));
|
|
985
|
-
});
|
|
986
|
-
}, X = "__i18next_supportNoticeShown", ue = () => !!(typeof globalThis < "u" && globalThis[X] || typeof process < "u" && process.env && process.env.I18NEXT_NO_SUPPORT_NOTICE || typeof process < "u" && process.env && process.env.NODE_ENV === "production"), de = () => {
|
|
987
|
-
typeof globalThis < "u" && (globalThis[X] = !0);
|
|
988
|
-
}, fe = (e) => !!(e?.modules?.backend?.name?.indexOf("Locize") > 0 || e?.modules?.backend?.constructor?.name?.indexOf("Locize") > 0 || e?.options?.backend?.backends && e.options.backend.backends.some((e) => e?.name?.indexOf("Locize") > 0 || e?.constructor?.name?.indexOf("Locize") > 0) || e?.options?.backend?.projectId || e?.options?.backend?.backendOptions && e.options.backend.backendOptions.some((e) => e?.projectId)), Z = class e extends M {
|
|
989
|
-
constructor(e = {}, t) {
|
|
990
|
-
if (super(), this.options = J(e), this.services = {}, this.logger = j, this.modules = { external: [] }, le(this), t && !this.isInitialized && !e.isClone) {
|
|
991
|
-
if (!this.options.initAsync) return this.init(e, t), this;
|
|
992
|
-
setTimeout(() => {
|
|
993
|
-
this.init(e, t);
|
|
994
|
-
}, 0);
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
init(e = {}, t) {
|
|
998
|
-
this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (u(e.ns) ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0]));
|
|
999
|
-
let n = q();
|
|
1000
|
-
this.options = {
|
|
1001
|
-
...n,
|
|
1002
|
-
...this.options,
|
|
1003
|
-
...J(e)
|
|
1004
|
-
}, this.options.interpolation = {
|
|
1005
|
-
...n.interpolation,
|
|
1006
|
-
...this.options.interpolation
|
|
1007
|
-
}, e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator), typeof this.options.overloadTranslationOptionHandler != "function" && (this.options.overloadTranslationOptionHandler = n.overloadTranslationOptionHandler), this.options.showSupportNotice !== !1 && !fe(this) && !ue() && (typeof console < "u" && console.info !== void 0 && console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"), de());
|
|
1008
|
-
let r = (e) => e ? typeof e == "function" ? new e() : e : null;
|
|
1009
|
-
if (!this.options.isClone) {
|
|
1010
|
-
this.modules.logger ? j.init(r(this.modules.logger), this.options) : j.init(null, this.options);
|
|
1011
|
-
let e;
|
|
1012
|
-
e = this.modules.formatter ? this.modules.formatter : oe;
|
|
1013
|
-
let t = new B(this.options);
|
|
1014
|
-
this.store = new N(this.options.resources, this.options);
|
|
1015
|
-
let i = this.services;
|
|
1016
|
-
i.logger = j, i.resourceStore = this.store, i.languageUtils = t, i.pluralResolver = new re(t, {
|
|
1017
|
-
prepend: this.options.pluralSeparator,
|
|
1018
|
-
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1019
|
-
}), this.options.interpolation.format && this.options.interpolation.format !== n.interpolation.format && this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), e && (!this.options.interpolation.format || this.options.interpolation.format === n.interpolation.format) && (i.formatter = r(e), i.formatter.init && i.formatter.init(i, this.options), this.options.interpolation.format = i.formatter.format.bind(i.formatter)), i.interpolator = new G(this.options), i.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) }, i.backendConnector = new ce(r(this.modules.backend), i.resourceStore, i, this.options), i.backendConnector.on("*", (e, ...t) => {
|
|
1020
|
-
this.emit(e, ...t);
|
|
1021
|
-
}), this.modules.languageDetector && (i.languageDetector = r(this.modules.languageDetector), i.languageDetector.init && i.languageDetector.init(i, this.options.detection, this.options)), this.modules.i18nFormat && (i.i18nFormat = r(this.modules.i18nFormat), i.i18nFormat.init && i.i18nFormat.init(this)), this.translator = new z(this.services, this.options), this.translator.on("*", (e, ...t) => {
|
|
1022
|
-
this.emit(e, ...t);
|
|
1023
|
-
}), this.modules.external.forEach((e) => {
|
|
1024
|
-
e.init && e.init(this);
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
if (this.format = this.options.interpolation.format, t ||= Y, this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
1028
|
-
let e = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
1029
|
-
e.length > 0 && e[0] !== "dev" && (this.options.lng = e[0]);
|
|
1030
|
-
}
|
|
1031
|
-
!this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), [
|
|
1032
|
-
"getResource",
|
|
1033
|
-
"hasResourceBundle",
|
|
1034
|
-
"getResourceBundle",
|
|
1035
|
-
"getDataByLanguage"
|
|
1036
|
-
].forEach((e) => {
|
|
1037
|
-
this[e] = (...t) => this.store[e](...t);
|
|
1038
|
-
}), [
|
|
1039
|
-
"addResource",
|
|
1040
|
-
"addResources",
|
|
1041
|
-
"addResourceBundle",
|
|
1042
|
-
"removeResourceBundle"
|
|
1043
|
-
].forEach((e) => {
|
|
1044
|
-
this[e] = (...t) => (this.store[e](...t), this);
|
|
1045
|
-
});
|
|
1046
|
-
let i = d(), a = () => {
|
|
1047
|
-
let e = (e, n) => {
|
|
1048
|
-
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), i.resolve(n), t(e, n);
|
|
1049
|
-
};
|
|
1050
|
-
if (this.languages && !this.isInitialized) return e(null, this.t.bind(this));
|
|
1051
|
-
this.changeLanguage(this.options.lng, e);
|
|
1052
|
-
};
|
|
1053
|
-
return this.options.resources || !this.options.initAsync ? a() : setTimeout(a, 0), i;
|
|
1054
|
-
}
|
|
1055
|
-
loadResources(e, t = Y) {
|
|
1056
|
-
let n = t, r = u(e) ? e : this.language;
|
|
1057
|
-
if (typeof e == "function" && (n = e), !this.options.resources || this.options.partialBundledLanguages) {
|
|
1058
|
-
if (r?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return n();
|
|
1059
|
-
let e = [], t = (t) => {
|
|
1060
|
-
t && t !== "cimode" && this.services.languageUtils.toResolveHierarchy(t).forEach((t) => {
|
|
1061
|
-
t !== "cimode" && e.indexOf(t) < 0 && e.push(t);
|
|
1062
|
-
});
|
|
1063
|
-
};
|
|
1064
|
-
r ? t(r) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((e) => t(e)), this.options.preload?.forEach?.((e) => t(e)), this.services.backendConnector.load(e, this.options.ns, (e) => {
|
|
1065
|
-
!e && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), n(e);
|
|
1066
|
-
});
|
|
1067
|
-
} else n(null);
|
|
1068
|
-
}
|
|
1069
|
-
reloadResources(e, t, n) {
|
|
1070
|
-
let r = d();
|
|
1071
|
-
return typeof e == "function" && (n = e, e = void 0), typeof t == "function" && (n = t, t = void 0), e ||= this.languages, t ||= this.options.ns, n ||= Y, this.services.backendConnector.reload(e, t, (e) => {
|
|
1072
|
-
r.resolve(), n(e);
|
|
1073
|
-
}), r;
|
|
1074
|
-
}
|
|
1075
|
-
use(e) {
|
|
1076
|
-
if (!e) throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
|
|
1077
|
-
if (!e.type) throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
|
|
1078
|
-
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" && P.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
|
|
1079
|
-
}
|
|
1080
|
-
setResolvedLanguage(e) {
|
|
1081
|
-
if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
|
|
1082
|
-
for (let e = 0; e < this.languages.length; e++) {
|
|
1083
|
-
let t = this.languages[e];
|
|
1084
|
-
if (!(["cimode", "dev"].indexOf(t) > -1) && this.store.hasLanguageSomeTranslations(t)) {
|
|
1085
|
-
this.resolvedLanguage = t;
|
|
1086
|
-
break;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
!this.resolvedLanguage && this.languages.indexOf(e) < 0 && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
changeLanguage(e, t) {
|
|
1093
|
-
this.isLanguageChangingTo = e;
|
|
1094
|
-
let n = d();
|
|
1095
|
-
this.emit("languageChanging", e);
|
|
1096
|
-
let r = (e) => {
|
|
1097
|
-
this.language = e, this.languages = this.services.languageUtils.toResolveHierarchy(e), this.resolvedLanguage = void 0, this.setResolvedLanguage(e);
|
|
1098
|
-
}, i = (i, a) => {
|
|
1099
|
-
a ? this.isLanguageChangingTo === e && (r(a), this.translator.changeLanguage(a), this.isLanguageChangingTo = void 0, this.emit("languageChanged", a), this.logger.log("languageChanged", a)) : this.isLanguageChangingTo = void 0, n.resolve((...e) => this.t(...e)), t && t(i, (...e) => this.t(...e));
|
|
1100
|
-
}, a = (t) => {
|
|
1101
|
-
!e && !t && this.services.languageDetector && (t = []);
|
|
1102
|
-
let n = u(t) ? t : t && t[0], a = this.store.hasLanguageSomeTranslations(n) ? n : this.services.languageUtils.getBestMatchFromCodes(u(t) ? [t] : t);
|
|
1103
|
-
a && (this.language || r(a), this.translator.language || this.translator.changeLanguage(a), this.services.languageDetector?.cacheUserLanguage?.(a)), this.loadResources(a, (e) => {
|
|
1104
|
-
i(e, a);
|
|
1105
|
-
});
|
|
1106
|
-
};
|
|
1107
|
-
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), n;
|
|
1108
|
-
}
|
|
1109
|
-
getFixedT(e, t, n) {
|
|
1110
|
-
let r = (e, t, ...i) => {
|
|
1111
|
-
let a;
|
|
1112
|
-
a = typeof t == "object" ? { ...t } : this.options.overloadTranslationOptionHandler([e, t].concat(i)), a.lng = a.lng || r.lng, a.lngs = a.lngs || r.lngs, a.ns = a.ns || r.ns, a.keyPrefix !== "" && (a.keyPrefix = a.keyPrefix || n || r.keyPrefix);
|
|
1113
|
-
let o = {
|
|
1114
|
-
...this.options,
|
|
1115
|
-
...a
|
|
1116
|
-
};
|
|
1117
|
-
typeof a.keyPrefix == "function" && (a.keyPrefix = I(a.keyPrefix, o));
|
|
1118
|
-
let s = this.options.keySeparator || ".", c;
|
|
1119
|
-
return a.keyPrefix && Array.isArray(e) ? c = e.map((e) => (typeof e == "function" && (e = I(e, o)), `${a.keyPrefix}${s}${e}`)) : (typeof e == "function" && (e = I(e, o)), c = a.keyPrefix ? `${a.keyPrefix}${s}${e}` : e), this.t(c, a);
|
|
1120
|
-
};
|
|
1121
|
-
return u(e) ? r.lng = e : r.lngs = e, r.ns = t, r.keyPrefix = n, r;
|
|
1122
|
-
}
|
|
1123
|
-
t(...e) {
|
|
1124
|
-
return this.translator?.translate(...e);
|
|
1125
|
-
}
|
|
1126
|
-
exists(...e) {
|
|
1127
|
-
return this.translator?.exists(...e);
|
|
1128
|
-
}
|
|
1129
|
-
setDefaultNamespace(e) {
|
|
1130
|
-
this.options.defaultNS = e;
|
|
1131
|
-
}
|
|
1132
|
-
hasLoadedNamespace(e, t = {}) {
|
|
1133
|
-
if (!this.isInitialized) return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
|
|
1134
|
-
if (!this.languages || !this.languages.length) return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
|
|
1135
|
-
let n = t.lng || this.resolvedLanguage || this.languages[0], r = this.options ? this.options.fallbackLng : !1, i = this.languages[this.languages.length - 1];
|
|
1136
|
-
if (n.toLowerCase() === "cimode") return !0;
|
|
1137
|
-
let a = (e, t) => {
|
|
1138
|
-
let n = this.services.backendConnector.state[`${e}|${t}`];
|
|
1139
|
-
return n === -1 || n === 0 || n === 2;
|
|
1140
|
-
};
|
|
1141
|
-
if (t.precheck) {
|
|
1142
|
-
let e = t.precheck(this, a);
|
|
1143
|
-
if (e !== void 0) return e;
|
|
1144
|
-
}
|
|
1145
|
-
return !!(this.hasResourceBundle(n, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(n, e) && (!r || a(i, e)));
|
|
1146
|
-
}
|
|
1147
|
-
loadNamespaces(e, t) {
|
|
1148
|
-
let n = d();
|
|
1149
|
-
return this.options.ns ? (u(e) && (e = [e]), e.forEach((e) => {
|
|
1150
|
-
this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
|
|
1151
|
-
}), this.loadResources((e) => {
|
|
1152
|
-
n.resolve(), t && t(e);
|
|
1153
|
-
}), n) : (t && t(), Promise.resolve());
|
|
1154
|
-
}
|
|
1155
|
-
loadLanguages(e, t) {
|
|
1156
|
-
let n = d();
|
|
1157
|
-
u(e) && (e = [e]);
|
|
1158
|
-
let r = this.options.preload || [], i = e.filter((e) => r.indexOf(e) < 0 && this.services.languageUtils.isSupportedCode(e));
|
|
1159
|
-
return i.length ? (this.options.preload = r.concat(i), this.loadResources((e) => {
|
|
1160
|
-
n.resolve(), t && t(e);
|
|
1161
|
-
}), n) : (t && t(), Promise.resolve());
|
|
1162
|
-
}
|
|
1163
|
-
dir(e) {
|
|
1164
|
-
if (e ||= this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language), !e) return "rtl";
|
|
1165
|
-
try {
|
|
1166
|
-
let t = new Intl.Locale(e);
|
|
1167
|
-
if (t && t.getTextInfo) {
|
|
1168
|
-
let e = t.getTextInfo();
|
|
1169
|
-
if (e && e.direction) return e.direction;
|
|
1170
|
-
}
|
|
1171
|
-
} catch {}
|
|
1172
|
-
let t = /* @__PURE__ */ "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".split("."), n = this.services?.languageUtils || new B(q());
|
|
1173
|
-
return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(n.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
1174
|
-
}
|
|
1175
|
-
static createInstance(t = {}, n) {
|
|
1176
|
-
let r = new e(t, n);
|
|
1177
|
-
return r.createInstance = e.createInstance, r;
|
|
1178
|
-
}
|
|
1179
|
-
cloneInstance(t = {}, n = Y) {
|
|
1180
|
-
let r = t.forkResourceStore;
|
|
1181
|
-
r && delete t.forkResourceStore;
|
|
1182
|
-
let i = {
|
|
1183
|
-
...this.options,
|
|
1184
|
-
...t,
|
|
1185
|
-
isClone: !0
|
|
1186
|
-
}, a = new e(i);
|
|
1187
|
-
if ((t.debug !== void 0 || t.prefix !== void 0) && (a.logger = a.logger.clone(t)), [
|
|
1188
|
-
"store",
|
|
1189
|
-
"services",
|
|
1190
|
-
"language"
|
|
1191
|
-
].forEach((e) => {
|
|
1192
|
-
a[e] = this[e];
|
|
1193
|
-
}), a.services = { ...this.services }, a.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, r && (a.store = new N(Object.keys(this.store.data).reduce((e, t) => (e[t] = { ...this.store.data[t] }, e[t] = Object.keys(e[t]).reduce((n, r) => (n[r] = { ...e[t][r] }, n), e[t]), e), {}), i), a.services.resourceStore = a.store), t.interpolation) {
|
|
1194
|
-
let e = {
|
|
1195
|
-
...q().interpolation,
|
|
1196
|
-
...this.options.interpolation,
|
|
1197
|
-
...t.interpolation
|
|
1198
|
-
}, n = {
|
|
1199
|
-
...i,
|
|
1200
|
-
interpolation: e
|
|
1201
|
-
};
|
|
1202
|
-
a.services.interpolator = new G(n);
|
|
1203
|
-
}
|
|
1204
|
-
return a.translator = new z(a.services, i), a.translator.on("*", (e, ...t) => {
|
|
1205
|
-
a.emit(e, ...t);
|
|
1206
|
-
}), a.init(i, n), a.translator.options = i, a.translator.backendConnector.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, a;
|
|
1207
|
-
}
|
|
1208
|
-
toJSON() {
|
|
1209
|
-
return {
|
|
1210
|
-
options: this.options,
|
|
1211
|
-
store: this.store,
|
|
1212
|
-
language: this.language,
|
|
1213
|
-
languages: this.languages,
|
|
1214
|
-
resolvedLanguage: this.resolvedLanguage
|
|
1215
|
-
};
|
|
1216
|
-
}
|
|
1217
|
-
}.createInstance();
|
|
1218
|
-
Z.createInstance, Z.dir, Z.init, Z.loadResources, Z.reloadResources, Z.use, Z.changeLanguage, Z.getFixedT, Z.t, Z.exists, Z.setDefaultNamespace, Z.hasLoadedNamespace, Z.loadNamespaces, Z.loadLanguages;
|
|
1219
|
-
//#endregion
|
|
1220
|
-
//#region node_modules/react-i18next/dist/es/unescape.js
|
|
1221
|
-
var pe = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g, me = {
|
|
1222
|
-
"&": "&",
|
|
1223
|
-
"&": "&",
|
|
1224
|
-
"<": "<",
|
|
1225
|
-
"<": "<",
|
|
1226
|
-
">": ">",
|
|
1227
|
-
">": ">",
|
|
1228
|
-
"'": "'",
|
|
1229
|
-
"'": "'",
|
|
1230
|
-
""": "\"",
|
|
1231
|
-
""": "\"",
|
|
1232
|
-
" ": " ",
|
|
1233
|
-
" ": " ",
|
|
1234
|
-
"©": "©",
|
|
1235
|
-
"©": "©",
|
|
1236
|
-
"®": "®",
|
|
1237
|
-
"®": "®",
|
|
1238
|
-
"…": "…",
|
|
1239
|
-
"…": "…",
|
|
1240
|
-
"/": "/",
|
|
1241
|
-
"/": "/"
|
|
1242
|
-
}, he = (e) => me[e], Q = (e) => e.replace(pe, he), $ = {
|
|
1243
|
-
bindI18n: "languageChanged",
|
|
1244
|
-
bindI18nStore: "",
|
|
1245
|
-
transEmptyNodeValue: "",
|
|
1246
|
-
transSupportBasicHtmlNodes: !0,
|
|
1247
|
-
transWrapTextNodes: "",
|
|
1248
|
-
transKeepBasicHtmlNodesFor: [
|
|
1249
|
-
"br",
|
|
1250
|
-
"strong",
|
|
1251
|
-
"i",
|
|
1252
|
-
"p"
|
|
1253
|
-
],
|
|
1254
|
-
useSuspense: !0,
|
|
1255
|
-
unescape: Q,
|
|
1256
|
-
transDefaultProps: void 0
|
|
1257
|
-
}, ge = (e = {}) => {
|
|
1258
|
-
$ = {
|
|
1259
|
-
...$,
|
|
1260
|
-
...e
|
|
1261
|
-
};
|
|
1262
|
-
}, _e = () => $, ve, ye = (e) => {
|
|
1263
|
-
ve = e;
|
|
1264
|
-
}, be = () => ve, xe = {
|
|
1265
|
-
type: "3rdParty",
|
|
1266
|
-
init(e) {
|
|
1267
|
-
ge(e.options.react), ye(e);
|
|
1268
|
-
}
|
|
1269
|
-
}, Se = function(e) {
|
|
1270
|
-
return {
|
|
1271
|
-
type: "backend",
|
|
1272
|
-
init: function(e, t, n) {},
|
|
1273
|
-
read: function(t, n, r) {
|
|
1274
|
-
if (typeof e == "function") {
|
|
1275
|
-
if (e.length < 3) {
|
|
1276
|
-
try {
|
|
1277
|
-
var i = e(t, n);
|
|
1278
|
-
i && typeof i.then == "function" ? i.then(function(e) {
|
|
1279
|
-
return r(null, e && e.default || e);
|
|
1280
|
-
}).catch(r) : r(null, i);
|
|
1281
|
-
} catch (e) {
|
|
1282
|
-
r(e);
|
|
1283
|
-
}
|
|
1284
|
-
return;
|
|
1285
|
-
}
|
|
1286
|
-
e(t, n, r);
|
|
1287
|
-
return;
|
|
1288
|
-
}
|
|
1289
|
-
r(null, e && e[t] && e[t][n]);
|
|
1290
|
-
}
|
|
1291
|
-
};
|
|
1292
|
-
}, Ce = /* @__PURE__ */ s({ default: () => De }), we = /* #__PURE__ */ Object.assign({
|
|
1293
|
-
"./locales/cs/translation.json": () => import("./translation-BL8dP5qm.js"),
|
|
1294
|
-
"./locales/en/translation.json": () => import("./translation-BYSHywcB.js"),
|
|
1295
|
-
"./locales/sk/translation.json": () => import("./translation-B0QPZgVW.js")
|
|
1296
|
-
}), Te = Array.from(new Set(Object.keys(we).map((e) => e.split("/")[2]).filter((e) => !!e)));
|
|
1297
|
-
function Ee() {
|
|
1298
|
-
try {
|
|
1299
|
-
let e = localStorage.getItem("chatui-settings");
|
|
1300
|
-
if (e) {
|
|
1301
|
-
let t = JSON.parse(e).state?.language;
|
|
1302
|
-
if (t) return t;
|
|
1303
|
-
}
|
|
1304
|
-
} catch {}
|
|
1305
|
-
return "en";
|
|
1306
|
-
}
|
|
1307
|
-
Z.use(Se(async (e, t) => {
|
|
1308
|
-
let n = we[`./locales/${e}/${t}.json`];
|
|
1309
|
-
if (!n) throw Error(`Missing locale bundle: ${e}/${t}`);
|
|
1310
|
-
return (await n()).default;
|
|
1311
|
-
})).use(xe).init({
|
|
1312
|
-
lng: Ee(),
|
|
1313
|
-
fallbackLng: "en",
|
|
1314
|
-
supportedLngs: Te,
|
|
1315
|
-
interpolation: { escapeValue: !1 }
|
|
1316
|
-
});
|
|
1317
|
-
var De = Z;
|
|
1318
|
-
//#endregion
|
|
1319
|
-
export { I as a, l as c, Q as i, be as n, o, _e as r, s, Ce as t };
|
|
1320
|
-
|
|
1321
|
-
//# sourceMappingURL=i18n-DS9aLar5.js.map
|