@trackunit/i18n-library-translation 0.0.11 → 0.0.14

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/index.js CHANGED
@@ -91,37 +91,27 @@ var FunctionPrototype$1 = Function.prototype;
91
91
  var call$c = FunctionPrototype$1.call;
92
92
  var uncurryThisWithBind = NATIVE_BIND$1 && FunctionPrototype$1.bind.bind(call$c, call$c);
93
93
 
94
- var functionUncurryThisRaw = function (fn) {
95
- return NATIVE_BIND$1 ? uncurryThisWithBind(fn) : function () {
94
+ var functionUncurryThis = NATIVE_BIND$1 ? uncurryThisWithBind : function (fn) {
95
+ return function () {
96
96
  return call$c.apply(fn, arguments);
97
97
  };
98
98
  };
99
99
 
100
- var uncurryThisRaw$1 = functionUncurryThisRaw;
100
+ var uncurryThis$e = functionUncurryThis;
101
101
 
102
- var toString$4 = uncurryThisRaw$1({}.toString);
103
- var stringSlice$2 = uncurryThisRaw$1(''.slice);
102
+ var toString$4 = uncurryThis$e({}.toString);
103
+ var stringSlice$2 = uncurryThis$e(''.slice);
104
104
 
105
105
  var classofRaw$2 = function (it) {
106
106
  return stringSlice$2(toString$4(it), 8, -1);
107
107
  };
108
108
 
109
- var classofRaw$1 = classofRaw$2;
110
- var uncurryThisRaw = functionUncurryThisRaw;
111
-
112
- var functionUncurryThis = function (fn) {
113
- // Nashorn bug:
114
- // https://github.com/zloirock/core-js/issues/1128
115
- // https://github.com/zloirock/core-js/issues/1130
116
- if (classofRaw$1(fn) === 'Function') return uncurryThisRaw(fn);
117
- };
118
-
119
- var uncurryThis$c = functionUncurryThis;
109
+ var uncurryThis$d = functionUncurryThis;
120
110
  var fails$d = fails$g;
121
111
  var classof$5 = classofRaw$2;
122
112
 
123
113
  var $Object$4 = Object;
124
- var split$1 = uncurryThis$c(''.split);
114
+ var split$1 = uncurryThis$d(''.split);
125
115
 
126
116
  // fallback for non-array-like ES3 and non-enumerable old V8 strings
127
117
  var indexedObject = fails$d(function () {
@@ -201,9 +191,9 @@ var getBuiltIn$4 = function (namespace, method) {
201
191
  return arguments.length < 2 ? aFunction(global$e[namespace]) : global$e[namespace] && global$e[namespace][method];
202
192
  };
203
193
 
204
- var uncurryThis$b = functionUncurryThis;
194
+ var uncurryThis$c = functionUncurryThis;
205
195
 
206
- var objectIsPrototypeOf = uncurryThis$b({}.isPrototypeOf);
196
+ var objectIsPrototypeOf = uncurryThis$c({}.isPrototypeOf);
207
197
 
208
198
  var getBuiltIn$3 = getBuiltIn$4;
209
199
 
@@ -351,10 +341,10 @@ var store$2 = sharedStore;
351
341
  (shared$4.exports = function (key, value) {
352
342
  return store$2[key] || (store$2[key] = value !== undefined ? value : {});
353
343
  })('versions', []).push({
354
- version: '3.25.5',
344
+ version: '3.26.1',
355
345
  mode: 'global',
356
346
  copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
357
- license: 'https://github.com/zloirock/core-js/blob/v3.25.5/LICENSE',
347
+ license: 'https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE',
358
348
  source: 'https://github.com/zloirock/core-js'
359
349
  });
360
350
 
@@ -368,10 +358,10 @@ var toObject$3 = function (argument) {
368
358
  return $Object$2(requireObjectCoercible$1(argument));
369
359
  };
370
360
 
371
- var uncurryThis$a = functionUncurryThis;
361
+ var uncurryThis$b = functionUncurryThis;
372
362
  var toObject$2 = toObject$3;
373
363
 
374
- var hasOwnProperty = uncurryThis$a({}.hasOwnProperty);
364
+ var hasOwnProperty = uncurryThis$b({}.hasOwnProperty);
375
365
 
376
366
  // `HasOwnProperty` abstract operation
377
367
  // https://tc39.es/ecma262/#sec-hasownproperty
@@ -380,11 +370,11 @@ var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
380
370
  return hasOwnProperty(toObject$2(it), key);
381
371
  };
382
372
 
383
- var uncurryThis$9 = functionUncurryThis;
373
+ var uncurryThis$a = functionUncurryThis;
384
374
 
385
375
  var id = 0;
386
376
  var postfix = Math.random();
387
- var toString$3 = uncurryThis$9(1.0.toString);
377
+ var toString$3 = uncurryThis$a(1.0.toString);
388
378
 
389
379
  var uid$2 = function (key) {
390
380
  return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$3(++id + postfix, 36);
@@ -598,11 +588,11 @@ var functionName = {
598
588
  CONFIGURABLE: CONFIGURABLE
599
589
  };
600
590
 
601
- var uncurryThis$8 = functionUncurryThis;
591
+ var uncurryThis$9 = functionUncurryThis;
602
592
  var isCallable$b = isCallable$h;
603
593
  var store$1 = sharedStore;
604
594
 
605
- var functionToString = uncurryThis$8(Function.toString);
595
+ var functionToString = uncurryThis$9(Function.toString);
606
596
 
607
597
  // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
608
598
  if (!isCallable$b(store$1.inspectSource)) {
@@ -867,13 +857,13 @@ var arrayIncludes = {
867
857
  indexOf: createMethod(false)
868
858
  };
869
859
 
870
- var uncurryThis$7 = functionUncurryThis;
860
+ var uncurryThis$8 = functionUncurryThis;
871
861
  var hasOwn$4 = hasOwnProperty_1;
872
862
  var toIndexedObject$2 = toIndexedObject$5;
873
863
  var indexOf$1 = arrayIncludes.indexOf;
874
864
  var hiddenKeys$2 = hiddenKeys$4;
875
865
 
876
- var push$1 = uncurryThis$7([].push);
866
+ var push$1 = uncurryThis$8([].push);
877
867
 
878
868
  var objectKeysInternal = function (object, names) {
879
869
  var O = toIndexedObject$2(object);
@@ -917,12 +907,12 @@ var objectGetOwnPropertySymbols = {};
917
907
  objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
918
908
 
919
909
  var getBuiltIn$1 = getBuiltIn$4;
920
- var uncurryThis$6 = functionUncurryThis;
910
+ var uncurryThis$7 = functionUncurryThis;
921
911
  var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
922
912
  var getOwnPropertySymbolsModule$1 = objectGetOwnPropertySymbols;
923
913
  var anObject$a = anObject$c;
924
914
 
925
- var concat$1 = uncurryThis$6([].concat);
915
+ var concat$1 = uncurryThis$7([].concat);
926
916
 
927
917
  // all object keys, includes non-enumerable and symbols
928
918
  var ownKeys$1 = getBuiltIn$1('Reflect', 'ownKeys') || function ownKeys(it) {
@@ -1037,7 +1027,7 @@ var objectKeys$2 = Object.keys || function keys(O) {
1037
1027
  };
1038
1028
 
1039
1029
  var DESCRIPTORS$3 = descriptors;
1040
- var uncurryThis$5 = functionUncurryThis;
1030
+ var uncurryThis$6 = functionUncurryThis;
1041
1031
  var call$8 = functionCall;
1042
1032
  var fails$7 = fails$g;
1043
1033
  var objectKeys$1 = objectKeys$2;
@@ -1050,7 +1040,7 @@ var IndexedObject = indexedObject;
1050
1040
  var $assign = Object.assign;
1051
1041
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
1052
1042
  var defineProperty$3 = Object.defineProperty;
1053
- var concat = uncurryThis$5([].concat);
1043
+ var concat = uncurryThis$6([].concat);
1054
1044
 
1055
1045
  // `Object.assign` method
1056
1046
  // https://tc39.es/ecma262/#sec-object.assign
@@ -1356,7 +1346,7 @@ var aPossiblePrototype$1 = function (argument) {
1356
1346
 
1357
1347
  /* eslint-disable no-proto -- safe */
1358
1348
 
1359
- var uncurryThis$4 = functionUncurryThis;
1349
+ var uncurryThis$5 = functionUncurryThis;
1360
1350
  var anObject$7 = anObject$c;
1361
1351
  var aPossiblePrototype = aPossiblePrototype$1;
1362
1352
 
@@ -1370,7 +1360,7 @@ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? functio
1370
1360
  var setter;
1371
1361
  try {
1372
1362
  // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1373
- setter = uncurryThis$4(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
1363
+ setter = uncurryThis$5(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
1374
1364
  setter(test, []);
1375
1365
  CORRECT_SETTER = test instanceof Array;
1376
1366
  } catch (error) { /* empty */ }
@@ -1636,7 +1626,6 @@ handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
1636
1626
  * @param { NamespaceTransProps } props the props for this namespace
1637
1627
  * @returns { React.ReactElement } The translated text - with safe interpolation of simple html (<strong><em><b><i> etc.)
1638
1628
  */
1639
-
1640
1629
  function NamespaceTrans(props) {
1641
1630
  // The as string | string[] is in order for TS to not choke on the size of the intersection
1642
1631
  // "Expression produces a union type that is too complex to represent.ts(2590)"
@@ -1661,14 +1650,14 @@ var toStringTagSupport = String(test) === '[object z]';
1661
1650
 
1662
1651
  var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1663
1652
  var isCallable$2 = isCallable$h;
1664
- var classofRaw = classofRaw$2;
1653
+ var classofRaw$1 = classofRaw$2;
1665
1654
  var wellKnownSymbol$5 = wellKnownSymbol$d;
1666
1655
 
1667
1656
  var TO_STRING_TAG = wellKnownSymbol$5('toStringTag');
1668
1657
  var $Object = Object;
1669
1658
 
1670
1659
  // ES3 wrong here
1671
- var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
1660
+ var CORRECT_ARGUMENTS = classofRaw$1(function () { return arguments; }()) == 'Arguments';
1672
1661
 
1673
1662
  // fallback for IE11 Script Access Denied error
1674
1663
  var tryGet = function (it, key) {
@@ -1678,15 +1667,15 @@ var tryGet = function (it, key) {
1678
1667
  };
1679
1668
 
1680
1669
  // getting tag from ES6+ `Object.prototype.toString`
1681
- var classof$4 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
1670
+ var classof$4 = TO_STRING_TAG_SUPPORT ? classofRaw$1 : function (it) {
1682
1671
  var O, tag, result;
1683
1672
  return it === undefined ? 'Undefined' : it === null ? 'Null'
1684
1673
  // @@toStringTag case
1685
1674
  : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
1686
1675
  // builtinTag case
1687
- : CORRECT_ARGUMENTS ? classofRaw(O)
1676
+ : CORRECT_ARGUMENTS ? classofRaw$1(O)
1688
1677
  // ES3 arguments fallback
1689
- : (result = classofRaw(O)) == 'Object' && isCallable$2(O.callee) ? 'Arguments' : result;
1678
+ : (result = classofRaw$1(O)) == 'Object' && isCallable$2(O.callee) ? 'Arguments' : result;
1690
1679
  };
1691
1680
 
1692
1681
  var classof$3 = classof$4;
@@ -1773,7 +1762,7 @@ var regexpUnsupportedNcg = fails$2(function () {
1773
1762
  /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
1774
1763
  /* eslint-disable regexp/no-useless-quantifier -- testing */
1775
1764
  var call$6 = functionCall;
1776
- var uncurryThis$3 = functionUncurryThis;
1765
+ var uncurryThis$4 = functionUncurryThis;
1777
1766
  var toString$1 = toString$2;
1778
1767
  var regexpFlags = regexpFlags$1;
1779
1768
  var stickyHelpers = regexpStickyHelpers;
@@ -1786,10 +1775,10 @@ var UNSUPPORTED_NCG = regexpUnsupportedNcg;
1786
1775
  var nativeReplace = shared('native-string-replace', String.prototype.replace);
1787
1776
  var nativeExec = RegExp.prototype.exec;
1788
1777
  var patchedExec = nativeExec;
1789
- var charAt$1 = uncurryThis$3(''.charAt);
1790
- var indexOf = uncurryThis$3(''.indexOf);
1791
- var replace$1 = uncurryThis$3(''.replace);
1792
- var stringSlice$1 = uncurryThis$3(''.slice);
1778
+ var charAt$1 = uncurryThis$4(''.charAt);
1779
+ var indexOf = uncurryThis$4(''.indexOf);
1780
+ var replace$1 = uncurryThis$4(''.replace);
1781
+ var stringSlice$1 = uncurryThis$4(''.slice);
1793
1782
 
1794
1783
  var UPDATES_LAST_INDEX_WRONG = (function () {
1795
1784
  var re1 = /a/;
@@ -1896,9 +1885,19 @@ $$2({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {
1896
1885
  exec: exec
1897
1886
  });
1898
1887
 
1888
+ var classofRaw = classofRaw$2;
1889
+ var uncurryThis$3 = functionUncurryThis;
1890
+
1891
+ var functionUncurryThisClause = function (fn) {
1892
+ // Nashorn bug:
1893
+ // https://github.com/zloirock/core-js/issues/1128
1894
+ // https://github.com/zloirock/core-js/issues/1130
1895
+ if (classofRaw(fn) === 'Function') return uncurryThis$3(fn);
1896
+ };
1897
+
1899
1898
  // TODO: Remove from `core-js@4` since it's moved to entry points
1900
1899
 
1901
- var uncurryThis$2 = functionUncurryThis;
1900
+ var uncurryThis$2 = functionUncurryThisClause;
1902
1901
  var defineBuiltIn$2 = defineBuiltIn$6;
1903
1902
  var regexpExec$1 = regexpExec$2;
1904
1903
  var fails$1 = fails$g;
@@ -2088,7 +2087,7 @@ var anInstance$1 = function (it, Prototype) {
2088
2087
  throw $TypeError$3('Incorrect invocation');
2089
2088
  };
2090
2089
 
2091
- var uncurryThis$1 = functionUncurryThis;
2090
+ var uncurryThis$1 = functionUncurryThisClause;
2092
2091
  var aCallable$1 = aCallable$3;
2093
2092
  var NATIVE_BIND = functionBindNative;
2094
2093
 
@@ -2718,10 +2717,8 @@ $({ target: 'Object', stat: true }, {
2718
2717
 
2719
2718
  const LANG_STORAGE_KEY = "i18nextLng";
2720
2719
  /** Holds all available TranslationResource by namespace */
2721
-
2722
2720
  const availableTranslations = {};
2723
2721
  /** Holds all available TranslationResource by namespace */
2724
-
2725
2722
  let hasBeenInitialized = false;
2726
2723
  /**
2727
2724
  * Use this function to register your translations before the i18next is initialized.
@@ -2734,12 +2731,10 @@ let hasBeenInitialized = false;
2734
2731
  *
2735
2732
  * @param resource { TranslationResource<string> } A full translation resource object with lazy loaded translation files, default translations and namespace
2736
2733
  */
2737
-
2738
2734
  const registerTranslations = resource => {
2739
2735
  // We only register each namespace once
2740
2736
  if (!availableTranslations[resource.ns]) {
2741
2737
  availableTranslations[resource.ns] = resource;
2742
-
2743
2738
  if (hasBeenInitialized) {
2744
2739
  // If we already initialized but new namespaces was added, we initialize again...
2745
2740
  initializeTranslationsForApp();
@@ -2753,16 +2748,14 @@ const registerTranslations = resource => {
2753
2748
  *
2754
2749
  * @param initialResource {TranslationResource}
2755
2750
  */
2756
-
2757
2751
  const initializeTranslationsForApp = () => {
2758
- var _a, _b, _c; // Get selected language from url or fallback to english
2759
-
2760
-
2752
+ var _a, _b, _c;
2753
+ // Get selected language from url or fallback to english
2761
2754
  const queryString = window.location.search;
2762
2755
  const urlParams = new URLSearchParams(queryString);
2763
2756
  const savedLanguage = localStorage.getItem(LANG_STORAGE_KEY);
2764
- const selectedLanguage = (_c = (_b = (_a = urlParams.get("lang")) !== null && _a !== void 0 ? _a : i18next.language) !== null && _b !== void 0 ? _b : savedLanguage) !== null && _c !== void 0 ? _c : "en"; // Collect default (English) translations for all namespaces
2765
-
2757
+ const selectedLanguage = (_c = (_b = (_a = urlParams.get("lang")) !== null && _a !== void 0 ? _a : i18next.language) !== null && _b !== void 0 ? _b : savedLanguage) !== null && _c !== void 0 ? _c : "en";
2758
+ // Collect default (English) translations for all namespaces
2766
2759
  const defaultTranslations = Object.fromEntries(Object.entries(availableTranslations).map(([namespace, value]) => [namespace, value.default]));
2767
2760
  const init = {
2768
2761
  debug: false,
@@ -2785,11 +2778,9 @@ const initializeTranslationsForApp = () => {
2785
2778
  },
2786
2779
  compatibilityJSON: "v3"
2787
2780
  };
2788
-
2789
2781
  if (!hasBeenInitialized) {
2790
2782
  i18next.use(browserLanguageDetector).use(resourcesToBackend((language, namespace, callback) => {
2791
2783
  const resource = availableTranslations[namespace];
2792
-
2793
2784
  if (resource && resource.languages[language]) {
2794
2785
  resource.languages[language]().then(resources => callback(null, resources)).catch(callback);
2795
2786
  } else {
@@ -2802,7 +2793,6 @@ const initializeTranslationsForApp = () => {
2802
2793
  } else {
2803
2794
  i18next.init(init);
2804
2795
  }
2805
-
2806
2796
  hasBeenInitialized = true;
2807
2797
  };
2808
2798
 
@@ -2814,7 +2804,6 @@ const initializeTranslationsForApp = () => {
2814
2804
  * @param options options to send to i18next
2815
2805
  * @returns useTranslation with custom t function
2816
2806
  */
2817
-
2818
2807
  const useNamespaceTranslation = (namespace, options) => {
2819
2808
  const customUseTranslation = useTranslation(namespace, options);
2820
2809
  const [t, i18NextInstance] = useTranslation(namespace, options);
@@ -2829,14 +2818,12 @@ const useNamespaceTranslation = (namespace, options) => {
2829
2818
  namespace
2830
2819
  })));
2831
2820
  }
2832
-
2833
2821
  if (arguments.length === 3 && typeof arg2 === "string") {
2834
2822
  return t(key, arg2, arg3);
2835
2823
  }
2836
-
2837
2824
  return t(key, arg2);
2838
- }, [i18NextInstance, namespace, t]); // Replace t function with customT
2839
-
2825
+ }, [i18NextInstance, namespace, t]);
2826
+ // Replace t function with customT
2840
2827
  const updatedUseTranslation = useMemo(() => {
2841
2828
  customUseTranslation[0] = customT;
2842
2829
  customUseTranslation.t = customT;
package/package.json CHANGED
@@ -2,19 +2,19 @@
2
2
  "name": "@trackunit/i18n-library-translation",
3
3
  "repository": "https://github.com/Trackunit/manager",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "0.0.11",
5
+ "version": "0.0.14",
6
6
  "module": "./index.js",
7
7
  "main": "./index.js",
8
8
  "type": "module",
9
- "types": "./index.d.ts",
9
+ "types": "./src/index.d.ts",
10
10
  "dependencies": {
11
11
  "react": "17.0.2",
12
- "react-i18next": "^11.18.6",
12
+ "react-i18next": "11.18.6",
13
13
  "i18next": "21.10.0",
14
14
  "i18next-browser-languagedetector": "6.1.8",
15
- "i18next-resources-to-backend": "^1.0.0",
16
- "@trackunit/iris-app-api": "0.0.64",
17
- "@sentry/browser": "^7.15.0"
15
+ "i18next-resources-to-backend": "1.1.0",
16
+ "@trackunit/iris-app-api": "0.0.67",
17
+ "@sentry/browser": "7.24.2"
18
18
  },
19
19
  "peerDependencies": {}
20
20
  }
File without changes
File without changes
File without changes