@trackunit/i18n-library-translation 0.0.165 → 0.0.168
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.cjs.js +8 -16
- package/package.json +5 -4
package/index.cjs.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
4
|
var React = require('react');
|
|
7
5
|
var reactI18next = require('react-i18next');
|
|
@@ -11,10 +9,7 @@ var browserLanguageDetector = require('i18next-browser-languagedetector');
|
|
|
11
9
|
var resourcesToBackend = require('i18next-resources-to-backend');
|
|
12
10
|
var reactCoreHooks = require('@trackunit/react-core-hooks');
|
|
13
11
|
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
function _interopNamespace(e) {
|
|
17
|
-
if (e && e.__esModule) return e;
|
|
12
|
+
function _interopNamespaceDefault(e) {
|
|
18
13
|
var n = Object.create(null);
|
|
19
14
|
if (e) {
|
|
20
15
|
Object.keys(e).forEach(function (k) {
|
|
@@ -27,14 +22,11 @@ function _interopNamespace(e) {
|
|
|
27
22
|
}
|
|
28
23
|
});
|
|
29
24
|
}
|
|
30
|
-
n
|
|
25
|
+
n.default = e;
|
|
31
26
|
return Object.freeze(n);
|
|
32
27
|
}
|
|
33
28
|
|
|
34
|
-
var React__namespace = /*#__PURE__*/
|
|
35
|
-
var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
|
|
36
|
-
var browserLanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(browserLanguageDetector);
|
|
37
|
-
var resourcesToBackend__default = /*#__PURE__*/_interopDefaultLegacy(resourcesToBackend);
|
|
29
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
38
30
|
|
|
39
31
|
/**
|
|
40
32
|
* Minimal wrapper of i18ns Trans component - only exposing what is currently needed - while ensuring type safety on translation keys.
|
|
@@ -85,7 +77,7 @@ const initializeTranslationsForApp = () => {
|
|
|
85
77
|
const queryString = window.location.search;
|
|
86
78
|
const urlParams = new URLSearchParams(queryString);
|
|
87
79
|
const savedLanguage = localStorage.getItem(LANG_STORAGE_KEY);
|
|
88
|
-
const i18nextLanguage =
|
|
80
|
+
const i18nextLanguage = i18next.language;
|
|
89
81
|
const defaultLanguage = navigator.language;
|
|
90
82
|
const selectedLanguage = (_c = (_b = (_a = urlParams.get("lang")) !== null && _a !== void 0 ? _a : i18nextLanguage) !== null && _b !== void 0 ? _b : savedLanguage) !== null && _c !== void 0 ? _c : defaultLanguage;
|
|
91
83
|
// Collect default (English) translations for all namespaces
|
|
@@ -112,9 +104,9 @@ const initializeTranslationsForApp = () => {
|
|
|
112
104
|
compatibilityJSON: "v3",
|
|
113
105
|
};
|
|
114
106
|
if (!hasBeenInitialized) {
|
|
115
|
-
|
|
116
|
-
.use(
|
|
117
|
-
.use(
|
|
107
|
+
i18next
|
|
108
|
+
.use(browserLanguageDetector)
|
|
109
|
+
.use(resourcesToBackend((language, namespace, callback) => {
|
|
118
110
|
const resource = availableTranslations[namespace];
|
|
119
111
|
//@ts-ignore - suppressImplicitAnyIndexErrors
|
|
120
112
|
if (resource && resource.languages[language]) {
|
|
@@ -134,7 +126,7 @@ const initializeTranslationsForApp = () => {
|
|
|
134
126
|
.init(init);
|
|
135
127
|
}
|
|
136
128
|
else {
|
|
137
|
-
|
|
129
|
+
i18next.init(init);
|
|
138
130
|
}
|
|
139
131
|
hasBeenInitialized = true;
|
|
140
132
|
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/i18n-library-translation",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.168",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"react": "
|
|
10
|
+
"react": "18.3.1",
|
|
11
11
|
"react-i18next": "^12.2.2",
|
|
12
12
|
"jest-fetch-mock": "^3.0.3",
|
|
13
13
|
"@trackunit/iris-app-api": "*",
|
|
@@ -17,5 +17,6 @@
|
|
|
17
17
|
"@trackunit/react-core-hooks": "*"
|
|
18
18
|
},
|
|
19
19
|
"module": "./index.esm.js",
|
|
20
|
-
"main": "./index.cjs.js"
|
|
21
|
-
|
|
20
|
+
"main": "./index.cjs.js",
|
|
21
|
+
"types": "./index.esm.d.ts"
|
|
22
|
+
}
|