@trackunit/i18n-library-translation 1.3.173-alpha-f277ad3eb85.0 → 1.3.176
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 +3 -3
- package/index.esm.js +4 -4
- package/package.json +4 -4
package/index.cjs.js
CHANGED
|
@@ -122,12 +122,12 @@ const initializeTranslationsForApp = () => {
|
|
|
122
122
|
* @returns {[TransForLibs, i18n, boolean]} useTranslation with custom t function
|
|
123
123
|
*/
|
|
124
124
|
const useNamespaceTranslation = (namespace, options) => {
|
|
125
|
-
const
|
|
125
|
+
const errorhandler = reactCoreHooks.useErrorHandlerOrNull();
|
|
126
126
|
const customUseTranslation = reactI18next.useTranslation(namespace, options);
|
|
127
127
|
const [t, i18NextInstance] = reactI18next.useTranslation(namespace, options);
|
|
128
128
|
const customT = react.useCallback(function (key, arg2, arg3) {
|
|
129
129
|
if (key && !i18NextInstance.exists(key, { lng: "en", ns: namespace })) {
|
|
130
|
-
captureException(new Error(JSON.stringify({
|
|
130
|
+
errorhandler?.captureException(new Error(JSON.stringify({
|
|
131
131
|
info: "A Translation key could not be found!",
|
|
132
132
|
key,
|
|
133
133
|
namespace,
|
|
@@ -152,7 +152,7 @@ const useNamespaceTranslation = (namespace, options) => {
|
|
|
152
152
|
// Case: t(key)
|
|
153
153
|
return t(key);
|
|
154
154
|
}
|
|
155
|
-
}, [i18NextInstance, namespace,
|
|
155
|
+
}, [i18NextInstance, namespace, errorhandler, t]);
|
|
156
156
|
// Replace t function with customT
|
|
157
157
|
const updatedUseTranslation = react.useMemo(() => {
|
|
158
158
|
const result = [customT, customUseTranslation[1], customUseTranslation[2]];
|
package/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import { languageKeys } from '@trackunit/iris-app-api';
|
|
|
5
5
|
import i18next from 'i18next';
|
|
6
6
|
import browserLanguageDetector from 'i18next-browser-languagedetector';
|
|
7
7
|
import resourcesToBackend from 'i18next-resources-to-backend';
|
|
8
|
-
import {
|
|
8
|
+
import { useErrorHandlerOrNull } from '@trackunit/react-core-hooks';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Minimal wrapper of i18ns Trans component - only exposing what is currently needed - while ensuring type safety on translation keys.
|
|
@@ -120,12 +120,12 @@ const initializeTranslationsForApp = () => {
|
|
|
120
120
|
* @returns {[TransForLibs, i18n, boolean]} useTranslation with custom t function
|
|
121
121
|
*/
|
|
122
122
|
const useNamespaceTranslation = (namespace, options) => {
|
|
123
|
-
const
|
|
123
|
+
const errorhandler = useErrorHandlerOrNull();
|
|
124
124
|
const customUseTranslation = useTranslation(namespace, options);
|
|
125
125
|
const [t, i18NextInstance] = useTranslation(namespace, options);
|
|
126
126
|
const customT = useCallback(function (key, arg2, arg3) {
|
|
127
127
|
if (key && !i18NextInstance.exists(key, { lng: "en", ns: namespace })) {
|
|
128
|
-
captureException(new Error(JSON.stringify({
|
|
128
|
+
errorhandler?.captureException(new Error(JSON.stringify({
|
|
129
129
|
info: "A Translation key could not be found!",
|
|
130
130
|
key,
|
|
131
131
|
namespace,
|
|
@@ -150,7 +150,7 @@ const useNamespaceTranslation = (namespace, options) => {
|
|
|
150
150
|
// Case: t(key)
|
|
151
151
|
return t(key);
|
|
152
152
|
}
|
|
153
|
-
}, [i18NextInstance, namespace,
|
|
153
|
+
}, [i18NextInstance, namespace, errorhandler, t]);
|
|
154
154
|
// Replace t function with customT
|
|
155
155
|
const updatedUseTranslation = useMemo(() => {
|
|
156
156
|
const result = [customT, customUseTranslation[1], customUseTranslation[2]];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/i18n-library-translation",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.176",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"i18next": "25.1.2",
|
|
14
14
|
"i18next-browser-languagedetector": "8.1.0",
|
|
15
15
|
"i18next-resources-to-backend": "^1.2.1",
|
|
16
|
-
"@trackunit/iris-app-api": "1.3.
|
|
17
|
-
"@trackunit/react-core-hooks": "1.3.
|
|
18
|
-
"@trackunit/react-test-setup": "1.0.
|
|
16
|
+
"@trackunit/iris-app-api": "1.3.162",
|
|
17
|
+
"@trackunit/react-core-hooks": "1.3.169",
|
|
18
|
+
"@trackunit/react-test-setup": "1.0.44"
|
|
19
19
|
},
|
|
20
20
|
"module": "./index.esm.js",
|
|
21
21
|
"main": "./index.cjs.js",
|