i18next 24.2.2 → 25.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/i18next.js CHANGED
@@ -488,13 +488,13 @@
488
488
  const resolved = this.resolve(key, options);
489
489
  return resolved?.res !== undefined;
490
490
  }
491
- extractFromKey(key, options) {
492
- let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
491
+ extractFromKey(key, opt) {
492
+ let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
493
493
  if (nsSeparator === undefined) nsSeparator = ':';
494
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
495
- let namespaces = options.ns || this.options.defaultNS || [];
494
+ const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
495
+ let namespaces = opt.ns || this.options.defaultNS || [];
496
496
  const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
497
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
497
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
498
498
  if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
499
499
  const m = key.match(this.interpolator.nestingRegexp);
500
500
  if (m && m.length > 0) {
@@ -512,28 +512,28 @@
512
512
  namespaces: isString(namespaces) ? [namespaces] : namespaces
513
513
  };
514
514
  }
515
- translate(keys, options, lastKey) {
516
- if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
517
- options = this.options.overloadTranslationOptionHandler(arguments);
515
+ translate(keys, opt, lastKey) {
516
+ if (typeof opt !== 'object' && this.options.overloadTranslationOptionHandler) {
517
+ opt = this.options.overloadTranslationOptionHandler(arguments);
518
518
  }
519
- if (typeof options === 'object') options = {
520
- ...options
519
+ if (typeof options === 'object') opt = {
520
+ ...opt
521
521
  };
522
- if (!options) options = {};
522
+ if (!opt) opt = {};
523
523
  if (keys == null) return '';
524
524
  if (!Array.isArray(keys)) keys = [String(keys)];
525
- const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
526
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
525
+ const returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
526
+ const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
527
527
  const {
528
528
  key,
529
529
  namespaces
530
- } = this.extractFromKey(keys[keys.length - 1], options);
530
+ } = this.extractFromKey(keys[keys.length - 1], opt);
531
531
  const namespace = namespaces[namespaces.length - 1];
532
- const lng = options.lng || this.language;
533
- const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
532
+ const lng = opt.lng || this.language;
533
+ const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
534
534
  if (lng?.toLowerCase() === 'cimode') {
535
535
  if (appendNamespaceToCIMode) {
536
- const nsSeparator = options.nsSeparator || this.options.nsSeparator;
536
+ const nsSeparator = opt.nsSeparator || this.options.nsSeparator;
537
537
  if (returnDetails) {
538
538
  return {
539
539
  res: `${namespace}${nsSeparator}${key}`,
@@ -541,7 +541,7 @@
541
541
  exactUsedKey: key,
542
542
  usedLng: lng,
543
543
  usedNS: namespace,
544
- usedParams: this.getUsedParamsDetails(options)
544
+ usedParams: this.getUsedParamsDetails(opt)
545
545
  };
546
546
  }
547
547
  return `${namespace}${nsSeparator}${key}`;
@@ -553,26 +553,26 @@
553
553
  exactUsedKey: key,
554
554
  usedLng: lng,
555
555
  usedNS: namespace,
556
- usedParams: this.getUsedParamsDetails(options)
556
+ usedParams: this.getUsedParamsDetails(opt)
557
557
  };
558
558
  }
559
559
  return key;
560
560
  }
561
- const resolved = this.resolve(keys, options);
561
+ const resolved = this.resolve(keys, opt);
562
562
  let res = resolved?.res;
563
563
  const resUsedKey = resolved?.usedKey || key;
564
564
  const resExactUsedKey = resolved?.exactUsedKey || key;
565
565
  const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
566
- const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
566
+ const joinArrays = opt.joinArrays !== undefined ? opt.joinArrays : this.options.joinArrays;
567
567
  const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
568
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
569
- const hasDefaultValue = Translator.hasDefaultValue(options);
570
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
571
- const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
568
+ const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
569
+ const hasDefaultValue = Translator.hasDefaultValue(opt);
570
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : '';
571
+ const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
572
572
  ordinal: false
573
573
  }) : '';
574
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
575
- const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
574
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
575
+ const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
576
576
  let resForObjHndl = res;
577
577
  if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
578
578
  resForObjHndl = defaultValue;
@@ -580,17 +580,17 @@
580
580
  const handleAsObject = shouldHandleAsObject(resForObjHndl);
581
581
  const resType = Object.prototype.toString.apply(resForObjHndl);
582
582
  if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
583
- if (!options.returnObjects && !this.options.returnObjects) {
583
+ if (!opt.returnObjects && !this.options.returnObjects) {
584
584
  if (!this.options.returnedObjectHandler) {
585
585
  this.logger.warn('accessing an object - but returnObjects options is not enabled!');
586
586
  }
587
587
  const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
588
- ...options,
588
+ ...opt,
589
589
  ns: namespaces
590
590
  }) : `key '${key} (${this.language})' returned an object instead of string.`;
591
591
  if (returnDetails) {
592
592
  resolved.res = r;
593
- resolved.usedParams = this.getUsedParamsDetails(options);
593
+ resolved.usedParams = this.getUsedParamsDetails(opt);
594
594
  return resolved;
595
595
  }
596
596
  return r;
@@ -604,7 +604,7 @@
604
604
  const deepKey = `${newKeyToUse}${keySeparator}${m}`;
605
605
  if (hasDefaultValue && !res) {
606
606
  copy[m] = this.translate(deepKey, {
607
- ...options,
607
+ ...opt,
608
608
  defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : undefined,
609
609
  ...{
610
610
  joinArrays: false,
@@ -613,7 +613,7 @@
613
613
  });
614
614
  } else {
615
615
  copy[m] = this.translate(deepKey, {
616
- ...options,
616
+ ...opt,
617
617
  ...{
618
618
  joinArrays: false,
619
619
  ns: namespaces
@@ -627,7 +627,7 @@
627
627
  }
628
628
  } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
629
629
  res = res.join(joinArrays);
630
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
630
+ if (res) res = this.extendTranslation(res, keys, opt, lastKey);
631
631
  } else {
632
632
  let usedDefault = false;
633
633
  let usedKey = false;
@@ -639,47 +639,47 @@
639
639
  usedKey = true;
640
640
  res = key;
641
641
  }
642
- const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
642
+ const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
643
643
  const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
644
644
  const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
645
645
  if (usedKey || usedDefault || updateMissing) {
646
646
  this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
647
647
  if (keySeparator) {
648
648
  const fk = this.resolve(key, {
649
- ...options,
649
+ ...opt,
650
650
  keySeparator: false
651
651
  });
652
652
  if (fk && fk.res) this.logger.warn('Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.');
653
653
  }
654
654
  let lngs = [];
655
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
655
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
656
656
  if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
657
657
  for (let i = 0; i < fallbackLngs.length; i++) {
658
658
  lngs.push(fallbackLngs[i]);
659
659
  }
660
660
  } else if (this.options.saveMissingTo === 'all') {
661
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
661
+ lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
662
662
  } else {
663
- lngs.push(options.lng || this.language);
663
+ lngs.push(opt.lng || this.language);
664
664
  }
665
665
  const send = (l, k, specificDefaultValue) => {
666
666
  const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
667
667
  if (this.options.missingKeyHandler) {
668
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
668
+ this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
669
669
  } else if (this.backendConnector?.saveMissing) {
670
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
670
+ this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
671
671
  }
672
672
  this.emit('missingKey', l, namespace, k, res);
673
673
  };
674
674
  if (this.options.saveMissing) {
675
675
  if (this.options.saveMissingPlurals && needsPluralHandling) {
676
676
  lngs.forEach(language => {
677
- const suffixes = this.pluralResolver.getSuffixes(language, options);
678
- if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
677
+ const suffixes = this.pluralResolver.getSuffixes(language, opt);
678
+ if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
679
679
  suffixes.push(`${this.options.pluralSeparator}zero`);
680
680
  }
681
681
  suffixes.forEach(suffix => {
682
- send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
682
+ send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
683
683
  });
684
684
  });
685
685
  } else {
@@ -687,7 +687,7 @@
687
687
  }
688
688
  }
689
689
  }
690
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
690
+ res = this.extendTranslation(res, keys, opt, resolved, lastKey);
691
691
  if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
692
692
  if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
693
693
  res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
@@ -695,75 +695,75 @@
695
695
  }
696
696
  if (returnDetails) {
697
697
  resolved.res = res;
698
- resolved.usedParams = this.getUsedParamsDetails(options);
698
+ resolved.usedParams = this.getUsedParamsDetails(opt);
699
699
  return resolved;
700
700
  }
701
701
  return res;
702
702
  }
703
- extendTranslation(res, key, options, resolved, lastKey) {
703
+ extendTranslation(res, key, opt, resolved, lastKey) {
704
704
  var _this = this;
705
705
  if (this.i18nFormat?.parse) {
706
706
  res = this.i18nFormat.parse(res, {
707
707
  ...this.options.interpolation.defaultVariables,
708
- ...options
709
- }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
708
+ ...opt
709
+ }, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
710
710
  resolved
711
711
  });
712
- } else if (!options.skipInterpolation) {
713
- if (options.interpolation) this.interpolator.init({
714
- ...options,
712
+ } else if (!opt.skipInterpolation) {
713
+ if (opt.interpolation) this.interpolator.init({
714
+ ...opt,
715
715
  ...{
716
716
  interpolation: {
717
717
  ...this.options.interpolation,
718
- ...options.interpolation
718
+ ...opt.interpolation
719
719
  }
720
720
  }
721
721
  });
722
- const skipOnVariables = isString(res) && (options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
722
+ const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== undefined ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
723
723
  let nestBef;
724
724
  if (skipOnVariables) {
725
725
  const nb = res.match(this.interpolator.nestingRegexp);
726
726
  nestBef = nb && nb.length;
727
727
  }
728
- let data = options.replace && !isString(options.replace) ? options.replace : options;
728
+ let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
729
729
  if (this.options.interpolation.defaultVariables) data = {
730
730
  ...this.options.interpolation.defaultVariables,
731
731
  ...data
732
732
  };
733
- res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
733
+ res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
734
734
  if (skipOnVariables) {
735
735
  const na = res.match(this.interpolator.nestingRegexp);
736
736
  const nestAft = na && na.length;
737
- if (nestBef < nestAft) options.nest = false;
737
+ if (nestBef < nestAft) opt.nest = false;
738
738
  }
739
- if (!options.lng && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
740
- if (options.nest !== false) res = this.interpolator.nest(res, function () {
739
+ if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
740
+ if (opt.nest !== false) res = this.interpolator.nest(res, function () {
741
741
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
742
742
  args[_key] = arguments[_key];
743
743
  }
744
- if (lastKey?.[0] === args[0] && !options.context) {
744
+ if (lastKey?.[0] === args[0] && !opt.context) {
745
745
  _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
746
746
  return null;
747
747
  }
748
748
  return _this.translate(...args, key);
749
- }, options);
750
- if (options.interpolation) this.interpolator.reset();
749
+ }, opt);
750
+ if (opt.interpolation) this.interpolator.reset();
751
751
  }
752
- const postProcess = options.postProcess || this.options.postProcess;
752
+ const postProcess = opt.postProcess || this.options.postProcess;
753
753
  const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
754
- if (res != null && postProcessorNames?.length && options.applyPostProcessor !== false) {
754
+ if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
755
755
  res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
756
756
  i18nResolved: {
757
757
  ...resolved,
758
- usedParams: this.getUsedParamsDetails(options)
758
+ usedParams: this.getUsedParamsDetails(opt)
759
759
  },
760
- ...options
761
- } : options, this);
760
+ ...opt
761
+ } : opt, this);
762
762
  }
763
763
  return res;
764
764
  }
765
765
  resolve(keys) {
766
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
766
+ let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
767
767
  let found;
768
768
  let usedKey;
769
769
  let exactUsedKey;
@@ -772,15 +772,15 @@
772
772
  if (isString(keys)) keys = [keys];
773
773
  keys.forEach(k => {
774
774
  if (this.isValidLookup(found)) return;
775
- const extracted = this.extractFromKey(k, options);
775
+ const extracted = this.extractFromKey(k, opt);
776
776
  const key = extracted.key;
777
777
  usedKey = key;
778
778
  let namespaces = extracted.namespaces;
779
779
  if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
780
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
781
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
782
- const needsContextHandling = options.context !== undefined && (isString(options.context) || typeof options.context === 'number') && options.context !== '';
783
- const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
780
+ const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
781
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
782
+ const needsContextHandling = opt.context !== undefined && (isString(opt.context) || typeof opt.context === 'number') && opt.context !== '';
783
+ const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
784
784
  namespaces.forEach(ns => {
785
785
  if (this.isValidLookup(found)) return;
786
786
  usedNS = ns;
@@ -793,15 +793,15 @@
793
793
  usedLng = code;
794
794
  const finalKeys = [key];
795
795
  if (this.i18nFormat?.addLookupKeys) {
796
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
796
+ this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
797
797
  } else {
798
798
  let pluralSuffix;
799
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
799
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
800
800
  const zeroSuffix = `${this.options.pluralSeparator}zero`;
801
801
  const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
802
802
  if (needsPluralHandling) {
803
803
  finalKeys.push(key + pluralSuffix);
804
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
804
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
805
805
  finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
806
806
  }
807
807
  if (needsZeroSuffixLookup) {
@@ -809,11 +809,11 @@
809
809
  }
810
810
  }
811
811
  if (needsContextHandling) {
812
- const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
812
+ const contextKey = `${key}${this.options.contextSeparator}${opt.context}`;
813
813
  finalKeys.push(contextKey);
814
814
  if (needsPluralHandling) {
815
815
  finalKeys.push(contextKey + pluralSuffix);
816
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
816
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
817
817
  finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
818
818
  }
819
819
  if (needsZeroSuffixLookup) {
@@ -826,7 +826,7 @@
826
826
  while (possibleKey = finalKeys.pop()) {
827
827
  if (!this.isValidLookup(found)) {
828
828
  exactUsedKey = possibleKey;
829
- found = this.getResource(code, ns, possibleKey, options);
829
+ found = this.getResource(code, ns, possibleKey, opt);
830
830
  }
831
831
  }
832
832
  });
@@ -938,6 +938,8 @@
938
938
  if (!found && this.options.supportedLngs) {
939
939
  codes.forEach(code => {
940
940
  if (found) return;
941
+ const lngScOnly = this.getScriptPartFromCode(code);
942
+ if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
941
943
  const lngOnly = this.getLanguagePartFromCode(code);
942
944
  if (this.isSupportedCode(lngOnly)) return found = lngOnly;
943
945
  found = this.options.supportedLngs.find(supportedLng => {
@@ -1984,11 +1986,13 @@
1984
1986
  };
1985
1987
  const done = (err, l) => {
1986
1988
  if (l) {
1987
- setLngProps(l);
1988
- this.translator.changeLanguage(l);
1989
- this.isLanguageChangingTo = undefined;
1990
- this.emit('languageChanged', l);
1991
- this.logger.log('languageChanged', l);
1989
+ if (this.isLanguageChangingTo === lng) {
1990
+ setLngProps(l);
1991
+ this.translator.changeLanguage(l);
1992
+ this.isLanguageChangingTo = undefined;
1993
+ this.emit('languageChanged', l);
1994
+ this.logger.log('languageChanged', l);
1995
+ }
1992
1996
  } else {
1993
1997
  this.isLanguageChangingTo = undefined;
1994
1998
  }
@@ -2001,7 +2005,7 @@
2001
2005
  };
2002
2006
  const setLng = lngs => {
2003
2007
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
2004
- const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
2008
+ const l = this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
2005
2009
  if (l) {
2006
2010
  if (!this.language) {
2007
2011
  setLngProps(l);
@@ -2029,29 +2033,29 @@
2029
2033
  getFixedT(lng, ns, keyPrefix) {
2030
2034
  var _this3 = this;
2031
2035
  const fixedT = function (key, opts) {
2032
- let options;
2036
+ let o;
2033
2037
  if (typeof opts !== 'object') {
2034
2038
  for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2035
2039
  rest[_key3 - 2] = arguments[_key3];
2036
2040
  }
2037
- options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2041
+ o = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2038
2042
  } else {
2039
- options = {
2043
+ o = {
2040
2044
  ...opts
2041
2045
  };
2042
2046
  }
2043
- options.lng = options.lng || fixedT.lng;
2044
- options.lngs = options.lngs || fixedT.lngs;
2045
- options.ns = options.ns || fixedT.ns;
2046
- if (options.keyPrefix !== '') options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2047
+ o.lng = o.lng || fixedT.lng;
2048
+ o.lngs = o.lngs || fixedT.lngs;
2049
+ o.ns = o.ns || fixedT.ns;
2050
+ if (o.keyPrefix !== '') o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
2047
2051
  const keySeparator = _this3.options.keySeparator || '.';
2048
2052
  let resultKey;
2049
- if (options.keyPrefix && Array.isArray(key)) {
2050
- resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
2053
+ if (o.keyPrefix && Array.isArray(key)) {
2054
+ resultKey = key.map(k => `${o.keyPrefix}${keySeparator}${k}`);
2051
2055
  } else {
2052
- resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
2056
+ resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
2053
2057
  }
2054
- return _this3.t(resultKey, options);
2058
+ return _this3.t(resultKey, o);
2055
2059
  };
2056
2060
  if (isString(lng)) {
2057
2061
  fixedT.lng = lng;