locizify 9.0.8 → 9.0.9

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.
@@ -175,7 +175,7 @@
175
175
  };
176
176
  var makeString = object => {
177
177
  if (object == null) return '';
178
- return '' + object;
178
+ return String(object);
179
179
  };
180
180
  var copy = (a, s, t) => {
181
181
  a.forEach(m => {
@@ -183,7 +183,7 @@
183
183
  });
184
184
  };
185
185
  var lastOfPathSeparatorRegExp = /###/g;
186
- var cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
186
+ var cleanKey = key => key && key.includes('###') ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
187
187
  var canNotTraverseDeeper = object => !object || isString(object);
188
188
  var getLastOfPath = (object, path, Empty) => {
189
189
  var stack = !isString(path) ? path : path.split('.');
@@ -308,7 +308,7 @@
308
308
  var looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
309
309
  nsSeparator = nsSeparator || '';
310
310
  keySeparator = keySeparator || '';
311
- var possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
311
+ var possibleChars = chars.filter(c => !nsSeparator.includes(c) && !keySeparator.includes(c));
312
312
  if (possibleChars.length === 0) return true;
313
313
  var r = looksLikeObjectPathRegExpCache.getRegExp("(".concat(possibleChars.map(c => c === '?' ? '\\?' : c).join('|'), ")"));
314
314
  var matched = !r.test(key);
@@ -342,7 +342,7 @@
342
342
  nextPath += tokens[j];
343
343
  next = current[nextPath];
344
344
  if (next !== undefined) {
345
- if (['string', 'number', 'boolean'].indexOf(typeof next) > -1 && j < tokens.length - 1) {
345
+ if (['string', 'number', 'boolean'].includes(typeof next) && j < tokens.length - 1) {
346
346
  continue;
347
347
  }
348
348
  i += j - i + 1;
@@ -353,7 +353,7 @@
353
353
  }
354
354
  return current;
355
355
  };
356
- var getCleanedCode = code => code === null || code === void 0 ? void 0 : code.replace('_', '-');
356
+ var getCleanedCode = code => code === null || code === void 0 ? void 0 : code.replace(/_/g, '-');
357
357
  var consoleLogger = {
358
358
  type: 'logger',
359
359
  log(args) {
@@ -443,6 +443,15 @@
443
443
  }
444
444
  this.observers[event].delete(listener);
445
445
  }
446
+ once(event, listener) {
447
+ var _this = this;
448
+ var _wrapper = function wrapper() {
449
+ listener(...arguments);
450
+ _this.off(event, _wrapper);
451
+ };
452
+ this.on(event, _wrapper);
453
+ return this;
454
+ }
446
455
  emit(event) {
447
456
  for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
448
457
  args[_key5 - 1] = arguments[_key5];
@@ -461,7 +470,7 @@
461
470
  _cloned.forEach(_ref2 => {
462
471
  var [observer, numTimesAdded] = _ref2;
463
472
  for (var i = 0; i < numTimesAdded; i++) {
464
- observer.apply(observer, [event, ...args]);
473
+ observer(event, ...args);
465
474
  }
466
475
  });
467
476
  }
@@ -484,7 +493,7 @@
484
493
  }
485
494
  }
486
495
  addNamespaces(ns) {
487
- if (this.options.ns.indexOf(ns) < 0) {
496
+ if (!this.options.ns.includes(ns)) {
488
497
  this.options.ns.push(ns);
489
498
  }
490
499
  }
@@ -500,7 +509,7 @@
500
509
  var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
501
510
  var ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
502
511
  var path;
503
- if (lng.indexOf('.') > -1) {
512
+ if (lng.includes('.')) {
504
513
  path = lng.split('.');
505
514
  } else {
506
515
  path = [lng, ns];
@@ -515,7 +524,7 @@
515
524
  }
516
525
  }
517
526
  var result = getPath(this.data, path);
518
- if (!result && !ns && !key && lng.indexOf('.') > -1) {
527
+ if (!result && !ns && !key && lng.includes('.')) {
519
528
  lng = path[0];
520
529
  ns = path[1];
521
530
  key = path.slice(2).join('.');
@@ -530,7 +539,7 @@
530
539
  var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
531
540
  var path = [lng, ns];
532
541
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
533
- if (lng.indexOf('.') > -1) {
542
+ if (lng.includes('.')) {
534
543
  path = lng.split('.');
535
544
  value = ns;
536
545
  ns = path[1];
@@ -556,7 +565,7 @@
556
565
  skipCopy: false
557
566
  };
558
567
  var path = [lng, ns];
559
- if (lng.indexOf('.') > -1) {
568
+ if (lng.includes('.')) {
560
569
  path = lng.split('.');
561
570
  deep = resources;
562
571
  resources = ns;
@@ -628,13 +637,21 @@
628
637
  return Proxy.revocable(Object.create(null), handler).proxy;
629
638
  }
630
639
  function keysFromSelector(selector, opts) {
631
- var _opts$keySeparator;
640
+ var _opts$keySeparator, _opts$nsSeparator;
632
641
  var {
633
642
  [PATH_KEY]: path
634
643
  } = selector(createProxy());
635
- return path.join((_opts$keySeparator = opts === null || opts === void 0 ? void 0 : opts.keySeparator) !== null && _opts$keySeparator !== void 0 ? _opts$keySeparator : '.');
644
+ var keySeparator = (_opts$keySeparator = opts === null || opts === void 0 ? void 0 : opts.keySeparator) !== null && _opts$keySeparator !== void 0 ? _opts$keySeparator : '.';
645
+ var nsSeparator = (_opts$nsSeparator = opts === null || opts === void 0 ? void 0 : opts.nsSeparator) !== null && _opts$nsSeparator !== void 0 ? _opts$nsSeparator : ':';
646
+ if (path.length > 1 && nsSeparator) {
647
+ var ns = opts === null || opts === void 0 ? void 0 : opts.ns;
648
+ var nsArray = Array.isArray(ns) ? ns : null;
649
+ if (nsArray && nsArray.length > 1 && nsArray.slice(1).includes(path[0])) {
650
+ return "".concat(path[0]).concat(nsSeparator).concat(path.slice(1).join(keySeparator));
651
+ }
652
+ }
653
+ return path.join(keySeparator);
636
654
  }
637
- var checkedLoadedFor = {};
638
655
  var shouldHandleAsObject = res => !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
639
656
  class Translator extends EventEmitter {
640
657
  constructor(services) {
@@ -646,6 +663,7 @@
646
663
  this.options.keySeparator = '.';
647
664
  }
648
665
  this.logger = baseLogger.create('translator');
666
+ this.checkedLoadedFor = {};
649
667
  }
650
668
  changeLanguage(lng) {
651
669
  if (lng) this.language = lng;
@@ -669,7 +687,7 @@
669
687
  if (nsSeparator === undefined) nsSeparator = ':';
670
688
  var keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
671
689
  var namespaces = opt.ns || this.options.defaultNS || [];
672
- var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
690
+ var wouldCheckForNsInKey = nsSeparator && key.includes(nsSeparator);
673
691
  var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
674
692
  if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
675
693
  var m = key.match(this.interpolator.nestingRegexp);
@@ -680,7 +698,7 @@
680
698
  };
681
699
  }
682
700
  var parts = key.split(nsSeparator);
683
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
701
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.includes(parts[0])) namespaces = parts.shift();
684
702
  key = parts.join(keySeparator);
685
703
  }
686
704
  return {
@@ -698,6 +716,7 @@
698
716
  if (keys == null) return '';
699
717
  if (typeof keys === 'function') keys = keysFromSelector(keys, _objectSpread2(_objectSpread2({}, this.options), opt));
700
718
  if (!Array.isArray(keys)) keys = [String(keys)];
719
+ keys = keys.map(k => typeof k === 'function' ? keysFromSelector(k, _objectSpread2(_objectSpread2({}, this.options), opt)) : String(k));
701
720
  var returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
702
721
  var keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
703
722
  var {
@@ -756,7 +775,7 @@
756
775
  }
757
776
  var handleAsObject = shouldHandleAsObject(resForObjHndl);
758
777
  var resType = Object.prototype.toString.apply(resForObjHndl);
759
- if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
778
+ if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
760
779
  if (!opt.returnObjects && !this.options.returnObjects) {
761
780
  if (!this.options.returnedObjectHandler) {
762
781
  this.logger.warn('accessing an object - but returnObjects options is not enabled!');
@@ -846,7 +865,7 @@
846
865
  if (this.options.saveMissingPlurals && needsPluralHandling) {
847
866
  lngs.forEach(language => {
848
867
  var suffixes = this.pluralResolver.getSuffixes(language, opt);
849
- if (needsZeroSuffixLookup && opt["defaultValue".concat(this.options.pluralSeparator, "zero")] && suffixes.indexOf("".concat(this.options.pluralSeparator, "zero")) < 0) {
868
+ if (needsZeroSuffixLookup && opt["defaultValue".concat(this.options.pluralSeparator, "zero")] && !suffixes.includes("".concat(this.options.pluralSeparator, "zero"))) {
850
869
  suffixes.push("".concat(this.options.pluralSeparator, "zero"));
851
870
  }
852
871
  suffixes.forEach(suffix => {
@@ -875,7 +894,7 @@
875
894
  }
876
895
  extendTranslation(res, key, opt, resolved, lastKey) {
877
896
  var _this$i18nFormat,
878
- _this = this;
897
+ _this2 = this;
879
898
  if ((_this$i18nFormat = this.i18nFormat) !== null && _this$i18nFormat !== void 0 && _this$i18nFormat.parse) {
880
899
  res = this.i18nFormat.parse(res, _objectSpread2(_objectSpread2({}, this.options.interpolation.defaultVariables), opt), opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
881
900
  resolved
@@ -905,10 +924,10 @@
905
924
  args[_key6] = arguments[_key6];
906
925
  }
907
926
  if ((lastKey === null || lastKey === void 0 ? void 0 : lastKey[0]) === args[0] && !opt.context) {
908
- _this.logger.warn("It seems you are nesting recursively key: ".concat(args[0], " in key: ").concat(key[0]));
927
+ _this2.logger.warn("It seems you are nesting recursively key: ".concat(args[0], " in key: ").concat(key[0]));
909
928
  return null;
910
929
  }
911
- return _this.translate(...args, key);
930
+ return _this2.translate(...args, key);
912
931
  }, opt);
913
932
  if (opt.interpolation) this.interpolator.reset();
914
933
  }
@@ -931,6 +950,7 @@
931
950
  var usedLng;
932
951
  var usedNS;
933
952
  if (isString(keys)) keys = [keys];
953
+ if (Array.isArray(keys)) keys = keys.map(k => typeof k === 'function' ? keysFromSelector(k, _objectSpread2(_objectSpread2({}, this.options), opt)) : k);
934
954
  keys.forEach(k => {
935
955
  if (this.isValidLookup(found)) return;
936
956
  var extracted = this.extractFromKey(k, opt);
@@ -946,8 +966,8 @@
946
966
  var _this$utils, _this$utils2;
947
967
  if (this.isValidLookup(found)) return;
948
968
  usedNS = ns;
949
- if (!checkedLoadedFor["".concat(codes[0], "-").concat(ns)] && (_this$utils = this.utils) !== null && _this$utils !== void 0 && _this$utils.hasLoadedNamespace && !((_this$utils2 = this.utils) !== null && _this$utils2 !== void 0 && _this$utils2.hasLoadedNamespace(usedNS))) {
950
- checkedLoadedFor["".concat(codes[0], "-").concat(ns)] = true;
969
+ if (!this.checkedLoadedFor["".concat(codes[0], "-").concat(ns)] && (_this$utils = this.utils) !== null && _this$utils !== void 0 && _this$utils.hasLoadedNamespace && !((_this$utils2 = this.utils) !== null && _this$utils2 !== void 0 && _this$utils2.hasLoadedNamespace(usedNS))) {
970
+ this.checkedLoadedFor["".concat(codes[0], "-").concat(ns)] = true;
951
971
  this.logger.warn("key \"".concat(usedKey, "\" for languages \"").concat(codes.join(', '), "\" won't get resolved as namespace \"").concat(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!!!');
952
972
  }
953
973
  codes.forEach(code => {
@@ -963,7 +983,7 @@
963
983
  var zeroSuffix = "".concat(this.options.pluralSeparator, "zero");
964
984
  var ordinalPrefix = "".concat(this.options.pluralSeparator, "ordinal").concat(this.options.pluralSeparator);
965
985
  if (needsPluralHandling) {
966
- if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
986
+ if (opt.ordinal && pluralSuffix.startsWith(ordinalPrefix)) {
967
987
  finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
968
988
  }
969
989
  finalKeys.push(key + pluralSuffix);
@@ -975,7 +995,7 @@
975
995
  var contextKey = "".concat(key).concat(this.options.contextSeparator || '_').concat(opt.context);
976
996
  finalKeys.push(contextKey);
977
997
  if (needsPluralHandling) {
978
- if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
998
+ if (opt.ordinal && pluralSuffix.startsWith(ordinalPrefix)) {
979
999
  finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
980
1000
  }
981
1001
  finalKeys.push(contextKey + pluralSuffix);
@@ -1034,7 +1054,7 @@
1034
1054
  static hasDefaultValue(options) {
1035
1055
  var prefix = 'defaultValue';
1036
1056
  for (var option in options) {
1037
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
1057
+ if (Object.prototype.hasOwnProperty.call(options, option) && option.startsWith(prefix) && undefined !== options[option]) {
1038
1058
  return true;
1039
1059
  }
1040
1060
  }
@@ -1049,7 +1069,7 @@
1049
1069
  }
1050
1070
  getScriptPartFromCode(code) {
1051
1071
  code = getCleanedCode(code);
1052
- if (!code || code.indexOf('-') < 0) return null;
1072
+ if (!code || !code.includes('-')) return null;
1053
1073
  var p = code.split('-');
1054
1074
  if (p.length === 2) return null;
1055
1075
  p.pop();
@@ -1058,12 +1078,12 @@
1058
1078
  }
1059
1079
  getLanguagePartFromCode(code) {
1060
1080
  code = getCleanedCode(code);
1061
- if (!code || code.indexOf('-') < 0) return code;
1081
+ if (!code || !code.includes('-')) return code;
1062
1082
  var p = code.split('-');
1063
1083
  return this.formatLanguageCode(p[0]);
1064
1084
  }
1065
1085
  formatLanguageCode(code) {
1066
- if (isString(code) && code.indexOf('-') > -1) {
1086
+ if (isString(code) && code.includes('-')) {
1067
1087
  var formattedCode;
1068
1088
  try {
1069
1089
  formattedCode = Intl.getCanonicalLocales(code)[0];
@@ -1083,7 +1103,7 @@
1083
1103
  if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
1084
1104
  code = this.getLanguagePartFromCode(code);
1085
1105
  }
1086
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
1106
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.includes(code);
1087
1107
  }
1088
1108
  getBestMatchFromCodes(codes) {
1089
1109
  if (!codes) return null;
@@ -1101,10 +1121,11 @@
1101
1121
  var lngOnly = this.getLanguagePartFromCode(code);
1102
1122
  if (this.isSupportedCode(lngOnly)) return found = lngOnly;
1103
1123
  found = this.options.supportedLngs.find(supportedLng => {
1104
- if (supportedLng === lngOnly) return supportedLng;
1105
- if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
1106
- if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng;
1107
- if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
1124
+ if (supportedLng === lngOnly) return true;
1125
+ if (!supportedLng.includes('-') && !lngOnly.includes('-')) return false;
1126
+ if (supportedLng.includes('-') && !lngOnly.includes('-') && supportedLng.slice(0, supportedLng.indexOf('-')) === lngOnly) return true;
1127
+ if (supportedLng.startsWith(lngOnly) && lngOnly.length > 1) return true;
1128
+ return false;
1108
1129
  });
1109
1130
  });
1110
1131
  }
@@ -1135,7 +1156,7 @@
1135
1156
  this.logger.warn("rejecting language code not found in supportedLngs: ".concat(c));
1136
1157
  }
1137
1158
  };
1138
- if (isString(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
1159
+ if (isString(code) && (code.includes('-') || code.includes('_'))) {
1139
1160
  if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
1140
1161
  if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
1141
1162
  if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
@@ -1143,7 +1164,7 @@
1143
1164
  addCode(this.formatLanguageCode(code));
1144
1165
  }
1145
1166
  fallbackCodes.forEach(fc => {
1146
- if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
1167
+ if (!codes.includes(fc)) addCode(this.formatLanguageCode(fc));
1147
1168
  });
1148
1169
  return codes;
1149
1170
  }
@@ -1310,7 +1331,7 @@
1310
1331
  var replaces;
1311
1332
  var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1312
1333
  var handleFormat = key => {
1313
- if (key.indexOf(this.formatSeparator) < 0) {
1334
+ if (!key.includes(this.formatSeparator)) {
1314
1335
  var path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
1315
1336
  return this.alwaysFormat ? this.format(path, undefined, lng, _objectSpread2(_objectSpread2(_objectSpread2({}, options), data), {}, {
1316
1337
  interpolationkey: key
@@ -1378,7 +1399,7 @@
1378
1399
  var handleHasOptions = (key, inheritedOptions) => {
1379
1400
  var _matchedSingleQuotes$, _matchedDoubleQuotes$;
1380
1401
  var sep = this.nestingOptionsSeparator;
1381
- if (key.indexOf(sep) < 0) return key;
1402
+ if (!key.includes(sep)) return key;
1382
1403
  var c = key.split(new RegExp("".concat(regexEscape(sep), "[ ]*{")));
1383
1404
  var optionsString = "{".concat(c[1]);
1384
1405
  key = c[0];
@@ -1395,7 +1416,7 @@
1395
1416
  this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
1396
1417
  return "".concat(key).concat(sep).concat(optionsString);
1397
1418
  }
1398
- if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
1419
+ if (clonedOptions.defaultValue && clonedOptions.defaultValue.includes(this.prefix)) delete clonedOptions.defaultValue;
1399
1420
  return key;
1400
1421
  };
1401
1422
  while (match = this.nestingRegexp.exec(str)) {
@@ -1430,13 +1451,13 @@
1430
1451
  var parseFormatStr = formatStr => {
1431
1452
  var formatName = formatStr.toLowerCase().trim();
1432
1453
  var formatOptions = {};
1433
- if (formatStr.indexOf('(') > -1) {
1454
+ if (formatStr.includes('(')) {
1434
1455
  var p = formatStr.split('(');
1435
1456
  formatName = p[0].toLowerCase().trim();
1436
- var optStr = p[1].substring(0, p[1].length - 1);
1437
- if (formatName === 'currency' && optStr.indexOf(':') < 0) {
1457
+ var optStr = p[1].slice(0, -1);
1458
+ if (formatName === 'currency' && !optStr.includes(':')) {
1438
1459
  if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1439
- } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
1460
+ } else if (formatName === 'relativetime' && !optStr.includes(':')) {
1440
1461
  if (!formatOptions.range) formatOptions.range = optStr.trim();
1441
1462
  } else {
1442
1463
  var opts = optStr.split(';');
@@ -1523,9 +1544,11 @@
1523
1544
  }
1524
1545
  format(value, format, lng) {
1525
1546
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1547
+ if (!format) return value;
1548
+ if (value == null) return value;
1526
1549
  var formats = format.split(this.formatSeparator);
1527
- if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
1528
- var lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
1550
+ if (formats.length > 1 && formats[0].indexOf('(') > 1 && !formats[0].includes(')') && formats.find(f => f.includes(')'))) {
1551
+ var lastIndex = formats.findIndex(f => f.includes(')'));
1529
1552
  formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
1530
1553
  }
1531
1554
  var result = formats.reduce((mem, f) => {
@@ -1680,7 +1703,7 @@
1680
1703
  }
1681
1704
  if (err && data && tried < this.maxRetries) {
1682
1705
  setTimeout(() => {
1683
- this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
1706
+ this.read(lng, ns, fcName, tried + 1, wait * 2, callback);
1684
1707
  }, wait);
1685
1708
  return;
1686
1709
  }
@@ -1788,7 +1811,6 @@
1788
1811
  nonExplicitSupportedLngs: false,
1789
1812
  load: 'all',
1790
1813
  preload: false,
1791
- simplifyPluralSuffix: true,
1792
1814
  keySeparator: '.',
1793
1815
  nsSeparator: ':',
1794
1816
  pluralSeparator: '_',
@@ -1825,7 +1847,6 @@
1825
1847
  },
1826
1848
  interpolation: {
1827
1849
  escapeValue: true,
1828
- format: value => value,
1829
1850
  prefix: '{{',
1830
1851
  suffix: '}}',
1831
1852
  formatSeparator: ',',
@@ -1839,14 +1860,12 @@
1839
1860
  cacheInBuiltFormats: true
1840
1861
  });
1841
1862
  var transformOptions = options => {
1842
- var _options$supportedLng, _options$supportedLng2;
1843
1863
  if (isString(options.ns)) options.ns = [options.ns];
1844
1864
  if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1845
1865
  if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1846
- if (((_options$supportedLng = options.supportedLngs) === null || _options$supportedLng === void 0 || (_options$supportedLng2 = _options$supportedLng.indexOf) === null || _options$supportedLng2 === void 0 ? void 0 : _options$supportedLng2.call(_options$supportedLng, 'cimode')) < 0) {
1866
+ if (options.supportedLngs && !options.supportedLngs.includes('cimode')) {
1847
1867
  options.supportedLngs = options.supportedLngs.concat(['cimode']);
1848
1868
  }
1849
- if (typeof options.initImmediate === 'boolean') options.initAsync = options.initImmediate;
1850
1869
  return options;
1851
1870
  };
1852
1871
  var noop = () => {};
@@ -1858,27 +1877,6 @@
1858
1877
  }
1859
1878
  });
1860
1879
  };
1861
- var SUPPORT_NOTICE_KEY = '__i18next_supportNoticeShown';
1862
- var getSupportNoticeShown = () => typeof globalThis !== 'undefined' && !!globalThis[SUPPORT_NOTICE_KEY];
1863
- var setSupportNoticeShown = () => {
1864
- if (typeof globalThis !== 'undefined') globalThis[SUPPORT_NOTICE_KEY] = true;
1865
- };
1866
- var usesLocize = inst => {
1867
- var _inst$modules, _inst$modules2, _inst$options, _inst$options2, _inst$options3;
1868
- if ((inst === null || inst === void 0 || (_inst$modules = inst.modules) === null || _inst$modules === void 0 || (_inst$modules = _inst$modules.backend) === null || _inst$modules === void 0 || (_inst$modules = _inst$modules.name) === null || _inst$modules === void 0 ? void 0 : _inst$modules.indexOf('Locize')) > 0) return true;
1869
- if ((inst === null || inst === void 0 || (_inst$modules2 = inst.modules) === null || _inst$modules2 === void 0 || (_inst$modules2 = _inst$modules2.backend) === null || _inst$modules2 === void 0 || (_inst$modules2 = _inst$modules2.constructor) === null || _inst$modules2 === void 0 || (_inst$modules2 = _inst$modules2.name) === null || _inst$modules2 === void 0 ? void 0 : _inst$modules2.indexOf('Locize')) > 0) return true;
1870
- if (inst !== null && inst !== void 0 && (_inst$options = inst.options) !== null && _inst$options !== void 0 && (_inst$options = _inst$options.backend) !== null && _inst$options !== void 0 && _inst$options.backends) {
1871
- if (inst.options.backend.backends.some(b => {
1872
- var _b$name, _b$constructor;
1873
- return (b === null || b === void 0 || (_b$name = b.name) === null || _b$name === void 0 ? void 0 : _b$name.indexOf('Locize')) > 0 || (b === null || b === void 0 || (_b$constructor = b.constructor) === null || _b$constructor === void 0 || (_b$constructor = _b$constructor.name) === null || _b$constructor === void 0 ? void 0 : _b$constructor.indexOf('Locize')) > 0;
1874
- })) return true;
1875
- }
1876
- if (inst !== null && inst !== void 0 && (_inst$options2 = inst.options) !== null && _inst$options2 !== void 0 && (_inst$options2 = _inst$options2.backend) !== null && _inst$options2 !== void 0 && _inst$options2.projectId) return true;
1877
- if (inst !== null && inst !== void 0 && (_inst$options3 = inst.options) !== null && _inst$options3 !== void 0 && (_inst$options3 = _inst$options3.backend) !== null && _inst$options3 !== void 0 && _inst$options3.backendOptions) {
1878
- if (inst.options.backend.backendOptions.some(b => b === null || b === void 0 ? void 0 : b.projectId)) return true;
1879
- }
1880
- return false;
1881
- };
1882
1880
  class I18n extends EventEmitter {
1883
1881
  constructor() {
1884
1882
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -1902,7 +1900,7 @@
1902
1900
  }
1903
1901
  }
1904
1902
  init() {
1905
- var _this2 = this;
1903
+ var _this3 = this;
1906
1904
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1907
1905
  var callback = arguments.length > 1 ? arguments[1] : undefined;
1908
1906
  this.isInitializing = true;
@@ -1913,7 +1911,7 @@
1913
1911
  if (options.defaultNS == null && options.ns) {
1914
1912
  if (isString(options.ns)) {
1915
1913
  options.defaultNS = options.ns;
1916
- } else if (options.ns.indexOf('translation') < 0) {
1914
+ } else if (!options.ns.includes('translation')) {
1917
1915
  options.defaultNS = options.ns[0];
1918
1916
  }
1919
1917
  }
@@ -1929,10 +1927,6 @@
1929
1927
  if (typeof this.options.overloadTranslationOptionHandler !== 'function') {
1930
1928
  this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
1931
1929
  }
1932
- if (this.options.showSupportNotice !== false && !usesLocize(this) && !getSupportNoticeShown()) {
1933
- if (typeof console !== 'undefined' && typeof console.info !== 'undefined') console.info('🌐 i18next is maintained with support from Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙');
1934
- setSupportNoticeShown();
1935
- }
1936
1930
  var createClassOnDemand = ClassOrObject => {
1937
1931
  if (!ClassOrObject) return null;
1938
1932
  if (typeof ClassOrObject === 'function') return new ClassOrObject();
@@ -1957,14 +1951,9 @@
1957
1951
  s.resourceStore = this.store;
1958
1952
  s.languageUtils = lu;
1959
1953
  s.pluralResolver = new PluralResolver(lu, {
1960
- prepend: this.options.pluralSeparator,
1961
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1954
+ prepend: this.options.pluralSeparator
1962
1955
  });
1963
- var usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
1964
- if (usingLegacyFormatFunction) {
1965
- this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting");
1966
- }
1967
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1956
+ if (formatter) {
1968
1957
  s.formatter = createClassOnDemand(formatter);
1969
1958
  if (s.formatter.init) s.formatter.init(s, this.options);
1970
1959
  this.options.interpolation.format = s.formatter.format.bind(s.formatter);
@@ -1978,7 +1967,7 @@
1978
1967
  for (var _len7 = arguments.length, args = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
1979
1968
  args[_key7 - 1] = arguments[_key7];
1980
1969
  }
1981
- _this2.emit(event, ...args);
1970
+ _this3.emit(event, ...args);
1982
1971
  });
1983
1972
  if (this.modules.languageDetector) {
1984
1973
  s.languageDetector = createClassOnDemand(this.modules.languageDetector);
@@ -1993,7 +1982,7 @@
1993
1982
  for (var _len8 = arguments.length, args = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
1994
1983
  args[_key8 - 1] = arguments[_key8];
1995
1984
  }
1996
- _this2.emit(event, ...args);
1985
+ _this3.emit(event, ...args);
1997
1986
  });
1998
1987
  this.modules.external.forEach(m => {
1999
1988
  if (m.init) m.init(this);
@@ -2011,14 +2000,14 @@
2011
2000
  var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
2012
2001
  storeApi.forEach(fcName => {
2013
2002
  this[fcName] = function () {
2014
- return _this2.store[fcName](...arguments);
2003
+ return _this3.store[fcName](...arguments);
2015
2004
  };
2016
2005
  });
2017
2006
  var storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
2018
2007
  storeApiChained.forEach(fcName => {
2019
2008
  this[fcName] = function () {
2020
- _this2.store[fcName](...arguments);
2021
- return _this2;
2009
+ _this3.store[fcName](...arguments);
2010
+ return _this3;
2022
2011
  };
2023
2012
  });
2024
2013
  var deferred = defer();
@@ -2057,7 +2046,7 @@
2057
2046
  var lngs = this.services.languageUtils.toResolveHierarchy(lng);
2058
2047
  lngs.forEach(l => {
2059
2048
  if (l === 'cimode') return;
2060
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
2049
+ if (!toLoad.includes(l)) toLoad.push(l);
2061
2050
  });
2062
2051
  };
2063
2052
  if (!usedLng) {
@@ -2122,22 +2111,22 @@
2122
2111
  }
2123
2112
  setResolvedLanguage(l) {
2124
2113
  if (!l || !this.languages) return;
2125
- if (['cimode', 'dev'].indexOf(l) > -1) return;
2114
+ if (['cimode', 'dev'].includes(l)) return;
2126
2115
  for (var li = 0; li < this.languages.length; li++) {
2127
2116
  var lngInLngs = this.languages[li];
2128
- if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
2117
+ if (['cimode', 'dev'].includes(lngInLngs)) continue;
2129
2118
  if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
2130
2119
  this.resolvedLanguage = lngInLngs;
2131
2120
  break;
2132
2121
  }
2133
2122
  }
2134
- if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
2123
+ if (!this.resolvedLanguage && !this.languages.includes(l) && this.store.hasLanguageSomeTranslations(l)) {
2135
2124
  this.resolvedLanguage = l;
2136
2125
  this.languages.unshift(l);
2137
2126
  }
2138
2127
  }
2139
2128
  changeLanguage(lng, callback) {
2140
- var _this3 = this;
2129
+ var _this4 = this;
2141
2130
  this.isLanguageChangingTo = lng;
2142
2131
  var deferred = defer();
2143
2132
  this.emit('languageChanging', lng);
@@ -2160,10 +2149,10 @@
2160
2149
  this.isLanguageChangingTo = undefined;
2161
2150
  }
2162
2151
  deferred.resolve(function () {
2163
- return _this3.t(...arguments);
2152
+ return _this4.t(...arguments);
2164
2153
  });
2165
2154
  if (callback) callback(err, function () {
2166
- return _this3.t(...arguments);
2155
+ return _this4.t(...arguments);
2167
2156
  });
2168
2157
  };
2169
2158
  var setLng = lngs => {
@@ -2196,14 +2185,14 @@
2196
2185
  return deferred;
2197
2186
  }
2198
2187
  getFixedT(lng, ns, keyPrefix) {
2199
- var _this4 = this;
2188
+ var _this5 = this;
2200
2189
  var _fixedT = function fixedT(key, opts) {
2201
2190
  var o;
2202
2191
  if (typeof opts !== 'object') {
2203
2192
  for (var _len9 = arguments.length, rest = new Array(_len9 > 2 ? _len9 - 2 : 0), _key9 = 2; _key9 < _len9; _key9++) {
2204
2193
  rest[_key9 - 2] = arguments[_key9];
2205
2194
  }
2206
- o = _this4.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2195
+ o = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2207
2196
  } else {
2208
2197
  o = _objectSpread2({}, opts);
2209
2198
  }
@@ -2211,18 +2200,20 @@
2211
2200
  o.lngs = o.lngs || _fixedT.lngs;
2212
2201
  o.ns = o.ns || _fixedT.ns;
2213
2202
  if (o.keyPrefix !== '') o.keyPrefix = o.keyPrefix || keyPrefix || _fixedT.keyPrefix;
2214
- var keySeparator = _this4.options.keySeparator || '.';
2203
+ var selectorOpts = _objectSpread2(_objectSpread2({}, _this5.options), o);
2204
+ if (typeof o.keyPrefix === 'function') o.keyPrefix = keysFromSelector(o.keyPrefix, selectorOpts);
2205
+ var keySeparator = _this5.options.keySeparator || '.';
2215
2206
  var resultKey;
2216
2207
  if (o.keyPrefix && Array.isArray(key)) {
2217
2208
  resultKey = key.map(k => {
2218
- if (typeof k === 'function') k = keysFromSelector(k, _objectSpread2(_objectSpread2({}, _this4.options), opts));
2209
+ if (typeof k === 'function') k = keysFromSelector(k, selectorOpts);
2219
2210
  return "".concat(o.keyPrefix).concat(keySeparator).concat(k);
2220
2211
  });
2221
2212
  } else {
2222
- if (typeof key === 'function') key = keysFromSelector(key, _objectSpread2(_objectSpread2({}, _this4.options), opts));
2213
+ if (typeof key === 'function') key = keysFromSelector(key, selectorOpts);
2223
2214
  resultKey = o.keyPrefix ? "".concat(o.keyPrefix).concat(keySeparator).concat(key) : key;
2224
2215
  }
2225
- return _this4.t(resultKey, o);
2216
+ return _this5.t(resultKey, o);
2226
2217
  };
2227
2218
  if (isString(lng)) {
2228
2219
  _fixedT.lng = lng;
@@ -2285,7 +2276,7 @@
2285
2276
  }
2286
2277
  if (isString(ns)) ns = [ns];
2287
2278
  ns.forEach(n => {
2288
- if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2279
+ if (!this.options.ns.includes(n)) this.options.ns.push(n);
2289
2280
  });
2290
2281
  this.loadResources(err => {
2291
2282
  deferred.resolve();
@@ -2297,7 +2288,7 @@
2297
2288
  var deferred = defer();
2298
2289
  if (isString(lngs)) lngs = [lngs];
2299
2290
  var preloaded = this.options.preload || [];
2300
- var newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
2291
+ var newLngs = lngs.filter(lng => !preloaded.includes(lng) && this.services.languageUtils.isSupportedCode(lng));
2301
2292
  if (!newLngs.length) {
2302
2293
  if (callback) callback();
2303
2294
  return Promise.resolve();
@@ -2323,7 +2314,7 @@
2323
2314
  var 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'];
2324
2315
  var languageUtils = ((_this$services3 = this.services) === null || _this$services3 === void 0 ? void 0 : _this$services3.languageUtils) || new LanguageUtil(get());
2325
2316
  if (lng.toLowerCase().indexOf('-latn') > 1) return 'ltr';
2326
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2317
+ return rtlLngs.includes(languageUtils.getLanguagePartFromCode(lng)) || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2327
2318
  }
2328
2319
  static createInstance() {
2329
2320
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -2433,6 +2424,13 @@
2433
2424
  }
2434
2425
  return Promise.resolve(maybePromise);
2435
2426
  }
2427
+ var interpolationRegexp = /\{\{(.+?)\}\}/g;
2428
+ function interpolate(str, data) {
2429
+ return str.replace(interpolationRegexp, function (match, key) {
2430
+ var value = data[key.trim()];
2431
+ return value != null ? value : match;
2432
+ });
2433
+ }
2436
2434
 
2437
2435
  function ownKeys$1(e, r) {
2438
2436
  var t = Object.keys(e);
@@ -2781,7 +2779,7 @@
2781
2779
  loadPath = makePromise(loadPath);
2782
2780
  loadPath.then(function (resolvedLoadPath) {
2783
2781
  if (!resolvedLoadPath) return callback(null, {});
2784
- var url = _this2.services.interpolator.interpolate(resolvedLoadPath, {
2782
+ var url = interpolate(resolvedLoadPath, {
2785
2783
  lng: languages.join('+'),
2786
2784
  ns: namespaces.join('+')
2787
2785
  });
@@ -2837,7 +2835,7 @@
2837
2835
  if (typeof _this4.options.addPath === 'function') {
2838
2836
  addPath = _this4.options.addPath(lng, namespace);
2839
2837
  }
2840
- var url = _this4.services.interpolator.interpolate(addPath, {
2838
+ var url = interpolate(addPath, {
2841
2839
  lng: lng,
2842
2840
  ns: namespace
2843
2841
  });
@@ -7299,7 +7297,7 @@
7299
7297
  if (object == null) return '';
7300
7298
  return '' + object;
7301
7299
  }
7302
- function interpolate(str, data, lng) {
7300
+ function interpolate$1(str, data, lng) {
7303
7301
  var match, value;
7304
7302
  function regexSafe(val) {
7305
7303
  return val.replace(/\$/g, '$$$$');
@@ -7795,7 +7793,7 @@
7795
7793
  callback(new Error(isMissing));
7796
7794
  return deferred;
7797
7795
  }
7798
- var url = interpolate(this.options.getLanguagesPath, {
7796
+ var url = interpolate$1(this.options.getLanguagesPath, {
7799
7797
  projectId: this.options.projectId
7800
7798
  });
7801
7799
  if (!this.isProjectNotExisting && this.storage.isProjectNotExisting(this.options.projectId)) {
@@ -7815,7 +7813,7 @@
7815
7813
  _this3.isProjectNotExistingErrorMessage = errMsg;
7816
7814
  var cdnTypeAlt = _this3.options.cdnType === 'standard' ? 'pro' : 'standard';
7817
7815
  var otherEndpointApiPaths = getApiPaths(cdnTypeAlt);
7818
- var urlAlt = interpolate(otherEndpointApiPaths.getLanguagesPath, {
7816
+ var urlAlt = interpolate$1(otherEndpointApiPaths.getLanguagesPath, {
7819
7817
  projectId: _this3.options.projectId
7820
7818
  });
7821
7819
  _this3.loadUrl({}, urlAlt, function (errAlt, retAlt, infoAlt) {
@@ -7950,7 +7948,7 @@
7950
7948
  if (this.options.private) {
7951
7949
  var isMissing = isMissingOption(this.options, ['projectId', 'version', 'apiKey']);
7952
7950
  if (isMissing) return callback(new Error(isMissing), false);
7953
- url = interpolate(this.options.privatePath, {
7951
+ url = interpolate$1(this.options.privatePath, {
7954
7952
  lng: language,
7955
7953
  ns: namespace,
7956
7954
  projectId: this.options.projectId,
@@ -7962,7 +7960,7 @@
7962
7960
  } else {
7963
7961
  var _isMissing = isMissingOption(this.options, ['projectId', 'version']);
7964
7962
  if (_isMissing) return callback(new Error(_isMissing), false);
7965
- url = interpolate(this.options.loadPath, {
7963
+ url = interpolate$1(this.options.loadPath, {
7966
7964
  lng: language,
7967
7965
  ns: namespace,
7968
7966
  projectId: this.options.projectId,
@@ -8127,13 +8125,13 @@
8127
8125
  }, {
8128
8126
  key: "writePage",
8129
8127
  value: function writePage(lng, namespace, missings, callback) {
8130
- var missingUrl = interpolate(this.options.addPath, {
8128
+ var missingUrl = interpolate$1(this.options.addPath, {
8131
8129
  lng: lng,
8132
8130
  ns: namespace,
8133
8131
  projectId: this.options.projectId,
8134
8132
  version: this.options.version
8135
8133
  });
8136
- var updatesUrl = interpolate(this.options.updatePath, {
8134
+ var updatesUrl = interpolate$1(this.options.updatePath, {
8137
8135
  lng: lng,
8138
8136
  ns: namespace,
8139
8137
  projectId: this.options.projectId,