react-i18next 17.0.0 → 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 CHANGED
@@ -1,3 +1,8 @@
1
+ ## 17.0.1
2
+
3
+ - chore: bump minimum i18next peer dependency to `>= 26.0.1` _(forgot to do it in last version)_
4
+ - fix: migrate test setup from removed legacy `interpolation.format` to `i18n.services.formatter.add()` (i18next v26)
5
+
1
6
  ## 17.0.0
2
7
 
3
8
  ### Potentially breaking changes
@@ -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 '' + object;
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.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : 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
- var _entityMap = {
110
+ const _entityMap = {
111
111
  '&': '&',
112
112
  '<': '&lt;',
113
113
  '>': '&gt;',
@@ -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.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
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'].indexOf(typeof next) > -1 && j < tokens.length - 1) {
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.apply(observer, [event, ...args]);
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.indexOf(ns) < 0) {
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.indexOf('.') > -1) {
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.indexOf('.') > -1) {
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.indexOf('.') > -1) {
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.indexOf('.') > -1) {
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.indexOf(nsSeparator) > -1;
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.indexOf(parts[0]) > -1) namespaces = parts.shift();
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.indexOf(resType) < 0 && !(isString$1(joinArrays) && Array.isArray(resForObjHndl))) {
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.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
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.indexOf(ordinalPrefix) === 0) {
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.indexOf(ordinalPrefix) === 0) {
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) && prefix === option.substring(0, prefix.length) && undefined !== 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.indexOf('-') < 0) return null;
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.indexOf('-') < 0) return 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.indexOf('-') > -1) {
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.indexOf(code) > -1;
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 supportedLng;
956
- if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
957
- if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng;
958
- if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return 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.indexOf('-') > -1 || code.indexOf('_') > -1)) {
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.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
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.indexOf(this.formatSeparator) < 0) {
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.indexOf(sep) < 0) return 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.indexOf(this.prefix) > -1) delete 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.indexOf('(') > -1) {
1288
+ if (formatStr.includes('(')) {
1280
1289
  const p = formatStr.split('(');
1281
1290
  formatName = p[0].toLowerCase().trim();
1282
- const optStr = p[1].substring(0, p[1].length - 1);
1283
- if (formatName === 'currency' && optStr.indexOf(':') < 0) {
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.indexOf(':') < 0) {
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].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
1381
- const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
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.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
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?.indexOf?.('cimode') < 0) {
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,28 +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
- if (typeof process !== 'undefined' && process.env && "development" === 'production') ;
1711
- return false;
1712
- };
1713
- const setSupportNoticeShown = () => {
1714
- if (typeof globalThis !== 'undefined') globalThis[SUPPORT_NOTICE_KEY] = true;
1715
- };
1716
- const usesLocize = inst => {
1717
- if (inst?.modules?.backend?.name?.indexOf('Locize') > 0) return true;
1718
- if (inst?.modules?.backend?.constructor?.name?.indexOf('Locize') > 0) return true;
1719
- if (inst?.options?.backend?.backends) {
1720
- if (inst.options.backend.backends.some(b => b?.name?.indexOf('Locize') > 0 || b?.constructor?.name?.indexOf('Locize') > 0)) return true;
1721
- }
1722
- if (inst?.options?.backend?.projectId) return true;
1723
- if (inst?.options?.backend?.backendOptions) {
1724
- if (inst.options.backend.backendOptions.some(b => b?.projectId)) return true;
1725
- }
1726
- return false;
1727
- };
1728
1714
  class I18n extends EventEmitter {
1729
1715
  constructor(options = {}, callback) {
1730
1716
  super();
@@ -1754,7 +1740,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
1754
1740
  if (options.defaultNS == null && options.ns) {
1755
1741
  if (isString$1(options.ns)) {
1756
1742
  options.defaultNS = options.ns;
1757
- } else if (options.ns.indexOf('translation') < 0) {
1743
+ } else if (!options.ns.includes('translation')) {
1758
1744
  options.defaultNS = options.ns[0];
1759
1745
  }
1760
1746
  }
@@ -1777,10 +1763,6 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
1777
1763
  if (typeof this.options.overloadTranslationOptionHandler !== 'function') {
1778
1764
  this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
1779
1765
  }
1780
- if (this.options.showSupportNotice !== false && !usesLocize(this) && !getSupportNoticeShown()) {
1781
- 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 💙');
1782
- setSupportNoticeShown();
1783
- }
1784
1766
  const createClassOnDemand = ClassOrObject => {
1785
1767
  if (!ClassOrObject) return null;
1786
1768
  if (typeof ClassOrObject === 'function') return new ClassOrObject();
@@ -1805,14 +1787,9 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
1805
1787
  s.resourceStore = this.store;
1806
1788
  s.languageUtils = lu;
1807
1789
  s.pluralResolver = new PluralResolver(lu, {
1808
- prepend: this.options.pluralSeparator,
1809
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1790
+ prepend: this.options.pluralSeparator
1810
1791
  });
1811
- const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
1812
- if (usingLegacyFormatFunction) {
1813
- this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
1814
- }
1815
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1792
+ if (formatter) {
1816
1793
  s.formatter = createClassOnDemand(formatter);
1817
1794
  if (s.formatter.init) s.formatter.init(s, this.options);
1818
1795
  this.options.interpolation.format = s.formatter.format.bind(s.formatter);
@@ -1895,7 +1872,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
1895
1872
  const lngs = this.services.languageUtils.toResolveHierarchy(lng);
1896
1873
  lngs.forEach(l => {
1897
1874
  if (l === 'cimode') return;
1898
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
1875
+ if (!toLoad.includes(l)) toLoad.push(l);
1899
1876
  });
1900
1877
  };
1901
1878
  if (!usedLng) {
@@ -1960,16 +1937,16 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
1960
1937
  }
1961
1938
  setResolvedLanguage(l) {
1962
1939
  if (!l || !this.languages) return;
1963
- if (['cimode', 'dev'].indexOf(l) > -1) return;
1940
+ if (['cimode', 'dev'].includes(l)) return;
1964
1941
  for (let li = 0; li < this.languages.length; li++) {
1965
1942
  const lngInLngs = this.languages[li];
1966
- if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
1943
+ if (['cimode', 'dev'].includes(lngInLngs)) continue;
1967
1944
  if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
1968
1945
  this.resolvedLanguage = lngInLngs;
1969
1946
  break;
1970
1947
  }
1971
1948
  }
1972
- if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
1949
+ if (!this.resolvedLanguage && !this.languages.includes(l) && this.store.hasLanguageSomeTranslations(l)) {
1973
1950
  this.resolvedLanguage = l;
1974
1951
  this.languages.unshift(l);
1975
1952
  }
@@ -2111,7 +2088,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
2111
2088
  }
2112
2089
  if (isString$1(ns)) ns = [ns];
2113
2090
  ns.forEach(n => {
2114
- if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2091
+ if (!this.options.ns.includes(n)) this.options.ns.push(n);
2115
2092
  });
2116
2093
  this.loadResources(err => {
2117
2094
  deferred.resolve();
@@ -2123,7 +2100,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
2123
2100
  const deferred = defer();
2124
2101
  if (isString$1(lngs)) lngs = [lngs];
2125
2102
  const preloaded = this.options.preload || [];
2126
- const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
2103
+ const newLngs = lngs.filter(lng => !preloaded.includes(lng) && this.services.languageUtils.isSupportedCode(lng));
2127
2104
  if (!newLngs.length) {
2128
2105
  if (callback) callback();
2129
2106
  return Promise.resolve();
@@ -2148,7 +2125,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
2148
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'];
2149
2126
  const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
2150
2127
  if (lng.toLowerCase().indexOf('-latn') > 1) return 'ltr';
2151
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2128
+ return rtlLngs.includes(languageUtils.getLanguagePartFromCode(lng)) || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2152
2129
  }
2153
2130
  static createInstance(options = {}, callback) {
2154
2131
  const instance = new I18n(options, callback);