@intlayer/react-i18next 8.12.5-canary.0
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/README.md +330 -0
- package/dist/cjs/I18nextProvider.cjs +25 -0
- package/dist/cjs/I18nextProvider.cjs.map +1 -0
- package/dist/cjs/Trans.cjs +64 -0
- package/dist/cjs/Trans.cjs.map +1 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/cjs/helpers.cjs +67 -0
- package/dist/cjs/helpers.cjs.map +1 -0
- package/dist/cjs/index.cjs +49 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/initReactI18next.cjs +24 -0
- package/dist/cjs/initReactI18next.cjs.map +1 -0
- package/dist/cjs/plugin/index.cjs +62 -0
- package/dist/cjs/plugin/index.cjs.map +1 -0
- package/dist/cjs/useDictionary.cjs +64 -0
- package/dist/cjs/useDictionary.cjs.map +1 -0
- package/dist/cjs/useDictionaryDynamic.cjs +49 -0
- package/dist/cjs/useDictionaryDynamic.cjs.map +1 -0
- package/dist/cjs/useTranslation.cjs +109 -0
- package/dist/cjs/useTranslation.cjs.map +1 -0
- package/dist/cjs/useTranslationDictionary.cjs +57 -0
- package/dist/cjs/useTranslationDictionary.cjs.map +1 -0
- package/dist/cjs/useTranslationDictionaryDynamic.cjs +49 -0
- package/dist/cjs/useTranslationDictionaryDynamic.cjs.map +1 -0
- package/dist/cjs/withTranslation.cjs +28 -0
- package/dist/cjs/withTranslation.cjs.map +1 -0
- package/dist/esm/I18nextProvider.mjs +23 -0
- package/dist/esm/I18nextProvider.mjs.map +1 -0
- package/dist/esm/Trans.mjs +62 -0
- package/dist/esm/Trans.mjs.map +1 -0
- package/dist/esm/helpers.mjs +54 -0
- package/dist/esm/helpers.mjs.map +1 -0
- package/dist/esm/index.mjs +28 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/initReactI18next.mjs +23 -0
- package/dist/esm/initReactI18next.mjs.map +1 -0
- package/dist/esm/plugin/index.mjs +58 -0
- package/dist/esm/plugin/index.mjs.map +1 -0
- package/dist/esm/useDictionary.mjs +62 -0
- package/dist/esm/useDictionary.mjs.map +1 -0
- package/dist/esm/useDictionaryDynamic.mjs +47 -0
- package/dist/esm/useDictionaryDynamic.mjs.map +1 -0
- package/dist/esm/useTranslation.mjs +107 -0
- package/dist/esm/useTranslation.mjs.map +1 -0
- package/dist/esm/useTranslationDictionary.mjs +55 -0
- package/dist/esm/useTranslationDictionary.mjs.map +1 -0
- package/dist/esm/useTranslationDictionaryDynamic.mjs +47 -0
- package/dist/esm/useTranslationDictionaryDynamic.mjs.map +1 -0
- package/dist/esm/withTranslation.mjs +26 -0
- package/dist/esm/withTranslation.mjs.map +1 -0
- package/dist/types/I18nextProvider.d.ts +13 -0
- package/dist/types/I18nextProvider.d.ts.map +1 -0
- package/dist/types/Trans.d.ts +22 -0
- package/dist/types/Trans.d.ts.map +1 -0
- package/dist/types/helpers.d.ts +35 -0
- package/dist/types/helpers.d.ts.map +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/initReactI18next.d.ts +16 -0
- package/dist/types/initReactI18next.d.ts.map +1 -0
- package/dist/types/plugin/index.d.ts +12 -0
- package/dist/types/plugin/index.d.ts.map +1 -0
- package/dist/types/useDictionary.d.ts +32 -0
- package/dist/types/useDictionary.d.ts.map +1 -0
- package/dist/types/useDictionaryDynamic.d.ts +22 -0
- package/dist/types/useDictionaryDynamic.d.ts.map +1 -0
- package/dist/types/useTranslation.d.ts +43 -0
- package/dist/types/useTranslation.d.ts.map +1 -0
- package/dist/types/useTranslationDictionary.d.ts +29 -0
- package/dist/types/useTranslationDictionary.d.ts.map +1 -0
- package/dist/types/useTranslationDictionaryDynamic.d.ts +22 -0
- package/dist/types/useTranslationDictionaryDynamic.d.ts.map +1 -0
- package/dist/types/withTranslation.d.ts +10 -0
- package/dist/types/withTranslation.d.ts.map +1 -0
- package/package.json +118 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Trans.d.ts","names":[],"sources":["../../src/Trans.tsx"],"mappings":";;;;;AAsFA;;;;;;;;;;;;;cAAa,KAAA,SAAc,OAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TFunction, i18n } from "i18next";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers.d.ts
|
|
5
|
+
declare const I18nContext: React.Context<{
|
|
6
|
+
i18n: i18n;
|
|
7
|
+
}>;
|
|
8
|
+
interface TranslationProps {
|
|
9
|
+
children: (t: TFunction, options: {
|
|
10
|
+
i18n: i18n;
|
|
11
|
+
lng: string;
|
|
12
|
+
}, ready: boolean) => React.ReactNode;
|
|
13
|
+
ns?: string | string[];
|
|
14
|
+
keyPrefix?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const Translation: ({
|
|
17
|
+
children,
|
|
18
|
+
ns,
|
|
19
|
+
keyPrefix
|
|
20
|
+
}: TranslationProps) => React.ReactElement;
|
|
21
|
+
declare const nodesToString: (children: React.ReactNode, _i18nOptions?: unknown, _i18n?: unknown, _i18nKey?: string) => string;
|
|
22
|
+
declare const setI18n: (instance: i18n) => void;
|
|
23
|
+
declare const getI18n: () => i18n;
|
|
24
|
+
declare const setDefaults: (options: unknown) => void;
|
|
25
|
+
declare const getDefaults: () => unknown;
|
|
26
|
+
declare const useSSR: (_initialI18nStore: unknown, _initialLanguage: string) => void;
|
|
27
|
+
declare const withSSR: () => <P extends object>(WrappedComponent: React.ComponentType<P>) => React.ComponentType<P>;
|
|
28
|
+
declare const composeInitialProps: (_ForComponent: unknown) => (_ctx: unknown) => Promise<{}>;
|
|
29
|
+
declare const getInitialProps: () => {
|
|
30
|
+
initialI18nStore: {};
|
|
31
|
+
initialLanguage: string;
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { I18nContext, Translation, TranslationProps, composeInitialProps, getDefaults, getI18n, getInitialProps, nodesToString, setDefaults, setI18n, useSSR, withSSR };
|
|
35
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../src/helpers.tsx"],"mappings":";;;;cAKa,WAAA,EAAW,KAAA,CAAA,OAAA;QAA+B,IAAA;AAAA;AAAA,UAItC,gBAAA;EACf,QAAA,GACE,CAAA,EAAG,SAAA,EACH,OAAA;IAAW,IAAA,EAAM,IAAA;IAAM,GAAA;EAAA,GACvB,KAAA,cACG,KAAA,CAAM,SAAA;EACX,EAAA;EACA,SAAA;AAAA;AAAA,cAIW,WAAA;EAAe,QAAA;EAAA,EAAA;EAAA;AAAA,GAIzB,gBAAA,KAAmB,KAAA,CAAM,YAAA;AAAA,cAUf,aAAA,GACX,QAAA,EAAU,KAAA,CAAM,SAAA,EAChB,YAAA,YACA,KAAA,YACA,QAAA;AAAA,cAwBW,OAAA,GAAW,QAAA,EAAU,IAAA;AAAA,cAIrB,OAAA,QAAc,IAAA;AAAA,cAId,WAAA,GAAe,OAAA;AAAA,cAIf,WAAA;AAAA,cAKA,MAAA,GACX,iBAAA,WACA,gBAAA;AAAA,cAGW,OAAA,2BACkB,gBAAA,EACT,KAAA,CAAM,aAAA,CAAc,CAAA,MACrC,KAAA,CAAM,aAAA,CAAc,CAAA;AAAA,cAWZ,mBAAA,GACV,aAAA,eAAkC,IAAA,cAAa,OAAA;AAAA,cAErC,eAAA;EAGX,gBAAA;EAAA,eAAA;AAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { I18nextProvider } from "./I18nextProvider.js";
|
|
2
|
+
import { Trans } from "./Trans.js";
|
|
3
|
+
import { initReactI18next } from "./initReactI18next.js";
|
|
4
|
+
import { useDictionary } from "./useDictionary.js";
|
|
5
|
+
import { useDictionaryDynamic } from "./useDictionaryDynamic.js";
|
|
6
|
+
import { useTranslation } from "./useTranslation.js";
|
|
7
|
+
import { withTranslation } from "./withTranslation.js";
|
|
8
|
+
import { I18nContext as I18nContext$1, I18nextProviderProps, Trans as Trans$1, TransProps, TransWithoutContext as TransWithoutContext$1, Translation as Translation$1, UseTranslationOptions, UseTranslationResponse, WithTranslation, WithTranslationProps, composeInitialProps as composeInitialProps$1, getDefaults as getDefaults$1, getI18n as getI18n$1, getInitialProps as getInitialProps$1, setDefaults as setDefaults$1, setI18n as setI18n$1, useSSR as useSSR$1, withSSR as withSSR$1 } from "react-i18next";
|
|
9
|
+
|
|
10
|
+
//#region src/index.d.ts
|
|
11
|
+
declare const nodesToString: (children: React.ReactNode, _i18nOptions?: unknown, _i18n?: unknown, _i18nKey?: string) => string;
|
|
12
|
+
declare const setDefaults: typeof setDefaults$1;
|
|
13
|
+
declare const getDefaults: typeof getDefaults$1;
|
|
14
|
+
declare const setI18n: typeof setI18n$1;
|
|
15
|
+
declare const getI18n: typeof getI18n$1;
|
|
16
|
+
declare const composeInitialProps: typeof composeInitialProps$1;
|
|
17
|
+
declare const getInitialProps: typeof getInitialProps$1;
|
|
18
|
+
declare const useSSR: typeof useSSR$1;
|
|
19
|
+
declare const withSSR: typeof withSSR$1;
|
|
20
|
+
declare const Translation: typeof Translation$1;
|
|
21
|
+
declare const I18nContext: typeof I18nContext$1;
|
|
22
|
+
declare const TransWithoutContext: typeof TransWithoutContext$1;
|
|
23
|
+
declare const IcuTrans: typeof Trans$1;
|
|
24
|
+
declare const IcuTransWithoutContext: typeof Trans$1;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { I18nContext, I18nextProvider, type I18nextProviderProps, IcuTrans, IcuTransWithoutContext, Trans, type TransProps, TransWithoutContext, Translation, type UseTranslationOptions, type UseTranslationResponse, type WithTranslation, type WithTranslationProps, composeInitialProps, getDefaults, getI18n, getInitialProps, initReactI18next, nodesToString, setDefaults, setI18n, useDictionary, useDictionaryDynamic, useSSR, useTranslation, withSSR, withTranslation };
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;cAmDa,aAAA,GAAa,QAAA,EAAA,KAAA,CAAA,SAAA,EAAA,YAAA,YAAA,KAAA,YAAA,QAAA;AAAA,cACb,WAAA,SAAwC,aAAA;AAAA,cACxC,WAAA,SAAwC,aAAA;AAAA,cACxC,OAAA,SAAgC,SAAA;AAAA,cAChC,OAAA,SAAgC,SAAA;AAAA,cAChC,mBAAA,SACuB,qBAAA;AAAA,cACvB,eAAA,SAAgD,iBAAA;AAAA,cAChD,MAAA,SAA8B,QAAA;AAAA,cAC9B,OAAA,SAAgC,SAAA;AAAA,cAChC,WAAA,SAAwC,aAAA;AAAA,cACxC,WAAA,SAAwC,aAAA;AAAA,cAExC,mBAAA,SAAsC,qBAAA;AAAA,cAMtC,QAAA,SAA2B,OAAA;AAAA,cAC3B,sBAAA,SAAyC,OAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { initReactI18next as initReactI18next$1 } from "react-i18next";
|
|
2
|
+
|
|
3
|
+
//#region src/initReactI18next.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in for react-i18next's `initReactI18next` plugin.
|
|
6
|
+
*
|
|
7
|
+
* Implemented locally rather than re-exported from `react-i18next`: when the
|
|
8
|
+
* compat alias plugin is enabled, `react-i18next` resolves back to this package,
|
|
9
|
+
* so a re-export would be self-referential (resolving to `undefined`). The
|
|
10
|
+
* plugin records the i18n instance via the compat `setI18n`/`setDefaults`
|
|
11
|
+
* helpers; actual translation is served by Intlayer.
|
|
12
|
+
*/
|
|
13
|
+
declare const initReactI18next: typeof initReactI18next$1;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { initReactI18next };
|
|
16
|
+
//# sourceMappingURL=initReactI18next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initReactI18next.d.ts","names":[],"sources":["../../src/initReactI18next.ts"],"mappings":";;;;;AAYA;;;;;;;cAAa,gBAAA,SAAyB,kBAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PluginOption } from "vite";
|
|
2
|
+
import { intlayer } from "vite-intlayer";
|
|
3
|
+
|
|
4
|
+
//#region src/plugin/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A Vite plugin for react-i18next compat that wraps vite-intlayer
|
|
7
|
+
* and configures resolve aliases for react-i18next and i18next.
|
|
8
|
+
*/
|
|
9
|
+
declare const reactI18nextVitePlugin: (options?: Parameters<typeof intlayer>[0]) => PluginOption[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { reactI18nextVitePlugin as default, reactI18nextVitePlugin };
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugin/index.ts"],"mappings":";;;;;;AA6BA;;cAAa,sBAAA,GACX,OAAA,GAAU,UAAA,QAAkB,QAAA,SAC3B,YAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { UseTranslationOptions } from "react-i18next";
|
|
2
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
3
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
+
|
|
5
|
+
//#region src/useDictionary.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Dictionary-accepting variant of `useTranslation`.
|
|
8
|
+
*
|
|
9
|
+
* Used internally by the SWC optimization: instead of looking up the dictionary
|
|
10
|
+
* at runtime by key, the SWC plugin pre-imports the dictionary JSON at build time
|
|
11
|
+
* and passes it directly here. This enables tree-shaking of unused locale content.
|
|
12
|
+
*
|
|
13
|
+
* For a nested namespace (`useTranslation('about.counter')`), the SWC passes the
|
|
14
|
+
* key prefix (`'counter'`) as the second argument.
|
|
15
|
+
*
|
|
16
|
+
* @example (generated by SWC, not written manually)
|
|
17
|
+
* import _abc from '.intlayer/dictionaries/about.json' with { type: 'json' };
|
|
18
|
+
* const { t } = useDictionary(_abc);
|
|
19
|
+
*/
|
|
20
|
+
declare const useDictionary: <T extends Dictionary>(dictionary: T, keyPrefix?: string | UseTranslationOptions<string>, options?: UseTranslationOptions<string>) => {
|
|
21
|
+
t: <P extends ValidDotPathsFor<any>>(key: P, params?: Record<string, unknown>) => string;
|
|
22
|
+
i18n: {
|
|
23
|
+
language: string;
|
|
24
|
+
languages: string[];
|
|
25
|
+
changeLanguage: (lng: string) => Promise<void>;
|
|
26
|
+
isInitialized: boolean;
|
|
27
|
+
};
|
|
28
|
+
ready: boolean;
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { useDictionary };
|
|
32
|
+
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../src/useDictionary.ts"],"mappings":";;;;;;;AAuCA;;;;;;;;;;;;cAAa,aAAA,aAA2B,UAAA,EACtC,UAAA,EAAY,CAAA,EACZ,SAAA,YAAqB,qBAAA,UACrB,OAAA,GAAU,qBAAA;gBAsBW,gBAAA,OAAqB,GAAA,EACnC,CAAA,EAAC,MAAA,GACG,MAAA;;;;qCAf2B,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UseTranslationOptions } from "react-i18next";
|
|
2
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
3
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
+
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
5
|
+
|
|
6
|
+
//#region src/useDictionaryDynamic.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Dynamic dictionary-accepting variant of `useTranslation`.
|
|
9
|
+
*/
|
|
10
|
+
declare const useDictionaryDynamic: <const T extends Dictionary, const K extends string>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, options?: UseTranslationOptions<string>) => {
|
|
11
|
+
t: <P extends ValidDotPathsFor<any>>(lookup: P, params?: Record<string, unknown>) => string;
|
|
12
|
+
i18n: {
|
|
13
|
+
language: string;
|
|
14
|
+
languages: string[];
|
|
15
|
+
changeLanguage: (lng: string) => Promise<void>;
|
|
16
|
+
isInitialized: boolean;
|
|
17
|
+
};
|
|
18
|
+
ready: boolean;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useDictionaryDynamic };
|
|
22
|
+
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../src/useDictionaryDynamic.ts"],"mappings":";;;;;;;;AAeA;cAAa,oBAAA,mBACK,UAAA,0BAGhB,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,OAAA,GAAU,qBAAA;gBAsBW,gBAAA,OAAqB,MAAA,EAChC,CAAA,EAAC,MAAA,GACA,MAAA;;;;qCAZ2B,OAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { UseTranslationOptions } from "react-i18next";
|
|
2
|
+
import { TOptions } from "i18next";
|
|
3
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
4
|
+
import { DictionaryKeys } from "@intlayer/types/module_augmentation";
|
|
5
|
+
|
|
6
|
+
//#region src/useTranslation.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Drop-in for react-i18next's `useTranslation`.
|
|
9
|
+
*
|
|
10
|
+
* Translation lookup goes through the shared i18next-dialect resolver:
|
|
11
|
+
* namespace prefixes (`ns:key`), the `ns` option, plural suffixes
|
|
12
|
+
* (`key_one`/`key_other` via `Intl.PluralRules`), context suffixes
|
|
13
|
+
* (`key_male`), `$t()` nesting, `defaultValue` and `{{var}}` interpolation
|
|
14
|
+
* are all supported.
|
|
15
|
+
*
|
|
16
|
+
* The returned `t()` is typed against the intlayer dictionary for namespace N:
|
|
17
|
+
* keys are autocompleted and dot-paths are validated at compile time.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const { t } = useTranslation('about');
|
|
22
|
+
* t('counter.label'); // ✓ typed; compile error if key doesn't exist
|
|
23
|
+
* t('items', { count: 3 }); // plural suffix resolution
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare const useTranslation: <N extends DictionaryKeys>(ns?: N | N[], options?: UseTranslationOptions<string>) => {
|
|
27
|
+
t: <P extends ValidDotPathsFor<N>>(key: P | P[], optionsOrDefaultValue?: TOptions | string, extraOptions?: TOptions) => string;
|
|
28
|
+
i18n: {
|
|
29
|
+
language: string;
|
|
30
|
+
languages: string[];
|
|
31
|
+
resolvedLanguage: string;
|
|
32
|
+
isInitialized: boolean;
|
|
33
|
+
changeLanguage: (newLanguage: string) => Promise<void>;
|
|
34
|
+
dir: (language?: string) => "ltr" | "rtl";
|
|
35
|
+
exists: (key: string, existsOptions?: TOptions) => boolean;
|
|
36
|
+
t: (key: string | string[], optionsOrDefaultValue?: TOptions | string, extraOptions?: TOptions) => string;
|
|
37
|
+
getFixedT: (language?: string | null, fixedNamespace?: string | null) => (key: string, fixedOptions?: TOptions) => string;
|
|
38
|
+
};
|
|
39
|
+
ready: boolean;
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { useTranslation };
|
|
43
|
+
//# sourceMappingURL=useTranslation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslation.d.ts","names":[],"sources":["../../src/useTranslation.ts"],"mappings":";;;;;;;;AAkCA;;;;;;;;;;;;;;;;;cAAa,cAAA,aAA4B,cAAA,EACvC,EAAA,GAAK,CAAA,GAAI,CAAA,IACT,OAAA,GAAU,qBAAA;gBAgGwB,gBAAA,CAAiB,CAAA,GAAE,GAAA,EAC9C,CAAA,GAAI,CAAA,IAAG,qBAAA,GACY,QAAA,WAAiB,YAAA,GAC1B,QAAA;;;;;;6CAlC6B,OAAA;;0BAOtB,aAAA,GAAkB,QAAA;gCA3ChB,qBAAA,GACE,QAAA,WAAiB,YAAA,GAC1B,QAAA;0CAkDY,cAAA,sBAAgC,GAAA,UAC7C,YAAA,GAAiB,QAAA;EAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UseTranslationOptions } from "i18next";
|
|
2
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
3
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
+
|
|
5
|
+
//#region src/useTranslationDictionary.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Dictionary-accepting variant of `useTranslation`.
|
|
8
|
+
*
|
|
9
|
+
* Used internally by the SWC optimization: instead of looking up the dictionary
|
|
10
|
+
* at runtime by key, the SWC plugin pre-imports the dictionary JSON at build time
|
|
11
|
+
* and passes it directly here. This enables tree-shaking of unused locale content.
|
|
12
|
+
*
|
|
13
|
+
* @example (generated by SWC, not written manually)
|
|
14
|
+
* import _abc from '.intlayer/dictionaries/about.json' with { type: 'json' };
|
|
15
|
+
* const { t } = useTranslationDictionary(_abc);
|
|
16
|
+
*/
|
|
17
|
+
declare const useTranslationDictionary: <T extends Dictionary>(dictionary: T, keyPrefix?: string, options?: UseTranslationOptions<string>) => {
|
|
18
|
+
t: <P extends ValidDotPathsFor<any>>(key: P, params?: Record<string, unknown>) => string;
|
|
19
|
+
i18n: {
|
|
20
|
+
language: string;
|
|
21
|
+
languages: string[];
|
|
22
|
+
changeLanguage: (lng: string) => Promise<void>;
|
|
23
|
+
isInitialized: boolean;
|
|
24
|
+
};
|
|
25
|
+
ready: boolean;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { useTranslationDictionary };
|
|
29
|
+
//# sourceMappingURL=useTranslationDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslationDictionary.d.ts","names":[],"sources":["../../src/useTranslationDictionary.ts"],"mappings":";;;;;;;AAmBA;;;;;;;;;cAAa,wBAAA,aAAsC,UAAA,EACjD,UAAA,EAAY,CAAA,EACZ,SAAA,WACA,OAAA,GAAU,qBAAA;gBAoBW,gBAAA,OAAqB,GAAA,EACnC,CAAA,EAAC,MAAA,GACG,MAAA;;;;qCAZ2B,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UseTranslationOptions } from "i18next";
|
|
2
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
3
|
+
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
4
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
5
|
+
|
|
6
|
+
//#region src/useTranslationDictionaryDynamic.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Dynamic dictionary-accepting variant of `useTranslation`.
|
|
9
|
+
*/
|
|
10
|
+
declare const useTranslationDictionaryDynamic: <const T extends Dictionary, const K extends string>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, keyPrefix?: string, options?: UseTranslationOptions<string>) => {
|
|
11
|
+
t: <P extends ValidDotPathsFor<any>>(lookup: P, params?: Record<string, unknown>) => string;
|
|
12
|
+
i18n: {
|
|
13
|
+
language: string;
|
|
14
|
+
languages: string[];
|
|
15
|
+
changeLanguage: (lng: string) => Promise<void>;
|
|
16
|
+
isInitialized: boolean;
|
|
17
|
+
};
|
|
18
|
+
ready: boolean;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useTranslationDictionaryDynamic };
|
|
22
|
+
//# sourceMappingURL=useTranslationDictionaryDynamic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslationDictionaryDynamic.d.ts","names":[],"sources":["../../src/useTranslationDictionaryDynamic.ts"],"mappings":";;;;;;;;AAYA;cAAa,+BAAA,mBACK,UAAA,0BAGhB,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,SAAA,WACA,OAAA,GAAU,qBAAA;gBAmBW,gBAAA,OAAqB,MAAA,EAChC,CAAA,EAAC,MAAA,GACA,MAAA;;;;qCAZ2B,OAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { withTranslation as withTranslation$1 } from "react-i18next";
|
|
2
|
+
|
|
3
|
+
//#region src/withTranslation.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in for react-i18next's `withTranslation` HOC.
|
|
6
|
+
*/
|
|
7
|
+
declare const withTranslation: typeof withTranslation$1;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { withTranslation };
|
|
10
|
+
//# sourceMappingURL=withTranslation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withTranslation.d.ts","names":[],"sources":["../../src/withTranslation.tsx"],"mappings":";;;;;AAYA;cAAa,eAAA,SAAwB,iBAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intlayer/react-i18next",
|
|
3
|
+
"version": "8.12.5-canary.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "react-i18next API adapter for intlayer — useTranslation, Trans, withTranslation, I18nextProvider backed by react-intlayer",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"intlayer",
|
|
8
|
+
"react-i18next",
|
|
9
|
+
"i18next",
|
|
10
|
+
"react",
|
|
11
|
+
"i18n",
|
|
12
|
+
"adapter",
|
|
13
|
+
"compatibility"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://intlayer.org",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/aymericzip/intlayer/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/aymericzip/intlayer.git"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"author": {
|
|
25
|
+
"name": "Aymeric PINEAU",
|
|
26
|
+
"url": "https://github.com/aymericzip"
|
|
27
|
+
},
|
|
28
|
+
"contributors": [
|
|
29
|
+
{
|
|
30
|
+
"name": "Aymeric Pineau",
|
|
31
|
+
"email": "ay.pineau@gmail.com",
|
|
32
|
+
"url": "https://github.com/aymericzip"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/types/index.d.ts",
|
|
39
|
+
"require": "./dist/cjs/index.cjs",
|
|
40
|
+
"import": "./dist/esm/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./plugin": {
|
|
43
|
+
"types": "./dist/types/plugin/index.d.ts",
|
|
44
|
+
"require": "./dist/cjs/plugin/index.cjs",
|
|
45
|
+
"import": "./dist/esm/plugin/index.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./package.json": "./package.json"
|
|
48
|
+
},
|
|
49
|
+
"main": "dist/cjs/index.cjs",
|
|
50
|
+
"module": "dist/esm/index.mjs",
|
|
51
|
+
"types": "dist/types/index.d.ts",
|
|
52
|
+
"typesVersions": {
|
|
53
|
+
"*": {
|
|
54
|
+
"plugin": [
|
|
55
|
+
"./dist/types/plugin/index.d.ts"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"files": [
|
|
60
|
+
"./dist",
|
|
61
|
+
"./package.json"
|
|
62
|
+
],
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "bun --bun tsdown --config tsdown.config.ts",
|
|
65
|
+
"build:ci": "bun --bun tsdown --config tsdown.config.ts",
|
|
66
|
+
"clean": "bun --bun rimraf ./dist .turbo",
|
|
67
|
+
"dev": "bun --bun tsdown --config tsdown.config.ts --watch",
|
|
68
|
+
"format": "bun --bun biome format . --check",
|
|
69
|
+
"format:fix": "bun --bun biome format --write .",
|
|
70
|
+
"lint": "bun --bun biome lint .",
|
|
71
|
+
"lint:fix": "bun --bun biome lint --write .",
|
|
72
|
+
"prepublish": "cp -f ../../README.md ./README.md",
|
|
73
|
+
"publish": "bun publish || true",
|
|
74
|
+
"publish:canary": "bun publish --access public --tag canary || true",
|
|
75
|
+
"publish:latest": "bun publish --access public --tag latest || true",
|
|
76
|
+
"test": "bun --bun vitest run",
|
|
77
|
+
"test:watch": "bun --bun vitest",
|
|
78
|
+
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
79
|
+
},
|
|
80
|
+
"dependencies": {
|
|
81
|
+
"@intlayer/chokidar": "9.0.0-canary.1",
|
|
82
|
+
"@intlayer/config": "9.0.0-canary.1",
|
|
83
|
+
"@intlayer/core": "9.0.0-canary.1",
|
|
84
|
+
"@intlayer/i18next": "8.12.5-canary.0",
|
|
85
|
+
"@intlayer/types": "9.0.0-canary.1",
|
|
86
|
+
"react-intlayer": "9.0.0-canary.1",
|
|
87
|
+
"vite-intlayer": "9.0.0-canary.1"
|
|
88
|
+
},
|
|
89
|
+
"devDependencies": {
|
|
90
|
+
"@types/node": "25.9.3",
|
|
91
|
+
"@types/react": "19.2.17",
|
|
92
|
+
"@utils/ts-config": "1.0.4",
|
|
93
|
+
"@utils/ts-config-types": "1.0.4",
|
|
94
|
+
"@utils/tsdown-config": "1.0.4",
|
|
95
|
+
"i18next": "26.3.1",
|
|
96
|
+
"react-i18next": "17.0.8",
|
|
97
|
+
"rimraf": "6.1.3",
|
|
98
|
+
"tsdown": "0.21.10",
|
|
99
|
+
"typescript": "6.0.3",
|
|
100
|
+
"vite": "8.0.16",
|
|
101
|
+
"vitest": "4.1.9"
|
|
102
|
+
},
|
|
103
|
+
"peerDependencies": {
|
|
104
|
+
"i18next": ">=20.0.0",
|
|
105
|
+
"react": ">=16.0.0",
|
|
106
|
+
"react-dom": ">=16.0.0",
|
|
107
|
+
"react-i18next": ">=11.0.0",
|
|
108
|
+
"vite": ">=4.0.0"
|
|
109
|
+
},
|
|
110
|
+
"peerDependenciesMeta": {
|
|
111
|
+
"vite": {
|
|
112
|
+
"optional": true
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"engines": {
|
|
116
|
+
"node": ">=14.18"
|
|
117
|
+
}
|
|
118
|
+
}
|