@trackunit/i18n-library-translation 1.3.119 → 1.3.120

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 CHANGED
@@ -81,7 +81,7 @@ const initializeTranslationsForApp = () => {
81
81
  transSupportBasicHtmlNodes: true,
82
82
  transKeepBasicHtmlNodesFor: ["br", "strong", "i"],
83
83
  },
84
- compatibilityJSON: "v3",
84
+ compatibilityJSON: "v4",
85
85
  };
86
86
  if (!hasBeenInitialized) {
87
87
  i18next
@@ -131,10 +131,25 @@ const useNamespaceTranslation = (namespace, options) => {
131
131
  namespace,
132
132
  })));
133
133
  }
134
+ // Explicitly handle the three different function overloads of t()
134
135
  if (arguments.length === 3 && typeof arg2 === "string") {
135
- return t(key, arg2, arg3);
136
+ // Case: t(key, defaultValue, options)
137
+ const defaultValue = arg2;
138
+ const opt = arg3;
139
+ return t(key, defaultValue, opt);
140
+ }
141
+ else if (typeof arg2 === "string") {
142
+ // Case: t(key, defaultValue)
143
+ return t(key, arg2);
144
+ }
145
+ else if (arg2) {
146
+ // Case: t(key, options)
147
+ return t(key, arg2);
148
+ }
149
+ else {
150
+ // Case: t(key)
151
+ return t(key);
136
152
  }
137
- return t(key, arg2);
138
153
  }, [i18NextInstance, namespace, captureException, t]);
139
154
  // Replace t function with customT
140
155
  const updatedUseTranslation = react.useMemo(() => {
package/index.esm.js CHANGED
@@ -79,7 +79,7 @@ const initializeTranslationsForApp = () => {
79
79
  transSupportBasicHtmlNodes: true,
80
80
  transKeepBasicHtmlNodesFor: ["br", "strong", "i"],
81
81
  },
82
- compatibilityJSON: "v3",
82
+ compatibilityJSON: "v4",
83
83
  };
84
84
  if (!hasBeenInitialized) {
85
85
  i18next
@@ -129,10 +129,25 @@ const useNamespaceTranslation = (namespace, options) => {
129
129
  namespace,
130
130
  })));
131
131
  }
132
+ // Explicitly handle the three different function overloads of t()
132
133
  if (arguments.length === 3 && typeof arg2 === "string") {
133
- return t(key, arg2, arg3);
134
+ // Case: t(key, defaultValue, options)
135
+ const defaultValue = arg2;
136
+ const opt = arg3;
137
+ return t(key, defaultValue, opt);
138
+ }
139
+ else if (typeof arg2 === "string") {
140
+ // Case: t(key, defaultValue)
141
+ return t(key, arg2);
142
+ }
143
+ else if (arg2) {
144
+ // Case: t(key, options)
145
+ return t(key, arg2);
146
+ }
147
+ else {
148
+ // Case: t(key)
149
+ return t(key);
134
150
  }
135
- return t(key, arg2);
136
151
  }, [i18NextInstance, namespace, captureException, t]);
137
152
  // Replace t function with customT
138
153
  const updatedUseTranslation = useMemo(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/i18n-library-translation",
3
- "version": "1.3.119",
3
+ "version": "1.3.120",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,13 +8,13 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "react": "19.0.0",
11
- "react-i18next": "^12.2.2",
11
+ "react-i18next": "^15.5.1",
12
12
  "jest-fetch-mock": "^3.0.3",
13
- "i18next": "21.10.0",
14
- "i18next-browser-languagedetector": "6.1.8",
15
- "i18next-resources-to-backend": "^1.1.4",
16
- "@trackunit/iris-app-api": "1.3.111",
17
- "@trackunit/react-core-hooks": "1.3.115"
13
+ "i18next": "25.1.2",
14
+ "i18next-browser-languagedetector": "8.1.0",
15
+ "i18next-resources-to-backend": "^1.2.1",
16
+ "@trackunit/iris-app-api": "1.3.112",
17
+ "@trackunit/react-core-hooks": "1.3.116"
18
18
  },
19
19
  "module": "./index.esm.js",
20
20
  "main": "./index.cjs.js",
@@ -9,7 +9,7 @@ export type TransForLibs<LibKeys> = (key: LibKeys, arg2?: string | TOptions, arg
9
9
  * @param options options to send to i18next
10
10
  * @returns {[TransForLibs, i18n, boolean]} useTranslation with custom t function
11
11
  */
12
- export declare const useNamespaceTranslation: <TranslationKeys extends string>(namespace: string, options?: UseTranslationOptions) => [TransForLibs<TranslationKeys>, i18n, boolean] & {
12
+ export declare const useNamespaceTranslation: <TranslationKeys extends string, KPrefix extends string = string>(namespace: string, options?: UseTranslationOptions<KPrefix>) => [TransForLibs<TranslationKeys>, i18n, boolean] & {
13
13
  t: TransForLibs<TranslationKeys>;
14
14
  i18n: i18n;
15
15
  ready: boolean;