@intlayer/use-intl 9.4.3 → 9.5.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 +0 -2
- package/dist/types/client/IntlProvider.d.ts +2 -3
- package/dist/types/client/IntlProvider.d.ts.map +1 -1
- package/dist/types/client/helpers.d.ts +4 -5
- package/dist/types/client/helpers.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +2 -2
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +1 -2
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useTranslations.d.ts +1 -2
- package/dist/types/client/useTranslations.d.ts.map +1 -1
- package/dist/types/core/createFormatter.d.ts +1 -2
- package/dist/types/core/createFormatter.d.ts.map +1 -1
- package/dist/types/core/createTranslator.d.ts +2 -3
- package/dist/types/core/createTranslator.d.ts.map +1 -1
- package/dist/types/core/errors.d.ts +2 -3
- package/dist/types/core/errors.d.ts.map +1 -1
- package/dist/types/core/hasLocale.d.ts +1 -2
- package/dist/types/core/hasLocale.d.ts.map +1 -1
- package/dist/types/core/initializeConfig.d.ts +1 -2
- package/dist/types/core/initializeConfig.d.ts.map +1 -1
- package/dist/types/plugin/index.d.ts +2 -2
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/shared/intlFormatter.d.ts +2 -3
- package/dist/types/shared/intlFormatter.d.ts.map +1 -1
- package/dist/types/shared/namespaceTranslator.d.ts +6 -6
- package/dist/types/shared/namespaceTranslator.d.ts.map +1 -1
- package/dist/types/shared/translateFunctionTypes.d.ts +7 -8
- package/dist/types/shared/translateFunctionTypes.d.ts.map +1 -1
- package/dist/types/useDictionary.d.ts +1 -2
- package/dist/types/useDictionary.d.ts.map +1 -1
- package/dist/types/useDictionaryDynamic.d.ts +1 -2
- package/dist/types/useDictionaryDynamic.d.ts.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -69,8 +69,6 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
|
|
|
69
69
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
|
|
70
70
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
|
|
71
71
|
|
|
72
|
-
---
|
|
73
|
-
|
|
74
72
|
## 📦 Installation
|
|
75
73
|
|
|
76
74
|
Start your journey with Intlayer today and experience a smoother, more powerful approach to internationalization.
|
|
@@ -10,12 +10,12 @@ import { IntlProvider as IntlProvider$1 } from "use-intl";
|
|
|
10
10
|
* `getMessageFallback` are accepted for API compatibility but have no effect —
|
|
11
11
|
* Intlayer uses its own compiled dictionaries.
|
|
12
12
|
*/
|
|
13
|
-
declare const IntlProvider: typeof IntlProvider$1;
|
|
13
|
+
export declare const IntlProvider: typeof IntlProvider$1;
|
|
14
14
|
/**
|
|
15
15
|
* Props accepted by {@link IntlProvider}. `messages` is deprecated — Intlayer
|
|
16
16
|
* loads content from compiled dictionaries automatically.
|
|
17
17
|
*/
|
|
18
|
-
type IntlProviderProps = Omit<ComponentProps<typeof IntlProvider$1>, 'messages' | 'locale'> & {
|
|
18
|
+
export type IntlProviderProps = Omit<ComponentProps<typeof IntlProvider$1>, 'messages' | 'locale'> & {
|
|
19
19
|
/**
|
|
20
20
|
* @deprecated has no use case with intlayer. Messages are loaded
|
|
21
21
|
* automatically under the hood for bundle optimization reason.
|
|
@@ -25,5 +25,4 @@ type IntlProviderProps = Omit<ComponentProps<typeof IntlProvider$1>, 'messages'
|
|
|
25
25
|
locale: LocalesValues;
|
|
26
26
|
};
|
|
27
27
|
//#endregion
|
|
28
|
-
export { IntlProvider, IntlProviderProps };
|
|
29
28
|
//# sourceMappingURL=IntlProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlProvider.d.ts","names":[],"sources":["../../../src/client/IntlProvider.tsx"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"IntlProvider.d.ts","names":[],"sources":["../../../src/client/IntlProvider.tsx"],"mappings":";;;;;;;;;;;;qBAkBa,qBAAqB;;;;;YAiCtB,oBAAoB,KAC9B,sBAAsB;;;;;EAOtB;;EAEA,QAAQ"}
|
|
@@ -4,12 +4,12 @@ import { useFormatter as useFormatter$1, useMessages as useMessages$1, useNow as
|
|
|
4
4
|
* Drop-in for use-intl's `useNow`.
|
|
5
5
|
* Returns the current `Date`. The `updateInterval` option is ignored.
|
|
6
6
|
*/
|
|
7
|
-
declare const useNow: typeof useNow$1;
|
|
7
|
+
export declare const useNow: typeof useNow$1;
|
|
8
8
|
/**
|
|
9
9
|
* Drop-in for use-intl's `useTimeZone`.
|
|
10
10
|
* Returns the system time zone resolved from `Intl.DateTimeFormat`.
|
|
11
11
|
*/
|
|
12
|
-
declare const useTimeZone: typeof useTimeZone$1;
|
|
12
|
+
export declare const useTimeZone: typeof useTimeZone$1;
|
|
13
13
|
/**
|
|
14
14
|
* Drop-in for use-intl's `useMessages`.
|
|
15
15
|
*
|
|
@@ -17,14 +17,13 @@ declare const useTimeZone: typeof useTimeZone$1;
|
|
|
17
17
|
* Messages are loaded automatically under the hood.
|
|
18
18
|
* @returns An empty object.
|
|
19
19
|
*/
|
|
20
|
-
declare const useMessages: typeof useMessages$1;
|
|
20
|
+
export declare const useMessages: typeof useMessages$1;
|
|
21
21
|
/**
|
|
22
22
|
* Drop-in for use-intl's `useFormatter`.
|
|
23
23
|
* Returns locale-aware formatters backed by the native `Intl.*` APIs:
|
|
24
24
|
* `dateTime`, `number`, `dateTimeRange`, `relativeTime`, `list`, and
|
|
25
25
|
* `displayName`.
|
|
26
26
|
*/
|
|
27
|
-
declare const useFormatter: typeof useFormatter$1;
|
|
27
|
+
export declare const useFormatter: typeof useFormatter$1;
|
|
28
28
|
//#endregion
|
|
29
|
-
export { useFormatter, useMessages, useNow, useTimeZone };
|
|
30
29
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/client/helpers.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/client/helpers.ts"],"mappings":";;;;;;qBAkBa,eAAe;;;;;qBAMf,oBAAoB;;;;;;;;qBAUpB,oBAAoB;;;;;;;qBAiBpB,qBAAqB"}
|
|
@@ -9,7 +9,7 @@ import { useTranslations } from "./useTranslations.js";
|
|
|
9
9
|
* @internal Private use-intl export, kept so aliased `_useExtracted` imports
|
|
10
10
|
* resolve. Not part of the supported public surface.
|
|
11
11
|
*/
|
|
12
|
-
declare const _useExtracted: () => Record<string, never>;
|
|
12
|
+
export declare const _useExtracted: () => Record<string, never>;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { IntlProvider, type IntlProviderProps,
|
|
14
|
+
export { IntlProvider, type IntlProviderProps, useDictionary, useDictionaryDynamic, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/client/index.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/client/index.ts"],"mappings":";;;;;;;;;;;qBAWa,qBAAoB"}
|
|
@@ -5,7 +5,6 @@ import { useLocale as useLocale$1 } from "use-intl";
|
|
|
5
5
|
*
|
|
6
6
|
* Returns the active locale string from Intlayer's client context.
|
|
7
7
|
*/
|
|
8
|
-
declare const useLocale: typeof useLocale$1;
|
|
8
|
+
export declare const useLocale: typeof useLocale$1;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { useLocale };
|
|
11
10
|
//# sourceMappingURL=useLocale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/client/useLocale.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/client/useLocale.ts"],"mappings":";;;;;;;qBAUa,kBAAkB"}
|
|
@@ -38,7 +38,6 @@ type UseTranslations = {
|
|
|
38
38
|
* t.rich('terms', { link: (chunks) => <a href="/terms">{chunks}</a> });
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
declare const useTranslations: UseTranslations;
|
|
41
|
+
export declare const useTranslations: UseTranslations;
|
|
42
42
|
//#endregion
|
|
43
|
-
export { useTranslations };
|
|
44
43
|
//# sourceMappingURL=useTranslations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslations.d.ts","names":[],"sources":["../../../src/client/useTranslations.ts"],"mappings":";;;;;;;;;;;;;KAyBK;GACF,UAAU,gBAAgB,WAAW,IAAI,kBAAkB;GAC3D,iCACC,WAAW,IACV,8BAA8B;MAC7B;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useTranslations.d.ts","names":[],"sources":["../../../src/client/useTranslations.ts"],"mappings":";;;;;;;;;;;;;KAyBK;GACF,UAAU,gBAAgB,WAAW,IAAI,kBAAkB;GAC3D,iCACC,WAAW,IACV,8BAA8B;MAC7B;;;;;;;;;;;;;;;;;;;;;;;;qBAyBO,iBAOP"}
|
|
@@ -14,7 +14,6 @@ import { createFormatter as createFormatter$1 } from "use-intl";
|
|
|
14
14
|
* format.number(1234.5, { style: 'currency', currency: 'USD' });
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
declare const createFormatter: typeof createFormatter$1;
|
|
17
|
+
export declare const createFormatter: typeof createFormatter$1;
|
|
18
18
|
//#endregion
|
|
19
|
-
export { createFormatter };
|
|
20
19
|
//# sourceMappingURL=createFormatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFormatter.d.ts","names":[],"sources":["../../../src/core/createFormatter.ts"],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"createFormatter.d.ts","names":[],"sources":["../../../src/core/createFormatter.ts"],"mappings":";;;;;;;;;;;;;;;;qBAiBa,wBAAwB"}
|
|
@@ -8,7 +8,7 @@ import { DictionaryKeys, LocalesValues } from "@intlayer/types/module_augmentati
|
|
|
8
8
|
* `timeZone`, `onError`, and `getMessageFallback` have no effect — Intlayer
|
|
9
9
|
* resolves content from its own compiled dictionaries.
|
|
10
10
|
*/
|
|
11
|
-
type CreateTranslatorConfig<N extends DictionaryKeys> = {
|
|
11
|
+
export type CreateTranslatorConfig<N extends DictionaryKeys> = {
|
|
12
12
|
/** The locale dictionaries are resolved for. */
|
|
13
13
|
locale: LocalesValues;
|
|
14
14
|
/** A bare dictionary key, or a nested `'dictionary.scope'` namespace. */
|
|
@@ -52,7 +52,6 @@ type CreateTranslator = {
|
|
|
52
52
|
* t('items', { count: 3 }); // ICU plural
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
|
-
declare const createTranslator: CreateTranslator;
|
|
55
|
+
export declare const createTranslator: CreateTranslator;
|
|
56
56
|
//#endregion
|
|
57
|
-
export { CreateTranslatorConfig, createTranslator };
|
|
58
57
|
//# sourceMappingURL=createTranslator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTranslator.d.ts","names":[],"sources":["../../../src/core/createTranslator.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"createTranslator.d.ts","names":[],"sources":["../../../src/core/createTranslator.ts"],"mappings":";;;;;;;;;;YAqBY,uBAAuB,UAAU;;EAE3C,QAAQ;;EAER,YAAY;;;;;EAKZ;IACE;;;;;;;;;;;KAYC;GACF,UAAU,gBACT,QAAQ,uBAAuB;IAAO,WAAW;MAChD,kBAAkB;GACpB,iCACC,QAAQ,uBAAuB;IAAoB,WAAW;MAC7D,8BAA8B;GAChC,QAAQ,uBAAuB,kBAAkB;;;;;;;;;;;;;;;;qBAiBvC,kBAaP"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* aliased to this package at build time, so importing its runtime value would
|
|
7
7
|
* be circular.
|
|
8
8
|
*/
|
|
9
|
-
declare enum IntlErrorCode {
|
|
9
|
+
export declare enum IntlErrorCode {
|
|
10
10
|
MISSING_MESSAGE = "MISSING_MESSAGE",
|
|
11
11
|
MISSING_FORMAT = "MISSING_FORMAT",
|
|
12
12
|
ENVIRONMENT_FALLBACK = "ENVIRONMENT_FALLBACK",
|
|
@@ -21,11 +21,10 @@ declare enum IntlErrorCode {
|
|
|
21
21
|
* Carries the {@link IntlErrorCode} and the original message, matching
|
|
22
22
|
* use-intl's error shape so consumer `onError` handlers keep working.
|
|
23
23
|
*/
|
|
24
|
-
declare class IntlError extends Error {
|
|
24
|
+
export declare class IntlError extends Error {
|
|
25
25
|
readonly code: IntlErrorCode;
|
|
26
26
|
readonly originalMessage: string | undefined;
|
|
27
27
|
constructor(code: IntlErrorCode, originalMessage?: string);
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
|
-
export { IntlError, IntlErrorCode };
|
|
31
30
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","names":[],"sources":["../../../src/core/errors.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":[],"sources":["../../../src/core/errors.ts"],"mappings":";;;;;;;;oBAOY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;qBASW,kBAAkB;WACb,MAAM;WACN;EAEhB,YAAY,MAAM,eAAe"}
|
|
@@ -11,7 +11,6 @@ import { hasLocale as hasLocale$1 } from "use-intl";
|
|
|
11
11
|
* if (hasLocale(['en', 'fr'], requested)) { … }
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
declare const hasLocale: typeof hasLocale$1;
|
|
14
|
+
export declare const hasLocale: typeof hasLocale$1;
|
|
15
15
|
//#endregion
|
|
16
|
-
export { hasLocale };
|
|
17
16
|
//# sourceMappingURL=hasLocale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasLocale.d.ts","names":[],"sources":["../../../src/core/hasLocale.ts"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"hasLocale.d.ts","names":[],"sources":["../../../src/core/hasLocale.ts"],"mappings":";;;;;;;;;;;;;qBAca,kBAAkB"}
|
|
@@ -7,7 +7,6 @@ import { initializeConfig as initializeConfig$1 } from "use-intl";
|
|
|
7
7
|
* `formats` are not consumed at runtime (content comes from compiled
|
|
8
8
|
* dictionaries) but the shape is preserved so callers keep type-checking.
|
|
9
9
|
*/
|
|
10
|
-
declare const initializeConfig: typeof initializeConfig$1;
|
|
10
|
+
export declare const initializeConfig: typeof initializeConfig$1;
|
|
11
11
|
//#endregion
|
|
12
|
-
export { initializeConfig };
|
|
13
12
|
//# sourceMappingURL=initializeConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializeConfig.d.ts","names":[],"sources":["../../../src/core/initializeConfig.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"initializeConfig.d.ts","names":[],"sources":["../../../src/core/initializeConfig.ts"],"mappings":";;;;;;;;;qBASa,yBAAyB"}
|
|
@@ -15,7 +15,7 @@ import { intlayer } from "vite-intlayer";
|
|
|
15
15
|
* });
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
declare const useIntlVitePlugin: (options?: Parameters<typeof intlayer>[0]) => PluginOption[];
|
|
18
|
+
export declare const useIntlVitePlugin: (options?: Parameters<typeof intlayer>[0]) => PluginOption[];
|
|
19
19
|
//#endregion
|
|
20
|
-
export { useIntlVitePlugin as default
|
|
20
|
+
export { useIntlVitePlugin as default };
|
|
21
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugin/index.ts"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugin/index.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAuBa,oBAAiB,UAClB,kBAAkB,iBAC3B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createFormatter } from "use-intl";
|
|
2
2
|
//#region src/shared/intlFormatter.d.ts
|
|
3
3
|
/** The formatter object shape exposed by use-intl. */
|
|
4
|
-
type Formatter = ReturnType<typeof createFormatter>;
|
|
4
|
+
export type Formatter = ReturnType<typeof createFormatter>;
|
|
5
5
|
/**
|
|
6
6
|
* Builds a use-intl compatible formatter backed by the native `Intl.*` APIs
|
|
7
7
|
* for the given locale.
|
|
@@ -12,7 +12,6 @@ type Formatter = ReturnType<typeof createFormatter>;
|
|
|
12
12
|
* @returns A formatter exposing `dateTime`, `number`, `dateTimeRange`,
|
|
13
13
|
* `relativeTime`, `list`, and `displayName`.
|
|
14
14
|
*/
|
|
15
|
-
declare const buildIntlFormatter: (locale: string) => Formatter;
|
|
15
|
+
export declare const buildIntlFormatter: (locale: string) => Formatter;
|
|
16
16
|
//#endregion
|
|
17
|
-
export { Formatter, buildIntlFormatter };
|
|
18
17
|
//# sourceMappingURL=intlFormatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlFormatter.d.ts","names":[],"sources":["../../../src/shared/intlFormatter.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"intlFormatter.d.ts","names":[],"sources":["../../../src/shared/intlFormatter.ts"],"mappings":";;;YAGY,YAAY,kBAAkB;;;;;;;;;;;qBA0B7B,qBAAkB,mBAAqB"}
|
|
@@ -3,9 +3,9 @@ import { ReactNode } from "react";
|
|
|
3
3
|
import { MessageValues, navigatePath } from "@intlayer/core/messageFormat";
|
|
4
4
|
//#region src/shared/namespaceTranslator.d.ts
|
|
5
5
|
/** Chunk renderer used by `t.rich()` — maps tag children to a React node. */
|
|
6
|
-
type RichChunkRenderer = (chunks: ReactNode) => ReactNode;
|
|
6
|
+
export type RichChunkRenderer = (chunks: ReactNode) => ReactNode;
|
|
7
7
|
/** Chunk renderer used by `t.markup()` — maps tag children to a string. */
|
|
8
|
-
type MarkupChunkRenderer = (chunks: string) => string;
|
|
8
|
+
export type MarkupChunkRenderer = (chunks: string) => string;
|
|
9
9
|
/**
|
|
10
10
|
* The untyped runtime translator shared by `useTranslations` (React hook) and
|
|
11
11
|
* `createTranslator` (non-React core).
|
|
@@ -22,7 +22,7 @@ type MarkupChunkRenderer = (chunks: string) => string;
|
|
|
22
22
|
* @param namespace - Optional dictionary key, optionally with a nested scope.
|
|
23
23
|
* @returns A translate function augmented with `has`, `raw`, `rich`, `markup`.
|
|
24
24
|
*/
|
|
25
|
-
declare const createNamespaceTranslator: (locale: LocalesValues, namespace?: string) => ((key: string, values?: MessageValues) => string) & {
|
|
25
|
+
export declare const createNamespaceTranslator: (locale: LocalesValues, namespace?: string) => ((key: string, values?: MessageValues) => string) & {
|
|
26
26
|
/** Returns `true` if the given key exists in the namespace. */
|
|
27
27
|
has: (key: string) => boolean;
|
|
28
28
|
/** Returns the raw unprocessed content for the given key. */
|
|
@@ -50,7 +50,7 @@ declare const createNamespaceTranslator: (locale: LocalesValues, namespace?: str
|
|
|
50
50
|
* (`useTranslations('about.counter')` → content of `about`, prefix `counter`).
|
|
51
51
|
* @returns A translate function augmented with `has`, `raw`, `rich`, `markup`.
|
|
52
52
|
*/
|
|
53
|
-
declare const createDictionaryTranslator: (locale: LocalesValues, content: unknown, namespacePrefix?: string) => ((key: string, values?: MessageValues) => string) & {
|
|
53
|
+
export declare const createDictionaryTranslator: (locale: LocalesValues, content: unknown, namespacePrefix?: string) => ((key: string, values?: MessageValues) => string) & {
|
|
54
54
|
/** Returns `true` if the given key exists in the namespace. */
|
|
55
55
|
has: (key: string) => boolean;
|
|
56
56
|
/** Returns the raw unprocessed content for the given key. */
|
|
@@ -66,7 +66,7 @@ declare const createDictionaryTranslator: (locale: LocalesValues, content: unkno
|
|
|
66
66
|
*/
|
|
67
67
|
markup: (key: string, values?: Record<string, unknown>) => string;
|
|
68
68
|
};
|
|
69
|
-
type CompatTranslator = ReturnType<typeof createNamespaceTranslator>;
|
|
69
|
+
export type CompatTranslator = ReturnType<typeof createNamespaceTranslator>;
|
|
70
70
|
//#endregion
|
|
71
|
-
export {
|
|
71
|
+
export { navigatePath };
|
|
72
72
|
//# sourceMappingURL=namespaceTranslator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespaceTranslator.d.ts","names":[],"sources":["../../../src/shared/namespaceTranslator.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"namespaceTranslator.d.ts","names":[],"sources":["../../../src/shared/namespaceTranslator.tsx"],"mappings":";;;;;YAkBY,qBAAqB,QAAQ,cAAc;;YAG3C,uBAAuB;;;;;;;;;;;;;;;;;qBA0EtB,4BAAyB,QAC5B,eAAa,yBACH,aAgHY,SAAW;;EAK5B,MAAA;;EAGA,MAAA;;;;;EAMC,OAAA,aAAM,SAAW,4BAA0B;;;;;EAWzC,SAAA,aAAM,SAAW;;;;;;;;;;;;;;qBA/DtB,6BAA0B,QAC7B,eAAa,kBACL,+BACQ,aAmCM,SAAW;;EAK5B,MAAA;;EAGA,MAAA;;;;;EAMC,OAAA,aAAM,SAAW,4BAA0B;;;;;EAWzC,SAAA,aAAM,SAAW;;YASvB,mBAAmB,kBAAkB"}
|
|
@@ -8,18 +8,18 @@ import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
|
8
8
|
* The interpreter-resolved content type at dot-path `P` of dictionary `N` —
|
|
9
9
|
* the same type strength as the base `useIntlayer` hook.
|
|
10
10
|
*/
|
|
11
|
-
type ContentAtPath<N extends DictionaryKeys, P> = GetNestingResult<N, P>;
|
|
11
|
+
export type ContentAtPath<N extends DictionaryKeys, P> = GetNestingResult<N, P>;
|
|
12
12
|
/**
|
|
13
13
|
* The value returned by `t()` for key `P` of dictionary `N`: string literals
|
|
14
14
|
* declared in the dictionary keep their literal type (matching the strength of
|
|
15
15
|
* `useIntlayer`), every other node resolves to `string` at runtime.
|
|
16
16
|
*/
|
|
17
|
-
type TranslatedValue<N extends DictionaryKeys, P> = ContentAtPath<N, P> extends string ? ContentAtPath<N, P> : string;
|
|
17
|
+
export type TranslatedValue<N extends DictionaryKeys, P> = ContentAtPath<N, P> extends string ? ContentAtPath<N, P> : string;
|
|
18
18
|
/**
|
|
19
19
|
* The dot-paths of dictionary `D` relative to the nested namespace scope
|
|
20
20
|
* `Prefix` (`useTranslations('about.counter')` → paths under `about.counter`).
|
|
21
21
|
*/
|
|
22
|
-
type ScopedDotPaths<D extends DictionaryKeys, Prefix extends string> = ValidDotPathsFor<D> extends (infer AllPaths) ? AllPaths extends `${Prefix}.${infer RelativePath}` ? RelativePath : never : never;
|
|
22
|
+
export type ScopedDotPaths<D extends DictionaryKeys, Prefix extends string> = ValidDotPathsFor<D> extends (infer AllPaths) ? AllPaths extends `${Prefix}.${infer RelativePath}` ? RelativePath : never : never;
|
|
23
23
|
/**
|
|
24
24
|
* The translation function returned for a bare dictionary key namespace.
|
|
25
25
|
*
|
|
@@ -30,7 +30,7 @@ type ScopedDotPaths<D extends DictionaryKeys, Prefix extends string> = ValidDotP
|
|
|
30
30
|
* - `rich(key, values)` — resolves `<tag>chunks</tag>` markup to React nodes.
|
|
31
31
|
* - `markup(key, values)` — resolves `<tag>chunks</tag>` markup to a string.
|
|
32
32
|
*/
|
|
33
|
-
type TranslateFunction<N extends DictionaryKeys> = {
|
|
33
|
+
export type TranslateFunction<N extends DictionaryKeys> = {
|
|
34
34
|
/** Translate a key to a string, with optional ICU interpolation params. */
|
|
35
35
|
<P extends ValidDotPathsFor<N>>(key: P, params?: Record<string, unknown>): TranslatedValue<N, P>;
|
|
36
36
|
/** Returns `true` if the given key exists in the namespace. */
|
|
@@ -47,7 +47,7 @@ type TranslateFunction<N extends DictionaryKeys> = {
|
|
|
47
47
|
* namespace: keys are relative dot-paths under the scope, and return types are
|
|
48
48
|
* resolved against the absolute path in the dictionary.
|
|
49
49
|
*/
|
|
50
|
-
type ScopedTranslateFunction<D extends DictionaryKeys, Prefix extends string> = {
|
|
50
|
+
export type ScopedTranslateFunction<D extends DictionaryKeys, Prefix extends string> = {
|
|
51
51
|
/** Translate a scoped key to a string, with optional ICU interpolation params. */
|
|
52
52
|
<P extends ScopedDotPaths<D, Prefix>>(key: P, params?: Record<string, unknown>): TranslatedValue<D, `${Prefix}.${P}`>;
|
|
53
53
|
/** Returns `true` if the given key exists in the scoped namespace. */
|
|
@@ -65,9 +65,9 @@ type ScopedTranslateFunction<D extends DictionaryKeys, Prefix extends string> =
|
|
|
65
65
|
* `'dictionary.scope'` namespace is split at the first dot and typed
|
|
66
66
|
* relative to the scope, anything else falls back to loose typing.
|
|
67
67
|
*/
|
|
68
|
-
type TranslateFunctionForNamespace<N extends string> = N extends DictionaryKeys ? TranslateFunction<N> : N extends `${infer D extends DictionaryKeys & string}.${infer Prefix}` ? ScopedTranslateFunction<D, Prefix> : LooseTranslateFunction;
|
|
68
|
+
export type TranslateFunctionForNamespace<N extends string> = N extends DictionaryKeys ? TranslateFunction<N> : N extends `${infer D extends DictionaryKeys & string}.${infer Prefix}` ? ScopedTranslateFunction<D, Prefix> : LooseTranslateFunction;
|
|
69
69
|
/** Loosely-typed function returned for untyped namespaces (root scope). */
|
|
70
|
-
type LooseTranslateFunction = {
|
|
70
|
+
export type LooseTranslateFunction = {
|
|
71
71
|
(key: string, params?: Record<string, unknown>): string;
|
|
72
72
|
has(key: string): boolean;
|
|
73
73
|
raw(key: string): unknown;
|
|
@@ -75,5 +75,4 @@ type LooseTranslateFunction = {
|
|
|
75
75
|
markup(key: string, values?: Record<string, MarkupChunkRenderer | string | number>): string;
|
|
76
76
|
};
|
|
77
77
|
//#endregion
|
|
78
|
-
export { ContentAtPath, LooseTranslateFunction, ScopedDotPaths, ScopedTranslateFunction, TranslateFunction, TranslateFunctionForNamespace, TranslatedValue };
|
|
79
78
|
//# sourceMappingURL=translateFunctionTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translateFunctionTypes.d.ts","names":[],"sources":["../../../src/shared/translateFunctionTypes.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"translateFunctionTypes.d.ts","names":[],"sources":["../../../src/shared/translateFunctionTypes.ts"],"mappings":";;;;;;;;;;YAaY,cAAc,UAAU,gBAAgB,KAAK,iBAAiB,GAAG;;;;;;YAOjE,gBAAgB,UAAU,gBAAgB,KACpD,cAAc,GAAG,oBAAoB,cAAc,GAAG;;;;;YAM5C,eAAe,UAAU,gBAAgB,yBACnD,iBAAiB,kBAAiB,YAC9B,oBAAoB,gBAAgB,iBAClC;;;;;;;;;;;YAcI,kBAAkB,UAAU;;GAErC,UAAU,iBAAiB,IAC1B,KAAK,GACL,SAAS,0BACR,gBAAgB,GAAG;;EAEtB,IAAI,UAAU,iBAAiB,IAAI,KAAK;;EAExC,IAAI,UAAU,iBAAiB,IAAI,KAAK,IAAI,cAAc,GAAG;;EAE7D,KAAK,UAAU,iBAAiB,IAC9B,KAAK,GACL,SAAS,eAAe,oBAAoB,aAC3C;;EAEH,OAAO,UAAU,iBAAiB,IAChC,KAAK,GACL,SAAS,eAAe;;;;;;;YAShB,wBACV,UAAU,gBACV;;GAGC,UAAU,eAAe,GAAG,SAC3B,KAAK,GACL,SAAS,0BACR,gBAAgB,MAAM,UAAU;;EAEnC,IAAI,UAAU,eAAe,GAAG,SAAS,KAAK;;EAE9C,IAAI,UAAU,eAAe,GAAG,SAC9B,KAAK,IACJ,cAAc,MAAM,UAAU;;EAEjC,KAAK,UAAU,eAAe,GAAG,SAC/B,KAAK,GACL,SAAS,eAAe,oBAAoB,aAC3C;;EAEH,OAAO,UAAU,eAAe,GAAG,SACjC,KAAK,GACL,SAAS,eAAe;;;;;;;;YAUhB,8BAA8B,oBACxC,UAAU,iBACN,kBAAkB,KAClB,mBAAmB,UAAU,iCAAiC,WAC5D,wBAAwB,GAAG,UAC3B;;YAGI;GACT,aAAa,SAAS;EACvB,IAAI;EACJ,IAAI;EACJ,KACE,aACA,SAAS,eAAe,oBAAoB,aAC3C;EACH,OACE,aACA,SAAS,eAAe"}
|
|
@@ -26,7 +26,6 @@ type UseDictionary = {
|
|
|
26
26
|
* import _abc from '.intlayer/dictionaries/about.json' with { type: 'json' };
|
|
27
27
|
* const t = useDictionary(_abc);
|
|
28
28
|
*/
|
|
29
|
-
declare const useDictionary: UseDictionary;
|
|
29
|
+
export declare const useDictionary: UseDictionary;
|
|
30
30
|
//#endregion
|
|
31
|
-
export { useDictionary };
|
|
32
31
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../src/useDictionary.ts"],"mappings":";;;;;;;;;KAuBK;GACF,UAAU,YACT,YAAY,IACX,kBAAkB,WAAW;GAC/B,UAAU,YAAY,uBACrB,YAAY,GACZ,iBAAiB,SAChB,wBAAwB,WAAW,gBAAgB;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../src/useDictionary.ts"],"mappings":";;;;;;;;;KAuBK;GACF,UAAU,YACT,YAAY,IACX,kBAAkB,WAAW;GAC/B,UAAU,YAAY,uBACrB,YAAY,GACZ,iBAAiB,SAChB,wBAAwB,WAAW,gBAAgB;;;;;;;;;;;;;;;;;qBAkB3C,eAYP"}
|
|
@@ -17,7 +17,6 @@ type UseDictionaryDynamic = {
|
|
|
17
17
|
* Counterpart to {@link useDictionary} for dictionaries imported lazily per
|
|
18
18
|
* locale. Used internally by the build-time optimization.
|
|
19
19
|
*/
|
|
20
|
-
declare const useDictionaryDynamic: UseDictionaryDynamic;
|
|
20
|
+
export declare const useDictionaryDynamic: UseDictionaryDynamic;
|
|
21
21
|
//#endregion
|
|
22
|
-
export { useDictionaryDynamic };
|
|
23
22
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../src/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;KAwBK;GACF,UAAU,YAAY,UAAU,gBAC/B,mBAAmB,0BAA0B,QAAQ,KACrD,KAAK,IACJ,kBAAkB;GACpB,UAAU,YAAY,UAAU,gBAAgB,uBAC/C,mBAAmB,0BAA0B,QAAQ,KACrD,KAAK,GACL,iBAAiB,SAChB,wBAAwB,GAAG;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../src/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;KAwBK;GACF,UAAU,YAAY,UAAU,gBAC/B,mBAAmB,0BAA0B,QAAQ,KACrD,KAAK,IACJ,kBAAkB;GACpB,UAAU,YAAY,UAAU,gBAAgB,uBAC/C,mBAAmB,0BAA0B,QAAQ,KACrD,KAAK,GACL,iBAAiB,SAChB,wBAAwB,GAAG;;;;;;;;qBASnB,sBAgBP"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/use-intl",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "use-intl API adapter for intlayer — useTranslations, useLocale, useFormatter, IntlProvider, createTranslator backed by react-intlayer",
|
|
6
6
|
"keywords": [
|
|
@@ -89,26 +89,26 @@
|
|
|
89
89
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@intlayer/config": "9.
|
|
93
|
-
"@intlayer/core": "9.
|
|
94
|
-
"@intlayer/dictionaries-entry": "9.
|
|
95
|
-
"@intlayer/engine": "9.
|
|
96
|
-
"@intlayer/types": "9.
|
|
97
|
-
"react-intlayer": "9.
|
|
98
|
-
"vite-intlayer": "9.
|
|
92
|
+
"@intlayer/config": "9.5.0",
|
|
93
|
+
"@intlayer/core": "9.5.0",
|
|
94
|
+
"@intlayer/dictionaries-entry": "9.5.0",
|
|
95
|
+
"@intlayer/engine": "9.5.0",
|
|
96
|
+
"@intlayer/types": "9.5.0",
|
|
97
|
+
"react-intlayer": "9.5.0",
|
|
98
|
+
"vite-intlayer": "9.5.0"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
|
-
"@types/node": "26.
|
|
101
|
+
"@types/node": "26.5.0",
|
|
102
102
|
"@types/react": "19.2.18",
|
|
103
103
|
"@utils/ts-config": "1.0.4",
|
|
104
104
|
"@utils/ts-config-types": "1.0.4",
|
|
105
105
|
"@utils/tsdown-config": "1.0.4",
|
|
106
106
|
"rimraf": "6.1.3",
|
|
107
|
-
"tsdown": "0.
|
|
107
|
+
"tsdown": "0.23.0",
|
|
108
108
|
"typescript": "7.0.2",
|
|
109
|
-
"use-intl": "4.
|
|
109
|
+
"use-intl": "4.14.2",
|
|
110
110
|
"vite": "8.2.2",
|
|
111
|
-
"vitest": "
|
|
111
|
+
"vitest": "5.0.0"
|
|
112
112
|
},
|
|
113
113
|
"peerDependencies": {
|
|
114
114
|
"react": ">=16.0.0",
|