@trackunit/i18n-library-translation 1.11.7 → 1.11.8
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/i18n-library-translation",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.8",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"i18next": "25.1.2",
|
|
13
13
|
"i18next-browser-languagedetector": "8.1.0",
|
|
14
14
|
"i18next-resources-to-backend": "^1.2.1",
|
|
15
|
-
"@trackunit/iris-app-api": "1.14.
|
|
16
|
-
"@trackunit/react-core-hooks": "1.11.
|
|
15
|
+
"@trackunit/iris-app-api": "1.14.8",
|
|
16
|
+
"@trackunit/react-core-hooks": "1.11.8"
|
|
17
17
|
},
|
|
18
18
|
"module": "./index.esm.js",
|
|
19
19
|
"main": "./index.cjs.js",
|
package/src/NamespaceTrans.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
|
-
export interface NamespaceTransProps<
|
|
2
|
+
export interface NamespaceTransProps<TTranslationKeys extends string> {
|
|
3
3
|
namespace?: string;
|
|
4
|
-
i18nKey:
|
|
4
|
+
i18nKey: TTranslationKeys | Array<TTranslationKeys>;
|
|
5
5
|
values: object;
|
|
6
6
|
components?: {
|
|
7
7
|
readonly [tagName: string]: ReactElement;
|
|
@@ -13,4 +13,4 @@ export interface NamespaceTransProps<TranslationKeys extends string> {
|
|
|
13
13
|
* @param { NamespaceTransProps } props the props for this namespace
|
|
14
14
|
* @returns { ReactElement } The translated text - with safe interpolation of simple html (<strong><em><b><i> etc.)
|
|
15
15
|
*/
|
|
16
|
-
export declare function NamespaceTrans<
|
|
16
|
+
export declare function NamespaceTrans<TTranslationKeys extends string>(props: NamespaceTransProps<TTranslationKeys>): ReactElement;
|
package/src/types.d.ts
CHANGED
|
@@ -6,14 +6,14 @@ export type TranslationStrings = {
|
|
|
6
6
|
[key: string]: string;
|
|
7
7
|
};
|
|
8
8
|
export type Languages = {
|
|
9
|
-
[
|
|
9
|
+
[KeyLanguage in TranslationLanguageKeys]: () => Promise<TranslationStrings | {
|
|
10
10
|
default: TranslationStrings;
|
|
11
11
|
}>;
|
|
12
12
|
};
|
|
13
13
|
export interface TranslationResource<TLanguageKey extends string> {
|
|
14
14
|
ns: string;
|
|
15
15
|
default: {
|
|
16
|
-
[
|
|
16
|
+
[KeyTranslation in TLanguageKey]: string;
|
|
17
17
|
};
|
|
18
18
|
languages: Omit<Languages, "en">;
|
|
19
19
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i18n, TOptions } from "i18next";
|
|
2
2
|
import { UseTranslationOptions } from "react-i18next";
|
|
3
|
-
export type TransForLibs<
|
|
3
|
+
export type TransForLibs<TLibKeys> = (key: TLibKeys, arg2?: string | TOptions, arg3?: string | TOptions) => string;
|
|
4
4
|
/**
|
|
5
5
|
* This is a custom Type Safe version of react-i18next useTranslation hook.
|
|
6
6
|
* Logs errors in sentry for translations keys that does not exist in english for the given namespace.
|
|
@@ -9,8 +9,8 @@ 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: <
|
|
13
|
-
t: TransForLibs<
|
|
12
|
+
export declare const useNamespaceTranslation: <TTranslationKeys extends string, TKeyPrefix extends string = string>(namespace: string, options?: UseTranslationOptions<TKeyPrefix>) => [TransForLibs<TTranslationKeys>, i18n, boolean] & {
|
|
13
|
+
t: TransForLibs<TTranslationKeys>;
|
|
14
14
|
i18n: i18n;
|
|
15
15
|
ready: boolean;
|
|
16
16
|
};
|