@fkui/i18next-translate 5.40.0 → 5.42.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/dist/cjs/index.js CHANGED
@@ -882,7 +882,10 @@ class LanguageUtil {
882
882
  }
883
883
  formatLanguageCode(code) {
884
884
  if (isString$1(code) && code.indexOf('-') > -1) {
885
- let formattedCode = Intl.getCanonicalLocales(code)[0];
885
+ let formattedCode;
886
+ try {
887
+ formattedCode = Intl.getCanonicalLocales(code)[0];
888
+ } catch (e) {}
886
889
  if (formattedCode && this.options.lowerCaseLng) {
887
890
  formattedCode = formattedCode.toLowerCase();
888
891
  }
@@ -970,6 +973,12 @@ const suffixesOrder = {
970
973
  many: 4,
971
974
  other: 5
972
975
  };
976
+ const dummyRule = {
977
+ select: count => count === 1 ? 'one' : 'other',
978
+ resolvedOptions: () => ({
979
+ pluralCategories: ['one', 'other']
980
+ })
981
+ };
973
982
  class PluralResolver {
974
983
  constructor(languageUtils) {
975
984
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -1001,7 +1010,11 @@ class PluralResolver {
1001
1010
  type
1002
1011
  });
1003
1012
  } catch (err) {
1004
- if (!code.match(/-|_/)) return;
1013
+ if (!Intl) {
1014
+ this.logger.error('No Intl support, please use an Intl polyfill!');
1015
+ return dummyRule;
1016
+ }
1017
+ if (!code.match(/-|_/)) return dummyRule;
1005
1018
  const lngPart = this.languageUtils.getLanguagePartFromCode(code);
1006
1019
  rule = this.getRule(lngPart, options);
1007
1020
  }
@@ -1034,12 +1047,6 @@ class PluralResolver {
1034
1047
  this.logger.warn(`no plural rule found for: ${code}`);
1035
1048
  return this.getSuffix('dev', count, options);
1036
1049
  }
1037
- getSuffixRetroCompatible(rule, count) {
1038
- const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
1039
- rule.numbers[idx];
1040
- if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) ;
1041
- return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
1042
- }
1043
1050
  }
1044
1051
 
1045
1052
  const deepFindWithDefaults = function (data, defaultData, key) {