react-i18next 16.6.6 → 17.0.1
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/CHANGELOG.md +18 -0
- package/dist/amd/react-i18next.js +176 -172
- package/dist/amd/react-i18next.min.js +1 -1
- package/dist/commonjs/TransWithoutContext.js +3 -2
- package/dist/es/TransWithoutContext.js +3 -2
- package/dist/es/package.json +1 -1
- package/dist/umd/react-i18next.js +176 -172
- package/dist/umd/react-i18next.min.js +1 -1
- package/package.json +17 -17
- package/react-i18next.js +176 -172
- package/react-i18next.min.js +1 -1
- package/src/TransWithoutContext.js +5 -2
- package/vitest.workspace.typescript.mts +47 -48
|
@@ -14,7 +14,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
14
14
|
};
|
|
15
15
|
const makeString = object => {
|
|
16
16
|
if (object == null) return '';
|
|
17
|
-
return
|
|
17
|
+
return String(object);
|
|
18
18
|
};
|
|
19
19
|
const copy = (a, s, t) => {
|
|
20
20
|
a.forEach(m => {
|
|
@@ -22,7 +22,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
24
|
const lastOfPathSeparatorRegExp = /###/g;
|
|
25
|
-
const cleanKey = key => key && key.
|
|
25
|
+
const cleanKey = key => key && key.includes('###') ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
|
|
26
26
|
const canNotTraverseDeeper = object => !object || isString$1(object);
|
|
27
27
|
const getLastOfPath = (object, path, Empty) => {
|
|
28
28
|
const stack = !isString$1(path) ? path : path.split('.');
|
|
@@ -107,7 +107,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
107
107
|
return target;
|
|
108
108
|
};
|
|
109
109
|
const regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
110
|
-
|
|
110
|
+
const _entityMap = {
|
|
111
111
|
'&': '&',
|
|
112
112
|
'<': '<',
|
|
113
113
|
'>': '>',
|
|
@@ -146,7 +146,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
146
146
|
const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
|
|
147
147
|
nsSeparator = nsSeparator || '';
|
|
148
148
|
keySeparator = keySeparator || '';
|
|
149
|
-
const possibleChars = chars.filter(c => nsSeparator.
|
|
149
|
+
const possibleChars = chars.filter(c => !nsSeparator.includes(c) && !keySeparator.includes(c));
|
|
150
150
|
if (possibleChars.length === 0) return true;
|
|
151
151
|
const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
|
|
152
152
|
let matched = !r.test(key);
|
|
@@ -179,7 +179,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
179
179
|
nextPath += tokens[j];
|
|
180
180
|
next = current[nextPath];
|
|
181
181
|
if (next !== undefined) {
|
|
182
|
-
if (['string', 'number', 'boolean'].
|
|
182
|
+
if (['string', 'number', 'boolean'].includes(typeof next) && j < tokens.length - 1) {
|
|
183
183
|
continue;
|
|
184
184
|
}
|
|
185
185
|
i += j - i + 1;
|
|
@@ -268,6 +268,14 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
268
268
|
}
|
|
269
269
|
this.observers[event].delete(listener);
|
|
270
270
|
}
|
|
271
|
+
once(event, listener) {
|
|
272
|
+
const wrapper = (...args) => {
|
|
273
|
+
listener(...args);
|
|
274
|
+
this.off(event, wrapper);
|
|
275
|
+
};
|
|
276
|
+
this.on(event, wrapper);
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
271
279
|
emit(event, ...args) {
|
|
272
280
|
if (this.observers[event]) {
|
|
273
281
|
const cloned = Array.from(this.observers[event].entries());
|
|
@@ -281,7 +289,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
281
289
|
const cloned = Array.from(this.observers['*'].entries());
|
|
282
290
|
cloned.forEach(([observer, numTimesAdded]) => {
|
|
283
291
|
for (let i = 0; i < numTimesAdded; i++) {
|
|
284
|
-
observer
|
|
292
|
+
observer(event, ...args);
|
|
285
293
|
}
|
|
286
294
|
});
|
|
287
295
|
}
|
|
@@ -303,7 +311,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
303
311
|
}
|
|
304
312
|
}
|
|
305
313
|
addNamespaces(ns) {
|
|
306
|
-
if (this.options.ns.
|
|
314
|
+
if (!this.options.ns.includes(ns)) {
|
|
307
315
|
this.options.ns.push(ns);
|
|
308
316
|
}
|
|
309
317
|
}
|
|
@@ -317,7 +325,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
317
325
|
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
318
326
|
const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
319
327
|
let path;
|
|
320
|
-
if (lng.
|
|
328
|
+
if (lng.includes('.')) {
|
|
321
329
|
path = lng.split('.');
|
|
322
330
|
} else {
|
|
323
331
|
path = [lng, ns];
|
|
@@ -332,7 +340,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
332
340
|
}
|
|
333
341
|
}
|
|
334
342
|
const result = getPath(this.data, path);
|
|
335
|
-
if (!result && !ns && !key && lng.
|
|
343
|
+
if (!result && !ns && !key && lng.includes('.')) {
|
|
336
344
|
lng = path[0];
|
|
337
345
|
ns = path[1];
|
|
338
346
|
key = path.slice(2).join('.');
|
|
@@ -346,7 +354,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
346
354
|
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
347
355
|
let path = [lng, ns];
|
|
348
356
|
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
349
|
-
if (lng.
|
|
357
|
+
if (lng.includes('.')) {
|
|
350
358
|
path = lng.split('.');
|
|
351
359
|
value = ns;
|
|
352
360
|
ns = path[1];
|
|
@@ -370,7 +378,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
370
378
|
skipCopy: false
|
|
371
379
|
}) {
|
|
372
380
|
let path = [lng, ns];
|
|
373
|
-
if (lng.
|
|
381
|
+
if (lng.includes('.')) {
|
|
374
382
|
path = lng.split('.');
|
|
375
383
|
deep = resources;
|
|
376
384
|
resources = ns;
|
|
@@ -457,7 +465,6 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
457
465
|
}
|
|
458
466
|
return path.join(keySeparator);
|
|
459
467
|
}
|
|
460
|
-
const checkedLoadedFor = {};
|
|
461
468
|
const shouldHandleAsObject = res => !isString$1(res) && typeof res !== 'boolean' && typeof res !== 'number';
|
|
462
469
|
class Translator extends EventEmitter {
|
|
463
470
|
constructor(services, options = {}) {
|
|
@@ -468,6 +475,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
468
475
|
this.options.keySeparator = '.';
|
|
469
476
|
}
|
|
470
477
|
this.logger = baseLogger.create('translator');
|
|
478
|
+
this.checkedLoadedFor = {};
|
|
471
479
|
}
|
|
472
480
|
changeLanguage(lng) {
|
|
473
481
|
if (lng) this.language = lng;
|
|
@@ -492,7 +500,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
492
500
|
if (nsSeparator === undefined) nsSeparator = ':';
|
|
493
501
|
const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
|
|
494
502
|
let namespaces = opt.ns || this.options.defaultNS || [];
|
|
495
|
-
const wouldCheckForNsInKey = nsSeparator && key.
|
|
503
|
+
const wouldCheckForNsInKey = nsSeparator && key.includes(nsSeparator);
|
|
496
504
|
const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
|
|
497
505
|
if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
|
|
498
506
|
const m = key.match(this.interpolator.nestingRegexp);
|
|
@@ -503,7 +511,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
503
511
|
};
|
|
504
512
|
}
|
|
505
513
|
const parts = key.split(nsSeparator);
|
|
506
|
-
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.
|
|
514
|
+
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.includes(parts[0])) namespaces = parts.shift();
|
|
507
515
|
key = parts.join(keySeparator);
|
|
508
516
|
}
|
|
509
517
|
return {
|
|
@@ -590,7 +598,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
590
598
|
}
|
|
591
599
|
const handleAsObject = shouldHandleAsObject(resForObjHndl);
|
|
592
600
|
const resType = Object.prototype.toString.apply(resForObjHndl);
|
|
593
|
-
if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.
|
|
601
|
+
if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString$1(joinArrays) && Array.isArray(resForObjHndl))) {
|
|
594
602
|
if (!opt.returnObjects && !this.options.returnObjects) {
|
|
595
603
|
if (!this.options.returnedObjectHandler) {
|
|
596
604
|
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
|
@@ -686,7 +694,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
686
694
|
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
|
687
695
|
lngs.forEach(language => {
|
|
688
696
|
const suffixes = this.pluralResolver.getSuffixes(language, opt);
|
|
689
|
-
if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.
|
|
697
|
+
if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && !suffixes.includes(`${this.options.pluralSeparator}zero`)) {
|
|
690
698
|
suffixes.push(`${this.options.pluralSeparator}zero`);
|
|
691
699
|
}
|
|
692
700
|
suffixes.forEach(suffix => {
|
|
@@ -796,8 +804,8 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
796
804
|
namespaces.forEach(ns => {
|
|
797
805
|
if (this.isValidLookup(found)) return;
|
|
798
806
|
usedNS = ns;
|
|
799
|
-
if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
|
|
800
|
-
checkedLoadedFor[`${codes[0]}-${ns}`] = true;
|
|
807
|
+
if (!this.checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
|
|
808
|
+
this.checkedLoadedFor[`${codes[0]}-${ns}`] = true;
|
|
801
809
|
this.logger.warn(`key "${usedKey}" for languages "${codes.join(', ')}" won't get resolved as namespace "${usedNS}" 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!!!');
|
|
802
810
|
}
|
|
803
811
|
codes.forEach(code => {
|
|
@@ -812,7 +820,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
812
820
|
const zeroSuffix = `${this.options.pluralSeparator}zero`;
|
|
813
821
|
const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
814
822
|
if (needsPluralHandling) {
|
|
815
|
-
if (opt.ordinal && pluralSuffix.
|
|
823
|
+
if (opt.ordinal && pluralSuffix.startsWith(ordinalPrefix)) {
|
|
816
824
|
finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
817
825
|
}
|
|
818
826
|
finalKeys.push(key + pluralSuffix);
|
|
@@ -824,7 +832,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
824
832
|
const contextKey = `${key}${this.options.contextSeparator || '_'}${opt.context}`;
|
|
825
833
|
finalKeys.push(contextKey);
|
|
826
834
|
if (needsPluralHandling) {
|
|
827
|
-
if (opt.ordinal && pluralSuffix.
|
|
835
|
+
if (opt.ordinal && pluralSuffix.startsWith(ordinalPrefix)) {
|
|
828
836
|
finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
829
837
|
}
|
|
830
838
|
finalKeys.push(contextKey + pluralSuffix);
|
|
@@ -885,7 +893,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
885
893
|
static hasDefaultValue(options) {
|
|
886
894
|
const prefix = 'defaultValue';
|
|
887
895
|
for (const option in options) {
|
|
888
|
-
if (Object.prototype.hasOwnProperty.call(options, option) &&
|
|
896
|
+
if (Object.prototype.hasOwnProperty.call(options, option) && option.startsWith(prefix) && undefined !== options[option]) {
|
|
889
897
|
return true;
|
|
890
898
|
}
|
|
891
899
|
}
|
|
@@ -900,7 +908,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
900
908
|
}
|
|
901
909
|
getScriptPartFromCode(code) {
|
|
902
910
|
code = getCleanedCode(code);
|
|
903
|
-
if (!code || code.
|
|
911
|
+
if (!code || !code.includes('-')) return null;
|
|
904
912
|
const p = code.split('-');
|
|
905
913
|
if (p.length === 2) return null;
|
|
906
914
|
p.pop();
|
|
@@ -909,12 +917,12 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
909
917
|
}
|
|
910
918
|
getLanguagePartFromCode(code) {
|
|
911
919
|
code = getCleanedCode(code);
|
|
912
|
-
if (!code || code.
|
|
920
|
+
if (!code || !code.includes('-')) return code;
|
|
913
921
|
const p = code.split('-');
|
|
914
922
|
return this.formatLanguageCode(p[0]);
|
|
915
923
|
}
|
|
916
924
|
formatLanguageCode(code) {
|
|
917
|
-
if (isString$1(code) && code.
|
|
925
|
+
if (isString$1(code) && code.includes('-')) {
|
|
918
926
|
let formattedCode;
|
|
919
927
|
try {
|
|
920
928
|
formattedCode = Intl.getCanonicalLocales(code)[0];
|
|
@@ -934,7 +942,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
934
942
|
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
|
935
943
|
code = this.getLanguagePartFromCode(code);
|
|
936
944
|
}
|
|
937
|
-
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.
|
|
945
|
+
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.includes(code);
|
|
938
946
|
}
|
|
939
947
|
getBestMatchFromCodes(codes) {
|
|
940
948
|
if (!codes) return null;
|
|
@@ -952,10 +960,11 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
952
960
|
const lngOnly = this.getLanguagePartFromCode(code);
|
|
953
961
|
if (this.isSupportedCode(lngOnly)) return found = lngOnly;
|
|
954
962
|
found = this.options.supportedLngs.find(supportedLng => {
|
|
955
|
-
if (supportedLng === lngOnly) return
|
|
956
|
-
if (supportedLng.
|
|
957
|
-
if (supportedLng.
|
|
958
|
-
if (supportedLng.
|
|
963
|
+
if (supportedLng === lngOnly) return true;
|
|
964
|
+
if (!supportedLng.includes('-') && !lngOnly.includes('-')) return false;
|
|
965
|
+
if (supportedLng.includes('-') && !lngOnly.includes('-') && supportedLng.slice(0, supportedLng.indexOf('-')) === lngOnly) return true;
|
|
966
|
+
if (supportedLng.startsWith(lngOnly) && lngOnly.length > 1) return true;
|
|
967
|
+
return false;
|
|
959
968
|
});
|
|
960
969
|
});
|
|
961
970
|
}
|
|
@@ -986,7 +995,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
986
995
|
this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
|
|
987
996
|
}
|
|
988
997
|
};
|
|
989
|
-
if (isString$1(code) && (code.
|
|
998
|
+
if (isString$1(code) && (code.includes('-') || code.includes('_'))) {
|
|
990
999
|
if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
|
|
991
1000
|
if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
|
|
992
1001
|
if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
|
|
@@ -994,7 +1003,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
994
1003
|
addCode(this.formatLanguageCode(code));
|
|
995
1004
|
}
|
|
996
1005
|
fallbackCodes.forEach(fc => {
|
|
997
|
-
if (codes.
|
|
1006
|
+
if (!codes.includes(fc)) addCode(this.formatLanguageCode(fc));
|
|
998
1007
|
});
|
|
999
1008
|
return codes;
|
|
1000
1009
|
}
|
|
@@ -1148,7 +1157,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1148
1157
|
let replaces;
|
|
1149
1158
|
const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
|
1150
1159
|
const handleFormat = key => {
|
|
1151
|
-
if (key.
|
|
1160
|
+
if (!key.includes(this.formatSeparator)) {
|
|
1152
1161
|
const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
1153
1162
|
return this.alwaysFormat ? this.format(path, undefined, lng, {
|
|
1154
1163
|
...options,
|
|
@@ -1218,7 +1227,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1218
1227
|
let clonedOptions;
|
|
1219
1228
|
const handleHasOptions = (key, inheritedOptions) => {
|
|
1220
1229
|
const sep = this.nestingOptionsSeparator;
|
|
1221
|
-
if (key.
|
|
1230
|
+
if (!key.includes(sep)) return key;
|
|
1222
1231
|
const c = key.split(new RegExp(`${regexEscape(sep)}[ ]*{`));
|
|
1223
1232
|
let optionsString = `{${c[1]}`;
|
|
1224
1233
|
key = c[0];
|
|
@@ -1238,7 +1247,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1238
1247
|
this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
|
|
1239
1248
|
return `${key}${sep}${optionsString}`;
|
|
1240
1249
|
}
|
|
1241
|
-
if (clonedOptions.defaultValue && clonedOptions.defaultValue.
|
|
1250
|
+
if (clonedOptions.defaultValue && clonedOptions.defaultValue.includes(this.prefix)) delete clonedOptions.defaultValue;
|
|
1242
1251
|
return key;
|
|
1243
1252
|
};
|
|
1244
1253
|
while (match = this.nestingRegexp.exec(str)) {
|
|
@@ -1276,13 +1285,13 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1276
1285
|
const parseFormatStr = formatStr => {
|
|
1277
1286
|
let formatName = formatStr.toLowerCase().trim();
|
|
1278
1287
|
const formatOptions = {};
|
|
1279
|
-
if (formatStr.
|
|
1288
|
+
if (formatStr.includes('(')) {
|
|
1280
1289
|
const p = formatStr.split('(');
|
|
1281
1290
|
formatName = p[0].toLowerCase().trim();
|
|
1282
|
-
const optStr = p[1].
|
|
1283
|
-
if (formatName === 'currency' && optStr.
|
|
1291
|
+
const optStr = p[1].slice(0, -1);
|
|
1292
|
+
if (formatName === 'currency' && !optStr.includes(':')) {
|
|
1284
1293
|
if (!formatOptions.currency) formatOptions.currency = optStr.trim();
|
|
1285
|
-
} else if (formatName === 'relativetime' && optStr.
|
|
1294
|
+
} else if (formatName === 'relativetime' && !optStr.includes(':')) {
|
|
1286
1295
|
if (!formatOptions.range) formatOptions.range = optStr.trim();
|
|
1287
1296
|
} else {
|
|
1288
1297
|
const opts = optStr.split(';');
|
|
@@ -1376,9 +1385,11 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1376
1385
|
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
1377
1386
|
}
|
|
1378
1387
|
format(value, format, lng, options = {}) {
|
|
1388
|
+
if (!format) return value;
|
|
1389
|
+
if (value == null) return value;
|
|
1379
1390
|
const formats = format.split(this.formatSeparator);
|
|
1380
|
-
if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].
|
|
1381
|
-
const lastIndex = formats.findIndex(f => f.
|
|
1391
|
+
if (formats.length > 1 && formats[0].indexOf('(') > 1 && !formats[0].includes(')') && formats.find(f => f.includes(')'))) {
|
|
1392
|
+
const lastIndex = formats.findIndex(f => f.includes(')'));
|
|
1382
1393
|
formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
|
|
1383
1394
|
}
|
|
1384
1395
|
const result = formats.reduce((mem, f) => {
|
|
@@ -1531,7 +1542,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1531
1542
|
}
|
|
1532
1543
|
if (err && data && tried < this.maxRetries) {
|
|
1533
1544
|
setTimeout(() => {
|
|
1534
|
-
this.read
|
|
1545
|
+
this.read(lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
1535
1546
|
}, wait);
|
|
1536
1547
|
return;
|
|
1537
1548
|
}
|
|
@@ -1634,7 +1645,6 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1634
1645
|
nonExplicitSupportedLngs: false,
|
|
1635
1646
|
load: 'all',
|
|
1636
1647
|
preload: false,
|
|
1637
|
-
simplifyPluralSuffix: true,
|
|
1638
1648
|
keySeparator: '.',
|
|
1639
1649
|
nsSeparator: ':',
|
|
1640
1650
|
pluralSeparator: '_',
|
|
@@ -1671,7 +1681,6 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1671
1681
|
},
|
|
1672
1682
|
interpolation: {
|
|
1673
1683
|
escapeValue: true,
|
|
1674
|
-
format: value => value,
|
|
1675
1684
|
prefix: '{{',
|
|
1676
1685
|
suffix: '}}',
|
|
1677
1686
|
formatSeparator: ',',
|
|
@@ -1688,10 +1697,9 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1688
1697
|
if (isString$1(options.ns)) options.ns = [options.ns];
|
|
1689
1698
|
if (isString$1(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
|
|
1690
1699
|
if (isString$1(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
|
|
1691
|
-
if (options.supportedLngs
|
|
1700
|
+
if (options.supportedLngs && !options.supportedLngs.includes('cimode')) {
|
|
1692
1701
|
options.supportedLngs = options.supportedLngs.concat(['cimode']);
|
|
1693
1702
|
}
|
|
1694
|
-
if (typeof options.initImmediate === 'boolean') options.initAsync = options.initImmediate;
|
|
1695
1703
|
return options;
|
|
1696
1704
|
};
|
|
1697
1705
|
const noop = () => {};
|
|
@@ -1703,27 +1711,6 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1703
1711
|
}
|
|
1704
1712
|
});
|
|
1705
1713
|
};
|
|
1706
|
-
const SUPPORT_NOTICE_KEY = '__i18next_supportNoticeShown';
|
|
1707
|
-
const getSupportNoticeShown = () => {
|
|
1708
|
-
if (typeof globalThis !== 'undefined' && !!globalThis[SUPPORT_NOTICE_KEY]) return true;
|
|
1709
|
-
if (typeof process !== 'undefined' && process.env && process.env.I18NEXT_NO_SUPPORT_NOTICE) return true;
|
|
1710
|
-
return false;
|
|
1711
|
-
};
|
|
1712
|
-
const setSupportNoticeShown = () => {
|
|
1713
|
-
if (typeof globalThis !== 'undefined') globalThis[SUPPORT_NOTICE_KEY] = true;
|
|
1714
|
-
};
|
|
1715
|
-
const usesLocize = inst => {
|
|
1716
|
-
if (inst?.modules?.backend?.name?.indexOf('Locize') > 0) return true;
|
|
1717
|
-
if (inst?.modules?.backend?.constructor?.name?.indexOf('Locize') > 0) return true;
|
|
1718
|
-
if (inst?.options?.backend?.backends) {
|
|
1719
|
-
if (inst.options.backend.backends.some(b => b?.name?.indexOf('Locize') > 0 || b?.constructor?.name?.indexOf('Locize') > 0)) return true;
|
|
1720
|
-
}
|
|
1721
|
-
if (inst?.options?.backend?.projectId) return true;
|
|
1722
|
-
if (inst?.options?.backend?.backendOptions) {
|
|
1723
|
-
if (inst.options.backend.backendOptions.some(b => b?.projectId)) return true;
|
|
1724
|
-
}
|
|
1725
|
-
return false;
|
|
1726
|
-
};
|
|
1727
1714
|
class I18n extends EventEmitter {
|
|
1728
1715
|
constructor(options = {}, callback) {
|
|
1729
1716
|
super();
|
|
@@ -1753,7 +1740,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1753
1740
|
if (options.defaultNS == null && options.ns) {
|
|
1754
1741
|
if (isString$1(options.ns)) {
|
|
1755
1742
|
options.defaultNS = options.ns;
|
|
1756
|
-
} else if (options.ns.
|
|
1743
|
+
} else if (!options.ns.includes('translation')) {
|
|
1757
1744
|
options.defaultNS = options.ns[0];
|
|
1758
1745
|
}
|
|
1759
1746
|
}
|
|
@@ -1776,10 +1763,6 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1776
1763
|
if (typeof this.options.overloadTranslationOptionHandler !== 'function') {
|
|
1777
1764
|
this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
|
|
1778
1765
|
}
|
|
1779
|
-
if (this.options.showSupportNotice !== false && !usesLocize(this) && !getSupportNoticeShown()) {
|
|
1780
|
-
if (typeof console !== 'undefined' && typeof console.info !== 'undefined') console.info('🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙');
|
|
1781
|
-
setSupportNoticeShown();
|
|
1782
|
-
}
|
|
1783
1766
|
const createClassOnDemand = ClassOrObject => {
|
|
1784
1767
|
if (!ClassOrObject) return null;
|
|
1785
1768
|
if (typeof ClassOrObject === 'function') return new ClassOrObject();
|
|
@@ -1804,14 +1787,9 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1804
1787
|
s.resourceStore = this.store;
|
|
1805
1788
|
s.languageUtils = lu;
|
|
1806
1789
|
s.pluralResolver = new PluralResolver(lu, {
|
|
1807
|
-
prepend: this.options.pluralSeparator
|
|
1808
|
-
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1790
|
+
prepend: this.options.pluralSeparator
|
|
1809
1791
|
});
|
|
1810
|
-
|
|
1811
|
-
if (usingLegacyFormatFunction) {
|
|
1812
|
-
this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
|
|
1813
|
-
}
|
|
1814
|
-
if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
|
|
1792
|
+
if (formatter) {
|
|
1815
1793
|
s.formatter = createClassOnDemand(formatter);
|
|
1816
1794
|
if (s.formatter.init) s.formatter.init(s, this.options);
|
|
1817
1795
|
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
@@ -1894,7 +1872,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1894
1872
|
const lngs = this.services.languageUtils.toResolveHierarchy(lng);
|
|
1895
1873
|
lngs.forEach(l => {
|
|
1896
1874
|
if (l === 'cimode') return;
|
|
1897
|
-
if (toLoad.
|
|
1875
|
+
if (!toLoad.includes(l)) toLoad.push(l);
|
|
1898
1876
|
});
|
|
1899
1877
|
};
|
|
1900
1878
|
if (!usedLng) {
|
|
@@ -1959,16 +1937,16 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
1959
1937
|
}
|
|
1960
1938
|
setResolvedLanguage(l) {
|
|
1961
1939
|
if (!l || !this.languages) return;
|
|
1962
|
-
if (['cimode', 'dev'].
|
|
1940
|
+
if (['cimode', 'dev'].includes(l)) return;
|
|
1963
1941
|
for (let li = 0; li < this.languages.length; li++) {
|
|
1964
1942
|
const lngInLngs = this.languages[li];
|
|
1965
|
-
if (['cimode', 'dev'].
|
|
1943
|
+
if (['cimode', 'dev'].includes(lngInLngs)) continue;
|
|
1966
1944
|
if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
|
|
1967
1945
|
this.resolvedLanguage = lngInLngs;
|
|
1968
1946
|
break;
|
|
1969
1947
|
}
|
|
1970
1948
|
}
|
|
1971
|
-
if (!this.resolvedLanguage && this.languages.
|
|
1949
|
+
if (!this.resolvedLanguage && !this.languages.includes(l) && this.store.hasLanguageSomeTranslations(l)) {
|
|
1972
1950
|
this.resolvedLanguage = l;
|
|
1973
1951
|
this.languages.unshift(l);
|
|
1974
1952
|
}
|
|
@@ -2110,7 +2088,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
2110
2088
|
}
|
|
2111
2089
|
if (isString$1(ns)) ns = [ns];
|
|
2112
2090
|
ns.forEach(n => {
|
|
2113
|
-
if (this.options.ns.
|
|
2091
|
+
if (!this.options.ns.includes(n)) this.options.ns.push(n);
|
|
2114
2092
|
});
|
|
2115
2093
|
this.loadResources(err => {
|
|
2116
2094
|
deferred.resolve();
|
|
@@ -2122,7 +2100,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
2122
2100
|
const deferred = defer();
|
|
2123
2101
|
if (isString$1(lngs)) lngs = [lngs];
|
|
2124
2102
|
const preloaded = this.options.preload || [];
|
|
2125
|
-
const newLngs = lngs.filter(lng => preloaded.
|
|
2103
|
+
const newLngs = lngs.filter(lng => !preloaded.includes(lng) && this.services.languageUtils.isSupportedCode(lng));
|
|
2126
2104
|
if (!newLngs.length) {
|
|
2127
2105
|
if (callback) callback();
|
|
2128
2106
|
return Promise.resolve();
|
|
@@ -2147,7 +2125,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
2147
2125
|
const rtlLngs = ['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'];
|
|
2148
2126
|
const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
|
|
2149
2127
|
if (lng.toLowerCase().indexOf('-latn') > 1) return 'ltr';
|
|
2150
|
-
return rtlLngs.
|
|
2128
|
+
return rtlLngs.includes(languageUtils.getLanguagePartFromCode(lng)) || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
|
|
2151
2129
|
}
|
|
2152
2130
|
static createInstance(options = {}, callback) {
|
|
2153
2131
|
const instance = new I18n(options, callback);
|
|
@@ -2248,24 +2226,33 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
2248
2226
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
2249
2227
|
}
|
|
2250
2228
|
|
|
2251
|
-
var voidElements
|
|
2252
|
-
|
|
2253
|
-
"base": true,
|
|
2254
|
-
"br": true,
|
|
2255
|
-
"col": true,
|
|
2256
|
-
"embed": true,
|
|
2257
|
-
"hr": true,
|
|
2258
|
-
"img": true,
|
|
2259
|
-
"input": true,
|
|
2260
|
-
"link": true,
|
|
2261
|
-
"meta": true,
|
|
2262
|
-
"param": true,
|
|
2263
|
-
"source": true,
|
|
2264
|
-
"track": true,
|
|
2265
|
-
"wbr": true
|
|
2266
|
-
};
|
|
2229
|
+
var voidElements;
|
|
2230
|
+
var hasRequiredVoidElements;
|
|
2267
2231
|
|
|
2268
|
-
|
|
2232
|
+
function requireVoidElements () {
|
|
2233
|
+
if (hasRequiredVoidElements) return voidElements;
|
|
2234
|
+
hasRequiredVoidElements = 1;
|
|
2235
|
+
voidElements = {
|
|
2236
|
+
"area": true,
|
|
2237
|
+
"base": true,
|
|
2238
|
+
"br": true,
|
|
2239
|
+
"col": true,
|
|
2240
|
+
"embed": true,
|
|
2241
|
+
"hr": true,
|
|
2242
|
+
"img": true,
|
|
2243
|
+
"input": true,
|
|
2244
|
+
"link": true,
|
|
2245
|
+
"meta": true,
|
|
2246
|
+
"param": true,
|
|
2247
|
+
"source": true,
|
|
2248
|
+
"track": true,
|
|
2249
|
+
"wbr": true
|
|
2250
|
+
};
|
|
2251
|
+
return voidElements;
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
var voidElementsExports = requireVoidElements();
|
|
2255
|
+
var e = /*@__PURE__*/getDefaultExportFromCjs(voidElementsExports);
|
|
2269
2256
|
|
|
2270
2257
|
var t = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
|
|
2271
2258
|
function n(n) {
|
|
@@ -2534,8 +2521,9 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
2534
2521
|
stringNode += `<${childIndex}></${childIndex}>`;
|
|
2535
2522
|
return;
|
|
2536
2523
|
}
|
|
2537
|
-
if (shouldKeepChild && childPropsCount
|
|
2538
|
-
|
|
2524
|
+
if (shouldKeepChild && childPropsCount <= 1) {
|
|
2525
|
+
const cnt = isString(childChildren) ? childChildren : nodesToString(childChildren, i18nOptions, i18n, i18nKey);
|
|
2526
|
+
stringNode += `<${type}>${cnt}</${type}>`;
|
|
2539
2527
|
return;
|
|
2540
2528
|
}
|
|
2541
2529
|
const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
|
|
@@ -3440,77 +3428,93 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
|
|
|
3440
3428
|
* LICENSE file in the root directory of this source tree.
|
|
3441
3429
|
*/
|
|
3442
3430
|
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3431
|
+
var hasRequiredUseSyncExternalStoreShim_development;
|
|
3432
|
+
|
|
3433
|
+
function requireUseSyncExternalStoreShim_development () {
|
|
3434
|
+
if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
|
|
3435
|
+
hasRequiredUseSyncExternalStoreShim_development = 1;
|
|
3436
|
+
|
|
3437
|
+
(function () {
|
|
3438
|
+
function is(x, y) {
|
|
3439
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
3440
|
+
}
|
|
3441
|
+
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
3442
|
+
didWarnOld18Alpha || void 0 === React$1.startTransition || (didWarnOld18Alpha = true, console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
|
|
3443
|
+
var value = getSnapshot();
|
|
3444
|
+
if (!didWarnUncachedGetSnapshot) {
|
|
3445
|
+
var cachedValue = getSnapshot();
|
|
3446
|
+
objectIs(value, cachedValue) || (console.error("The result of getSnapshot should be cached to avoid an infinite loop"), didWarnUncachedGetSnapshot = true);
|
|
3447
|
+
}
|
|
3448
|
+
cachedValue = useState({
|
|
3449
|
+
inst: {
|
|
3450
|
+
value: value,
|
|
3451
|
+
getSnapshot: getSnapshot
|
|
3452
|
+
}
|
|
3453
|
+
});
|
|
3454
|
+
var inst = cachedValue[0].inst,
|
|
3455
|
+
forceUpdate = cachedValue[1];
|
|
3456
|
+
useLayoutEffect(function () {
|
|
3457
|
+
inst.value = value;
|
|
3458
|
+
inst.getSnapshot = getSnapshot;
|
|
3459
|
+
checkIfSnapshotChanged(inst) && forceUpdate({
|
|
3460
|
+
inst: inst
|
|
3461
|
+
});
|
|
3462
|
+
}, [subscribe, value, getSnapshot]);
|
|
3463
|
+
useEffect(function () {
|
|
3464
|
+
checkIfSnapshotChanged(inst) && forceUpdate({
|
|
3465
|
+
inst: inst
|
|
3466
|
+
});
|
|
3467
|
+
return subscribe(function () {
|
|
3468
|
+
checkIfSnapshotChanged(inst) && forceUpdate({
|
|
3469
|
+
inst: inst
|
|
3470
|
+
});
|
|
3471
|
+
});
|
|
3472
|
+
}, [subscribe]);
|
|
3473
|
+
useDebugValue(value);
|
|
3474
|
+
return value;
|
|
3475
|
+
}
|
|
3476
|
+
function checkIfSnapshotChanged(inst) {
|
|
3477
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
3478
|
+
inst = inst.value;
|
|
3479
|
+
try {
|
|
3480
|
+
var nextValue = latestGetSnapshot();
|
|
3481
|
+
return !objectIs(inst, nextValue);
|
|
3482
|
+
} catch (error) {
|
|
3483
|
+
return true;
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
3487
|
+
return getSnapshot();
|
|
3488
|
+
}
|
|
3489
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
3490
|
+
var React$1 = React,
|
|
3491
|
+
objectIs = "function" === typeof Object.is ? Object.is : is,
|
|
3492
|
+
useState = React$1.useState,
|
|
3493
|
+
useEffect = React$1.useEffect,
|
|
3494
|
+
useLayoutEffect = React$1.useLayoutEffect,
|
|
3495
|
+
useDebugValue = React$1.useDebugValue,
|
|
3496
|
+
didWarnOld18Alpha = false,
|
|
3497
|
+
didWarnUncachedGetSnapshot = false,
|
|
3498
|
+
shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
3499
|
+
useSyncExternalStoreShim_development.useSyncExternalStore = void 0 !== React$1.useSyncExternalStore ? React$1.useSyncExternalStore : shim;
|
|
3500
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
3501
|
+
})();
|
|
3502
|
+
return useSyncExternalStoreShim_development;
|
|
3503
|
+
}
|
|
3504
|
+
|
|
3505
|
+
var hasRequiredShim;
|
|
3506
|
+
|
|
3507
|
+
function requireShim () {
|
|
3508
|
+
if (hasRequiredShim) return shim.exports;
|
|
3509
|
+
hasRequiredShim = 1;
|
|
3508
3510
|
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
+
{
|
|
3512
|
+
shim.exports = requireUseSyncExternalStoreShim_development();
|
|
3513
|
+
}
|
|
3514
|
+
return shim.exports;
|
|
3511
3515
|
}
|
|
3512
3516
|
|
|
3513
|
-
var shimExports =
|
|
3517
|
+
var shimExports = requireShim();
|
|
3514
3518
|
|
|
3515
3519
|
const notReadyT = (k, optsOrDefaultValue) => {
|
|
3516
3520
|
if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
|