@intlayer/next-intl 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/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/cjs/client/NextIntlClientProvider.cjs +28 -0
- package/dist/cjs/client/NextIntlClientProvider.cjs.map +1 -0
- package/dist/cjs/client/helpers.cjs +66 -0
- package/dist/cjs/client/helpers.cjs.map +1 -0
- package/dist/cjs/client/index.cjs +19 -0
- package/dist/cjs/client/useLocale.cjs +18 -0
- package/dist/cjs/client/useLocale.cjs.map +1 -0
- package/dist/cjs/client/useTranslations.cjs +39 -0
- package/dist/cjs/client/useTranslations.cjs.map +1 -0
- package/dist/cjs/createFormatter.cjs +59 -0
- package/dist/cjs/createFormatter.cjs.map +1 -0
- package/dist/cjs/createTranslator.cjs +111 -0
- package/dist/cjs/createTranslator.cjs.map +1 -0
- package/dist/cjs/getDictionary.cjs +45 -0
- package/dist/cjs/getDictionary.cjs.map +1 -0
- package/dist/cjs/getDictionaryDynamic.cjs +35 -0
- package/dist/cjs/getDictionaryDynamic.cjs.map +1 -0
- package/dist/cjs/getTranslationsDictionary.cjs +31 -0
- package/dist/cjs/getTranslationsDictionary.cjs.map +1 -0
- package/dist/cjs/getTranslationsDictionaryDynamic.cjs +27 -0
- package/dist/cjs/getTranslationsDictionaryDynamic.cjs.map +1 -0
- package/dist/cjs/hasLocale.cjs +25 -0
- package/dist/cjs/hasLocale.cjs.map +1 -0
- package/dist/cjs/index.cjs +23 -0
- package/dist/cjs/middleware.cjs +37 -0
- package/dist/cjs/middleware.cjs.map +1 -0
- package/dist/cjs/navigation/Link.cjs +30 -0
- package/dist/cjs/navigation/Link.cjs.map +1 -0
- package/dist/cjs/navigation/createNavigation.cjs +40 -0
- package/dist/cjs/navigation/createNavigation.cjs.map +1 -0
- package/dist/cjs/navigation/hooks.cjs +42 -0
- package/dist/cjs/navigation/hooks.cjs.map +1 -0
- package/dist/cjs/navigation/index.cjs +10 -0
- package/dist/cjs/navigation/localizeHref.cjs +26 -0
- package/dist/cjs/navigation/localizeHref.cjs.map +1 -0
- package/dist/cjs/package.cjs +122 -0
- package/dist/cjs/package.cjs.map +1 -0
- package/dist/cjs/plugin/index.cjs +163 -0
- package/dist/cjs/plugin/index.cjs.map +1 -0
- package/dist/cjs/routing.cjs +30 -0
- package/dist/cjs/routing.cjs.map +1 -0
- package/dist/cjs/server/getLocale.cjs +13 -0
- package/dist/cjs/server/getLocale.cjs.map +1 -0
- package/dist/cjs/server/getMessages.cjs +30 -0
- package/dist/cjs/server/getMessages.cjs.map +1 -0
- package/dist/cjs/server/getTranslations.cjs +45 -0
- package/dist/cjs/server/getTranslations.cjs.map +1 -0
- package/dist/cjs/server/helpers.cjs +28 -0
- package/dist/cjs/server/helpers.cjs.map +1 -0
- package/dist/cjs/server/index.cjs +18 -0
- package/dist/cjs/server/setLocale.cjs +38 -0
- package/dist/cjs/server/setLocale.cjs.map +1 -0
- package/dist/cjs/useDictionary.cjs +45 -0
- package/dist/cjs/useDictionary.cjs.map +1 -0
- package/dist/cjs/useDictionaryDynamic.cjs +37 -0
- package/dist/cjs/useDictionaryDynamic.cjs.map +1 -0
- package/dist/cjs/useTranslationsDictionary.cjs +37 -0
- package/dist/cjs/useTranslationsDictionary.cjs.map +1 -0
- package/dist/cjs/useTranslationsDictionaryDynamic.cjs +29 -0
- package/dist/cjs/useTranslationsDictionaryDynamic.cjs.map +1 -0
- package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
- package/dist/esm/client/NextIntlClientProvider.mjs +26 -0
- package/dist/esm/client/NextIntlClientProvider.mjs.map +1 -0
- package/dist/esm/client/helpers.mjs +59 -0
- package/dist/esm/client/helpers.mjs.map +1 -0
- package/dist/esm/client/index.mjs +8 -0
- package/dist/esm/client/useLocale.mjs +16 -0
- package/dist/esm/client/useLocale.mjs.map +1 -0
- package/dist/esm/client/useTranslations.mjs +37 -0
- package/dist/esm/client/useTranslations.mjs.map +1 -0
- package/dist/esm/createFormatter.mjs +57 -0
- package/dist/esm/createFormatter.mjs.map +1 -0
- package/dist/esm/createTranslator.mjs +108 -0
- package/dist/esm/createTranslator.mjs.map +1 -0
- package/dist/esm/getDictionary.mjs +43 -0
- package/dist/esm/getDictionary.mjs.map +1 -0
- package/dist/esm/getDictionaryDynamic.mjs +33 -0
- package/dist/esm/getDictionaryDynamic.mjs.map +1 -0
- package/dist/esm/getTranslationsDictionary.mjs +29 -0
- package/dist/esm/getTranslationsDictionary.mjs.map +1 -0
- package/dist/esm/getTranslationsDictionaryDynamic.mjs +25 -0
- package/dist/esm/getTranslationsDictionaryDynamic.mjs.map +1 -0
- package/dist/esm/hasLocale.mjs +23 -0
- package/dist/esm/hasLocale.mjs.map +1 -0
- package/dist/esm/index.mjs +10 -0
- package/dist/esm/middleware.mjs +34 -0
- package/dist/esm/middleware.mjs.map +1 -0
- package/dist/esm/navigation/Link.mjs +27 -0
- package/dist/esm/navigation/Link.mjs.map +1 -0
- package/dist/esm/navigation/createNavigation.mjs +37 -0
- package/dist/esm/navigation/createNavigation.mjs.map +1 -0
- package/dist/esm/navigation/hooks.mjs +39 -0
- package/dist/esm/navigation/hooks.mjs.map +1 -0
- package/dist/esm/navigation/index.mjs +5 -0
- package/dist/esm/navigation/localizeHref.mjs +24 -0
- package/dist/esm/navigation/localizeHref.mjs.map +1 -0
- package/dist/esm/package.mjs +119 -0
- package/dist/esm/package.mjs.map +1 -0
- package/dist/esm/plugin/index.mjs +159 -0
- package/dist/esm/plugin/index.mjs.map +1 -0
- package/dist/esm/routing.mjs +28 -0
- package/dist/esm/routing.mjs.map +1 -0
- package/dist/esm/server/getLocale.mjs +11 -0
- package/dist/esm/server/getLocale.mjs.map +1 -0
- package/dist/esm/server/getMessages.mjs +28 -0
- package/dist/esm/server/getMessages.mjs.map +1 -0
- package/dist/esm/server/getTranslations.mjs +44 -0
- package/dist/esm/server/getTranslations.mjs.map +1 -0
- package/dist/esm/server/helpers.mjs +25 -0
- package/dist/esm/server/helpers.mjs.map +1 -0
- package/dist/esm/server/index.mjs +9 -0
- package/dist/esm/server/setLocale.mjs +36 -0
- package/dist/esm/server/setLocale.mjs.map +1 -0
- package/dist/esm/useDictionary.mjs +43 -0
- package/dist/esm/useDictionary.mjs.map +1 -0
- package/dist/esm/useDictionaryDynamic.mjs +35 -0
- package/dist/esm/useDictionaryDynamic.mjs.map +1 -0
- package/dist/esm/useTranslationsDictionary.mjs +35 -0
- package/dist/esm/useTranslationsDictionary.mjs.map +1 -0
- package/dist/esm/useTranslationsDictionaryDynamic.mjs +27 -0
- package/dist/esm/useTranslationsDictionaryDynamic.mjs.map +1 -0
- package/dist/types/client/NextIntlClientProvider.d.ts +28 -0
- package/dist/types/client/NextIntlClientProvider.d.ts.map +1 -0
- package/dist/types/client/helpers.d.ts +45 -0
- package/dist/types/client/helpers.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +7 -0
- package/dist/types/client/useLocale.d.ts +10 -0
- package/dist/types/client/useLocale.d.ts.map +1 -0
- package/dist/types/client/useTranslations.d.ts +74 -0
- package/dist/types/client/useTranslations.d.ts.map +1 -0
- package/dist/types/createFormatter.d.ts +15 -0
- package/dist/types/createFormatter.d.ts.map +1 -0
- package/dist/types/createTranslator.d.ts +40 -0
- package/dist/types/createTranslator.d.ts.map +1 -0
- package/dist/types/getDictionary.d.ts +23 -0
- package/dist/types/getDictionary.d.ts.map +1 -0
- package/dist/types/getDictionaryDynamic.d.ts +15 -0
- package/dist/types/getDictionaryDynamic.d.ts.map +1 -0
- package/dist/types/getTranslationsDictionary.d.ts +15 -0
- package/dist/types/getTranslationsDictionary.d.ts.map +1 -0
- package/dist/types/getTranslationsDictionaryDynamic.d.ts +12 -0
- package/dist/types/getTranslationsDictionaryDynamic.d.ts.map +1 -0
- package/dist/types/hasLocale.d.ts +20 -0
- package/dist/types/hasLocale.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/middleware.d.ts +22 -0
- package/dist/types/middleware.d.ts.map +1 -0
- package/dist/types/navigation/Link.d.ts +29 -0
- package/dist/types/navigation/Link.d.ts.map +1 -0
- package/dist/types/navigation/createNavigation.d.ts +21 -0
- package/dist/types/navigation/createNavigation.d.ts.map +1 -0
- package/dist/types/navigation/hooks.d.ts +33 -0
- package/dist/types/navigation/hooks.d.ts.map +1 -0
- package/dist/types/navigation/index.d.ts +5 -0
- package/dist/types/navigation/localizeHref.d.ts +23 -0
- package/dist/types/navigation/localizeHref.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/routing.d.ts +28 -0
- package/dist/types/routing.d.ts.map +1 -0
- package/dist/types/server/getLocale.d.ts +10 -0
- package/dist/types/server/getLocale.d.ts.map +1 -0
- package/dist/types/server/getMessages.d.ts +22 -0
- package/dist/types/server/getMessages.d.ts.map +1 -0
- package/dist/types/server/getTranslations.d.ts +85 -0
- package/dist/types/server/getTranslations.d.ts.map +1 -0
- package/dist/types/server/helpers.d.ts +21 -0
- package/dist/types/server/helpers.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +8 -0
- package/dist/types/server/setLocale.d.ts +21 -0
- package/dist/types/server/setLocale.d.ts.map +1 -0
- package/dist/types/useDictionary.d.ts +22 -0
- package/dist/types/useDictionary.d.ts.map +1 -0
- package/dist/types/useDictionaryDynamic.d.ts +15 -0
- package/dist/types/useDictionaryDynamic.d.ts.map +1 -0
- package/dist/types/useTranslationsDictionary.d.ts +19 -0
- package/dist/types/useTranslationsDictionary.d.ts.map +1 -0
- package/dist/types/useTranslationsDictionaryDynamic.d.ts +12 -0
- package/dist/types/useTranslationsDictionaryDynamic.d.ts.map +1 -0
- package/package.json +142 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { MessageValues } from "@intlayer/core/messageFormat";
|
|
4
|
+
|
|
5
|
+
//#region src/createTranslator.d.ts
|
|
6
|
+
/** Chunk renderer used by `t.rich()` — maps tag children to a React node. */
|
|
7
|
+
type RichChunkRenderer = (chunks: ReactNode) => ReactNode;
|
|
8
|
+
/** Chunk renderer used by `t.markup()` — maps tag children to a string. */
|
|
9
|
+
type MarkupChunkRenderer = (chunks: string) => string;
|
|
10
|
+
declare const navigatePath: (objectValue: unknown, path: string) => unknown;
|
|
11
|
+
/**
|
|
12
|
+
* The untyped runtime translator shared by `useTranslations` (client) and
|
|
13
|
+
* `getTranslations` (server).
|
|
14
|
+
*
|
|
15
|
+
* Behaviour matches next-intl:
|
|
16
|
+
* - namespace `'about'` → keys resolved inside the `about` dictionary
|
|
17
|
+
* - namespace `'about.counter'` → dictionary `about`, key prefix `counter`
|
|
18
|
+
* - no namespace → the first segment of each key is the dictionary key
|
|
19
|
+
* - messages support ICU syntax (plural, select, `#`, formatted arguments)
|
|
20
|
+
* - `t.rich` / `t.markup` map `<tag>chunks</tag>` through the provided
|
|
21
|
+
* renderers; `t.raw` returns the raw value; `t.has` checks existence
|
|
22
|
+
*/
|
|
23
|
+
declare const createTranslator: (locale: LocalesValues, namespace?: string) => ((key: string, values?: MessageValues) => string) & {
|
|
24
|
+
/** Returns `true` if the given key exists in the namespace. */has: (key: string) => boolean; /** Returns the raw unprocessed content for the given key. */
|
|
25
|
+
raw: (key: string) => unknown;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves a message containing `<tag>chunks</tag>` markup, mapping each
|
|
28
|
+
* tag through the matching renderer in `values`.
|
|
29
|
+
*/
|
|
30
|
+
rich: (key: string, values?: Record<string, unknown>) => ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Resolves a message containing `<tag>chunks</tag>` markup into a string,
|
|
33
|
+
* mapping each tag through the matching string renderer in `values`.
|
|
34
|
+
*/
|
|
35
|
+
markup: (key: string, values?: Record<string, unknown>) => string;
|
|
36
|
+
};
|
|
37
|
+
type CompatTranslator = ReturnType<typeof createTranslator>;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { CompatTranslator, MarkupChunkRenderer, RichChunkRenderer, createTranslator, navigatePath };
|
|
40
|
+
//# sourceMappingURL=createTranslator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTranslator.d.ts","names":[],"sources":["../../src/createTranslator.tsx"],"mappings":";;;;;;KAcY,iBAAA,IAAqB,MAAA,EAAQ,SAAA,KAAc,SAAA;AAAvD;AAAA,KAGY,mBAAA,IAAuB,MAAA;AAAA,cAEtB,YAAA,GAAgB,WAAA,WAAsB,IAAA;;;;;;;AAFnD;;;;;AAEA;cAqFa,gBAAA,GAAoB,MAAA,EAAQ,aAAA,EAAe,SAAA,gBAAkB,GAAA,UAsC1C,MAAA,GAAW,aAAA;gGA3HoB;;EA2J9D;;;;sBAlBqB,MAAA,GAAW,MAAA,sBAA0B,SAAA;EAAA;;;;wBAWnC,MAAA,GAAW,MAAA;AAAA;AAAA,KASvB,gBAAA,GAAmB,UAAA,QAAkB,gBAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
2
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
|
+
|
|
4
|
+
//#region src/getDictionary.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Dictionary-accepting variant of `getTranslations`.
|
|
7
|
+
*
|
|
8
|
+
* Used internally by the SWC optimization: instead of looking up the dictionary
|
|
9
|
+
* at runtime by key, the SWC plugin pre-imports the dictionary JSON at build time
|
|
10
|
+
* and passes it directly here. This enables tree-shaking of unused locale content.
|
|
11
|
+
*
|
|
12
|
+
* Runs on the server, where next-intl apps do not mount an `IntlayerServerProvider`.
|
|
13
|
+
* The request locale therefore cannot be read from a server context and is resolved
|
|
14
|
+
* asynchronously from the cookie/header via `getLocale()`. `getTranslations` is always
|
|
15
|
+
* awaited, so an async resolver is a drop-in replacement.
|
|
16
|
+
*/
|
|
17
|
+
declare const getDictionary: <T extends Dictionary>(dictionary: T, namespacePrefix?: string) => Promise<(<P extends ValidDotPathsFor<any>>(lookup: P, params?: Record<string, unknown>) => string) & {
|
|
18
|
+
has: <P extends ValidDotPathsFor<any>>(lookup: P) => boolean;
|
|
19
|
+
raw: <P extends ValidDotPathsFor<any>>(lookup: P) => unknown;
|
|
20
|
+
}>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { getDictionary };
|
|
23
|
+
//# sourceMappingURL=getDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../src/getDictionary.ts"],"mappings":";;;;;;AAmCA;;;;;;;;;;cAAa,aAAA,aAAiC,UAAA,EAC5C,UAAA,EAAY,CAAA,EACZ,eAAA,cAAwB,OAAA,aASX,gBAAA,OAAqB,MAAA,EACtB,CAAA,EAAC,MAAA,GACA,MAAA;kBAUO,gBAAA,OAAqB,MAAA,EAAU,CAAA;kBAE/B,gBAAA,OAAqB,MAAA,EAAU,CAAA;AAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
3
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
+
|
|
5
|
+
//#region src/getDictionaryDynamic.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Dynamic dictionary-accepting variant of `getTranslations`.
|
|
8
|
+
*/
|
|
9
|
+
declare const getDictionaryDynamic: <const T extends Dictionary, const K extends string>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, namespacePrefix?: string) => Promise<(<P extends ValidDotPathsFor<any>>(lookup: P, params?: Record<string, unknown>) => string) & {
|
|
10
|
+
has: <P extends ValidDotPathsFor<any>>(lookup: P) => boolean;
|
|
11
|
+
raw: <P extends ValidDotPathsFor<any>>(lookup: P) => unknown;
|
|
12
|
+
}>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getDictionaryDynamic };
|
|
15
|
+
//# sourceMappingURL=getDictionaryDynamic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDictionaryDynamic.d.ts","names":[],"sources":["../../src/getDictionaryDynamic.ts"],"mappings":";;;;;;;AAyBA;cAAa,oBAAA,mBACK,UAAA,0BAGhB,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,eAAA,cAAwB,OAAA,aAWX,gBAAA,OAAqB,MAAA,EACtB,CAAA,EAAC,MAAA,GACA,MAAA;kBAUO,gBAAA,OAAqB,MAAA,EAAU,CAAA;kBAE/B,gBAAA,OAAqB,MAAA,EAAU,CAAA;AAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
2
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
|
+
|
|
4
|
+
//#region src/getTranslationsDictionary.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Dictionary-accepting variant of `getTranslations`.
|
|
7
|
+
*
|
|
8
|
+
* Used internally by the SWC optimization: instead of looking up the dictionary
|
|
9
|
+
* at runtime by key, the SWC plugin pre-imports the dictionary JSON at build time
|
|
10
|
+
* and passes it directly here. This enables tree-shaking of unused locale content.
|
|
11
|
+
*/
|
|
12
|
+
declare const getTranslationsDictionary: <T extends Dictionary>(dictionary: T, namespacePrefix?: string) => Promise<(<P extends ValidDotPathsFor<any>>(lookup: P, params?: Record<string, unknown>) => string)>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getTranslationsDictionary };
|
|
15
|
+
//# sourceMappingURL=getTranslationsDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTranslationsDictionary.d.ts","names":[],"sources":["../../src/getTranslationsDictionary.ts"],"mappings":";;;;;;AAWA;;;;;cAAa,yBAAA,aAA6C,UAAA,EACxD,UAAA,EAAY,CAAA,EACZ,eAAA,cAAwB,OAAA,aAIN,gBAAA,OAAqB,MAAA,EAC7B,CAAA,EAAC,MAAA,GACA,MAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
3
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
+
|
|
5
|
+
//#region src/getTranslationsDictionaryDynamic.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Dynamic dictionary-accepting variant of `getTranslations`.
|
|
8
|
+
*/
|
|
9
|
+
declare const getTranslationsDictionaryDynamic: <const T extends Dictionary, const K extends string>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, namespacePrefix?: string) => Promise<(<P extends ValidDotPathsFor<any>>(lookup: P, params?: Record<string, unknown>) => string)>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { getTranslationsDictionaryDynamic };
|
|
12
|
+
//# sourceMappingURL=getTranslationsDictionaryDynamic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTranslationsDictionaryDynamic.d.ts","names":[],"sources":["../../src/getTranslationsDictionaryDynamic.ts"],"mappings":";;;;;;;AAQA;cAAa,gCAAA,mBACK,UAAA,0BAGhB,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,eAAA,cAAwB,OAAA,aAON,gBAAA,OAAqB,MAAA,EAC7B,CAAA,EAAC,MAAA,GACA,MAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { hasLocale as hasLocale$1 } from "next-intl";
|
|
2
|
+
|
|
3
|
+
//#region src/hasLocale.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in for next-intl's `hasLocale`.
|
|
6
|
+
*
|
|
7
|
+
* Checks that a locale candidate is part of the given locales list (or, when
|
|
8
|
+
* the list is read from routing, the locales configured in intlayer).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { routing } from '@/i18n/routing';
|
|
13
|
+
*
|
|
14
|
+
* if (hasLocale(routing.locales, requested)) { … }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare const hasLocale: typeof hasLocale$1;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { hasLocale };
|
|
20
|
+
//# sourceMappingURL=hasLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasLocale.d.ts","names":[],"sources":["../../src/hasLocale.ts"],"mappings":";;;;;AAgBA;;;;;;;;;;;cAAa,SAAA,SAAkB,WAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NextIntlClientProvider, NextIntlClientProviderProps } from "./client/NextIntlClientProvider.js";
|
|
2
|
+
import { IntlProvider, useExtracted, useFormatter, useMessages, useNow, useTimeZone } from "./client/helpers.js";
|
|
3
|
+
import { useDictionary } from "./useDictionary.js";
|
|
4
|
+
import { useDictionaryDynamic } from "./useDictionaryDynamic.js";
|
|
5
|
+
import { useLocale } from "./client/useLocale.js";
|
|
6
|
+
import { useTranslations } from "./client/useTranslations.js";
|
|
7
|
+
import { hasLocale } from "./hasLocale.js";
|
|
8
|
+
import { Routing, defineRouting } from "./routing.js";
|
|
9
|
+
export { IntlProvider, NextIntlClientProvider, NextIntlClientProviderProps, type Routing, defineRouting, hasLocale, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import _createMiddleware from "next-intl/middleware";
|
|
2
|
+
|
|
3
|
+
//#region src/middleware.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in replacement for next-intl's `createMiddleware`.
|
|
6
|
+
*
|
|
7
|
+
* Returns Intlayer's proxy/middleware, which handles locale detection and
|
|
8
|
+
* routing from the Intlayer configuration. The `routing` argument is accepted
|
|
9
|
+
* for API compatibility but ignored — locales come from `intlayer.config`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* // proxy.ts (or middleware.ts on Next <= 15)
|
|
14
|
+
* import createMiddleware from 'next-intl/middleware';
|
|
15
|
+
* export default createMiddleware(routing);
|
|
16
|
+
* export const config = { matcher: ['/((?!api|_next|.*\\..*).*)'] };
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare const createMiddleware: typeof _createMiddleware;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { createMiddleware, createMiddleware as default };
|
|
22
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","names":[],"sources":["../../src/middleware.ts"],"mappings":";;;;;AAmBA;;;;;;;;;;;;;cAAa,gBAAA,SAAyB,iBAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NextIntlHref } from "./localizeHref.js";
|
|
2
|
+
import * as _$react from "react";
|
|
3
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
4
|
+
import * as _$next_link0 from "next/link";
|
|
5
|
+
import NextLink from "next/link";
|
|
6
|
+
|
|
7
|
+
//#region src/navigation/Link.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Props for the compat `Link`: identical to `next/link` except `href` accepts a
|
|
10
|
+
* `next-intl` href and an optional `locale` overrides the current one.
|
|
11
|
+
*/
|
|
12
|
+
type LinkProps = Omit<ComponentPropsWithoutRef<typeof NextLink>, 'href' | 'locale'> & {
|
|
13
|
+
href: NextIntlHref;
|
|
14
|
+
locale?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Drop-in for the `Link` returned by next-intl's `createNavigation`. Prefixes
|
|
18
|
+
* `href` with the active locale (or the `locale` prop) before delegating to
|
|
19
|
+
* `next/link`.
|
|
20
|
+
*/
|
|
21
|
+
declare const Link: _$react.ForwardRefExoticComponent<Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
|
|
22
|
+
children?: React.ReactNode | undefined;
|
|
23
|
+
} & _$react.RefAttributes<HTMLAnchorElement>, "ref">, "href" | "locale"> & {
|
|
24
|
+
href: NextIntlHref;
|
|
25
|
+
locale?: string;
|
|
26
|
+
} & _$react.RefAttributes<HTMLAnchorElement>>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Link, LinkProps };
|
|
29
|
+
//# sourceMappingURL=Link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Link.d.ts","names":[],"sources":["../../../src/navigation/Link.tsx"],"mappings":";;;;;;;;;;;KAWY,SAAA,GAAY,IAAA,CACtB,wBAAA,QAAgC,QAAA;EAGhC,IAAA,EAAM,YAAA;EACN,MAAA;AAAA;;;;;;cAQW,IAAA,UAAI,yBAAA,CAAA,IAAA,CAAA,IAAA,CAAA,IAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,iBAAA,SAAA,YAAA,CAAA,SAAA,SAAA,YAAA,CAAA,SAAA;;;QATT,YAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createNavigation as createNavigation$1 } from "next-intl/navigation";
|
|
2
|
+
|
|
3
|
+
//#region src/navigation/createNavigation.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in replacement for next-intl's `createNavigation`.
|
|
6
|
+
*
|
|
7
|
+
* Returns locale-aware navigation APIs (`Link`, `usePathname`, `useRouter`,
|
|
8
|
+
* `getPathname`, `redirect`, `permanentRedirect`) backed by Intlayer's routing
|
|
9
|
+
* configuration. The `routing` argument is accepted for API compatibility;
|
|
10
|
+
* locales come from the Intlayer configuration.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* export const { Link, redirect, usePathname, useRouter, getPathname } =
|
|
15
|
+
* createNavigation();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare const createNavigation: typeof createNavigation$1;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { createNavigation, createNavigation as default };
|
|
21
|
+
//# sourceMappingURL=createNavigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNavigation.d.ts","names":[],"sources":["../../../src/navigation/createNavigation.ts"],"mappings":";;;;;AA6BA;;;;;;;;;;;;cAAa,gBAAA,SAAyB,kBAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NextIntlHref } from "./localizeHref.js";
|
|
2
|
+
import * as _$next_dist_shared_lib_app_router_context_shared_runtime0 from "next/dist/shared/lib/app-router-context.shared-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/navigation/hooks.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Options accepted by the locale-aware router methods: the standard Next.js
|
|
7
|
+
* navigate options plus an optional target `locale`.
|
|
8
|
+
*/
|
|
9
|
+
type NavigateOptions = {
|
|
10
|
+
locale?: string;
|
|
11
|
+
} & Record<string, unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Drop-in for the `usePathname` returned by next-intl's `createNavigation`.
|
|
14
|
+
* Returns the current pathname with the locale prefix stripped.
|
|
15
|
+
*/
|
|
16
|
+
declare const usePathname: () => string;
|
|
17
|
+
/**
|
|
18
|
+
* Drop-in for the `useRouter` returned by next-intl's `createNavigation`.
|
|
19
|
+
* Wraps the Next.js router so `push`/`replace`/`prefetch` localize their href
|
|
20
|
+
* (honouring an optional `locale` option) before navigating.
|
|
21
|
+
*/
|
|
22
|
+
declare const useRouter: () => {
|
|
23
|
+
push: (href: NextIntlHref, options?: NavigateOptions) => void;
|
|
24
|
+
replace: (href: NextIntlHref, options?: NavigateOptions) => void;
|
|
25
|
+
prefetch: (href: NextIntlHref, options?: NavigateOptions) => void;
|
|
26
|
+
back(): void;
|
|
27
|
+
forward(): void;
|
|
28
|
+
refresh(): void;
|
|
29
|
+
experimental_gesturePush?(href: string, options?: _$next_dist_shared_lib_app_router_context_shared_runtime0.NavigateOptions): void;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { usePathname, useRouter };
|
|
33
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","names":[],"sources":["../../../src/navigation/hooks.ts"],"mappings":";;;;;;;AAOiE;KAM5D,eAAA;EAAoB,MAAA;AAAA,IAAoB,MAAA;;AAM7C;;;cAAa,WAAA;;AAeb;;;;cAAa,SAAA;eASI,YAAA,EAAY,OAAA,GAAY,eAAA;kBAKrB,YAAA,EAAY,OAAA,GAAY,eAAA;mBAKvB,YAAA,EAAY,OAAA,GAAY,eAAA;;;;oDAAe,yDAAA,CAAA,eAAA;AAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NextIntlHref } from "./localizeHref.js";
|
|
2
|
+
import { Link, LinkProps } from "./Link.js";
|
|
3
|
+
import { createNavigation } from "./createNavigation.js";
|
|
4
|
+
import { usePathname, useRouter } from "./hooks.js";
|
|
5
|
+
export { Link, type LinkProps, type NextIntlHref, createNavigation, createNavigation as default, usePathname, useRouter };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/navigation/localizeHref.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A `next-intl` navigation href: either a pathname string or an object with a
|
|
4
|
+
* `pathname` and optional `query`. The `pathnames` (typed routes) feature is
|
|
5
|
+
* accepted for API compatibility but not interpolated.
|
|
6
|
+
*/
|
|
7
|
+
type NextIntlHref = string | {
|
|
8
|
+
pathname: string;
|
|
9
|
+
query?: Record<string, string | number | (string | number)[]>;
|
|
10
|
+
params?: Record<string, string | number | (string | number)[]>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Prefix a `next-intl` href with the given locale using Intlayer's
|
|
14
|
+
* `getLocalizedUrl`, preserving any query parameters.
|
|
15
|
+
*
|
|
16
|
+
* @param href - The target href (string or `{ pathname, query }`).
|
|
17
|
+
* @param locale - The locale to localize the href for.
|
|
18
|
+
* @returns The localized URL string.
|
|
19
|
+
*/
|
|
20
|
+
declare const localizeHref: (href: NextIntlHref, locale: string) => string;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { NextIntlHref, localizeHref };
|
|
23
|
+
//# sourceMappingURL=localizeHref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localizeHref.d.ts","names":[],"sources":["../../../src/navigation/localizeHref.ts"],"mappings":";;AAQA;;;;KAAY,YAAA;EAGN,QAAA;EACA,KAAA,GAAQ,MAAA;EACR,MAAA,GAAS,MAAA;AAAA;;;AAWf;;;;;;cAAa,YAAA,GAAgB,IAAA,EAAM,YAAA,EAAc,MAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NextConfig } from "next";
|
|
2
|
+
|
|
3
|
+
//#region src/plugin/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A Next.js plugin for next-intl compat that wraps next-intlayer's plugin
|
|
6
|
+
* and configures resolve aliases so `next-intl` imports are served by
|
|
7
|
+
* `@intlayer/next-intl`.
|
|
8
|
+
*/
|
|
9
|
+
declare const createNextIntlPlugin: (_i18nPath?: string) => (nextConfig?: NextConfig) => Promise<NextConfig>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { createNextIntlPlugin, createNextIntlPlugin as default };
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugin/index.ts"],"mappings":";;;;;AA0HA;;;cAAa,oBAAA,GAAwB,SAAA,eACrB,UAAA,GAAY,UAAA,KAAkB,OAAA,CAAQ,UAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
+
|
|
3
|
+
//#region src/routing.d.ts
|
|
4
|
+
type Routing = {
|
|
5
|
+
locales: LocalesValues[];
|
|
6
|
+
defaultLocale: LocalesValues;
|
|
7
|
+
localePrefix?: 'always' | 'as-needed' | 'never';
|
|
8
|
+
pathnames?: Record<string, string | Record<string, string>>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Drop-in replacement for next-intl's `defineRouting()`.
|
|
12
|
+
*
|
|
13
|
+
* Merges the provided config with Intlayer's own routing / internationalization
|
|
14
|
+
* configuration so you don't have to repeat locale lists. All fields are
|
|
15
|
+
* optional — omitted values are read from the Intlayer config at runtime.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* export default defineRouting({
|
|
20
|
+
* locales: ['en', 'fr'],
|
|
21
|
+
* defaultLocale: 'en',
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare const defineRouting: (config?: Partial<Routing>) => Routing;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { Routing, defineRouting };
|
|
28
|
+
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.d.ts","names":[],"sources":["../../src/routing.ts"],"mappings":";;;KAGY,OAAA;EACV,OAAA,EAAS,aAAA;EACT,aAAA,EAAe,aAAA;EACf,YAAA;EACA,SAAA,GAAY,MAAA,kBAAwB,MAAA;AAAA;;;;;;;;;;;;;;;;cAkBzB,aAAA,GAAgB,MAAA,GAAS,OAAA,CAAQ,OAAA,MAAa,OAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getLocale as getLocale$1 } from "next-intl/server";
|
|
2
|
+
|
|
3
|
+
//#region src/server/getLocale.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in for next-intl's `getLocale()` server function.
|
|
6
|
+
*/
|
|
7
|
+
declare const getLocale: typeof getLocale$1;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getLocale };
|
|
10
|
+
//# sourceMappingURL=getLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocale.d.ts","names":[],"sources":["../../../src/server/getLocale.ts"],"mappings":";;;;;AAMA;cAAa,SAAA,SAAkB,WAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getMessages as getMessages$1 } from "next-intl/server";
|
|
2
|
+
|
|
3
|
+
//#region src/server/getMessages.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in replacement for next-intl's `getMessages()` server function.
|
|
6
|
+
*
|
|
7
|
+
* Returns all compiled dictionary content for the current locale as a flat
|
|
8
|
+
* record keyed by dictionary name. Useful when you need to pass messages
|
|
9
|
+
* to a `NextIntlClientProvider`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const messages = await getMessages();
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @deprecated getMessages has no use case with intlayer.
|
|
17
|
+
* Messages are loaded automatically under the hood
|
|
18
|
+
*/
|
|
19
|
+
declare const getMessages: typeof getMessages$1;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { getMessages };
|
|
22
|
+
//# sourceMappingURL=getMessages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMessages.d.ts","names":[],"sources":["../../../src/server/getMessages.ts"],"mappings":";;;;;AAoBA;;;;;;;;;;;;;cAAa,WAAA,SAAoB,aAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { MarkupChunkRenderer, RichChunkRenderer } from "../createTranslator.js";
|
|
2
|
+
import { DictionaryKeys, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
5
|
+
|
|
6
|
+
//#region src/server/getTranslations.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Options accepted by the options-object overload of {@link getTranslations}.
|
|
9
|
+
*/
|
|
10
|
+
type GetTranslationsOptions<N extends DictionaryKeys> = {
|
|
11
|
+
/** The dictionary namespace to scope translations to. */namespace?: N; /** Override the locale instead of reading it from the current request. */
|
|
12
|
+
locale?: LocalesValues;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The translation function returned by {@link getTranslations}.
|
|
16
|
+
*
|
|
17
|
+
* Beyond the plain call signature, the function exposes:
|
|
18
|
+
* - `has(key)` — returns `true` when the key exists in the namespace.
|
|
19
|
+
* - `raw(key)` — returns the unprocessed message value.
|
|
20
|
+
* - `rich(key, values)` — resolves `<tag>chunks</tag>` markup to React nodes.
|
|
21
|
+
* - `markup(key, values)` — resolves `<tag>chunks</tag>` markup to a string.
|
|
22
|
+
*/
|
|
23
|
+
type TranslateFunction<N extends DictionaryKeys> = {
|
|
24
|
+
/** Translate a key to a string, with optional ICU interpolation params. */<P extends ValidDotPathsFor<N>>(key: P, params?: Record<string, unknown>): string; /** Returns `true` if the given key exists in the namespace. */
|
|
25
|
+
has<P extends ValidDotPathsFor<N>>(key: P): boolean; /** Returns the raw unprocessed message for the given key. */
|
|
26
|
+
raw<P extends ValidDotPathsFor<N>>(key: P): unknown; /** Resolves rich-text markup, mapping tags through React renderers. */
|
|
27
|
+
rich<P extends ValidDotPathsFor<N>>(key: P, values?: Record<string, RichChunkRenderer | ReactNode>): ReactNode; /** Resolves rich-text markup, mapping tags through string renderers. */
|
|
28
|
+
markup<P extends ValidDotPathsFor<N>>(key: P, values?: Record<string, MarkupChunkRenderer | string | number>): string;
|
|
29
|
+
};
|
|
30
|
+
/** Loosely-typed function returned for nested `'dict.scope'` namespaces. */
|
|
31
|
+
type LooseTranslateFunction = {
|
|
32
|
+
(key: string, params?: Record<string, unknown>): string;
|
|
33
|
+
has(key: string): boolean;
|
|
34
|
+
raw(key: string): unknown;
|
|
35
|
+
rich(key: string, values?: Record<string, RichChunkRenderer | ReactNode>): ReactNode;
|
|
36
|
+
markup(key: string, values?: Record<string, MarkupChunkRenderer | string | number>): string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Overload set for {@link getTranslations}:
|
|
40
|
+
*
|
|
41
|
+
* 1. A bare dictionary key → fully-typed `t()` (autocompleted dot-paths).
|
|
42
|
+
* 2. An options object `{ namespace?, locale? }` → typed when namespace is
|
|
43
|
+
* a known `DictionaryKeys` value.
|
|
44
|
+
* 3. A nested namespace `'dictionary.sub.scope'` → `t()` accepts relative
|
|
45
|
+
* `string` paths, matching next-intl's scoped-namespace behaviour.
|
|
46
|
+
* 4. No namespace → root scope; the first segment of each key designates
|
|
47
|
+
* the dictionary (`t('about.title')`).
|
|
48
|
+
*/
|
|
49
|
+
type GetTranslations = {
|
|
50
|
+
<N extends DictionaryKeys>(namespace: N): Promise<TranslateFunction<N>>;
|
|
51
|
+
<N extends DictionaryKeys>(options: GetTranslationsOptions<N>): Promise<TranslateFunction<N>>;
|
|
52
|
+
(namespace: `${string}.${string}`): Promise<LooseTranslateFunction>;
|
|
53
|
+
(): Promise<LooseTranslateFunction>;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Drop-in for next-intl's server `getTranslations()`.
|
|
57
|
+
*
|
|
58
|
+
* Messages support ICU MessageFormat syntax: simple arguments (`{name}`),
|
|
59
|
+
* plural (`{count, plural, one {…} other {…}}`, `#`), select, and formatted
|
|
60
|
+
* arguments (`{value, number}`). Rich text is available through `t.rich()`
|
|
61
|
+
* and `t.markup()`.
|
|
62
|
+
*
|
|
63
|
+
* Also accepts an options object `{ namespace, locale }` to match next-intl's
|
|
64
|
+
* full server API surface.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* // Bare namespace — fully typed dot-paths
|
|
69
|
+
* const t = await getTranslations('about');
|
|
70
|
+
* return <h1>{t('counter.label')}</h1>;
|
|
71
|
+
*
|
|
72
|
+
* // ICU plural
|
|
73
|
+
* t('items', { count: 3 });
|
|
74
|
+
*
|
|
75
|
+
* // Options object with locale override
|
|
76
|
+
* const t = await getTranslations({ namespace: 'about', locale: 'fr' });
|
|
77
|
+
*
|
|
78
|
+
* // Rich text
|
|
79
|
+
* t.rich('terms', { link: (chunks) => <a href="/terms">{chunks}</a> });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare const getTranslations: GetTranslations;
|
|
83
|
+
//#endregion
|
|
84
|
+
export { getTranslations };
|
|
85
|
+
//# sourceMappingURL=getTranslations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTranslations.d.ts","names":[],"sources":["../../../src/server/getTranslations.ts"],"mappings":";;;;;;;;AAU6B;KAMxB,sBAAA,WAAiC,cAAA;EAAX,yDAEzB,SAAA,GAAY,CAAA,EAAA;EAEZ,MAAA,GAAS,aAAA;AAAA;;;;;;;;;;KAYN,iBAAA,WAA4B,cAAA;EAAX,sFAET,gBAAA,CAAiB,CAAA,GAC1B,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,MAAA,4BAJoB;EAO/B,GAAA,WAAc,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA,YAL7B;EAOX,GAAA,WAAc,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA,YAL7B;EAOX,IAAA,WAAe,gBAAA,CAAiB,CAAA,GAC9B,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,MAAA,SAAe,iBAAA,GAAoB,SAAA,IAC3C,SAAA,EAPW;EASd,MAAA,WAAiB,gBAAA,CAAiB,CAAA,GAChC,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,MAAA,SAAe,mBAAA;AAAA;;KAKvB,sBAAA;EAAA,CACF,GAAA,UAAa,MAAA,GAAS,MAAA;EACvB,GAAA,CAAI,GAAA;EACJ,GAAA,CAAI,GAAA;EACJ,IAAA,CACE,GAAA,UACA,MAAA,GAAS,MAAA,SAAe,iBAAA,GAAoB,SAAA,IAC3C,SAAA;EACH,MAAA,CACE,GAAA,UACA,MAAA,GAAS,MAAA,SAAe,mBAAA;AAAA;;;;;;;;;;;;KAevB,eAAA;EAAA,WACQ,cAAA,EAAgB,SAAA,EAAW,CAAA,GAAI,OAAA,CAAQ,iBAAA,CAAkB,CAAA;EAAA,WACzD,cAAA,EACT,OAAA,EAAS,sBAAA,CAAuB,CAAA,IAC/B,OAAA,CAAQ,iBAAA,CAAkB,CAAA;EAAA,CAC5B,SAAA,0BAAmC,OAAA,CAAQ,sBAAA;EAAA,IACxC,OAAA,CAAQ,sBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BD,eAAA,EAAiB,eAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getFormatter as getFormatter$1, getNow as getNow$1, getTimeZone as getTimeZone$1 } from "next-intl/server";
|
|
2
|
+
|
|
3
|
+
//#region src/server/helpers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in for next-intl's server `getFormatter()`.
|
|
6
|
+
* Returns locale-aware formatters backed by the native `Intl.*` APIs.
|
|
7
|
+
*/
|
|
8
|
+
declare const getFormatter: typeof getFormatter$1;
|
|
9
|
+
/**
|
|
10
|
+
* Drop-in for next-intl's server `getNow()`.
|
|
11
|
+
* Returns the current `Date`.
|
|
12
|
+
*/
|
|
13
|
+
declare const getNow: typeof getNow$1;
|
|
14
|
+
/**
|
|
15
|
+
* Drop-in for next-intl's server `getTimeZone()`.
|
|
16
|
+
* Returns the system time zone resolved from `Intl.DateTimeFormat`.
|
|
17
|
+
*/
|
|
18
|
+
declare const getTimeZone: typeof getTimeZone$1;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getFormatter, getNow, getTimeZone };
|
|
21
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/server/helpers.ts"],"mappings":";;;;;AAYA;;cAAa,YAAA,SAAqB,cAAA;;;AAWlC;;cAAa,MAAA,SAAe,QAAA;;;AAO5B;;cAAa,WAAA,SAAoB,aAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getDictionary } from "../getDictionary.js";
|
|
2
|
+
import { getDictionaryDynamic } from "../getDictionaryDynamic.js";
|
|
3
|
+
import { getLocale } from "./getLocale.js";
|
|
4
|
+
import { getMessages } from "./getMessages.js";
|
|
5
|
+
import { getTranslations } from "./getTranslations.js";
|
|
6
|
+
import { getFormatter, getNow, getTimeZone } from "./helpers.js";
|
|
7
|
+
import { setLocale } from "./setLocale.js";
|
|
8
|
+
export { getDictionary, getDictionaryDynamic, getFormatter, getLocale, getMessages, getNow, getTimeZone, getTranslations, setLocale };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/server/setLocale.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Drop-in replacement for next-intl's `setLocale()` server action.
|
|
4
|
+
*
|
|
5
|
+
* Writes the locale to whichever cookie(s) the active `routing.storage`
|
|
6
|
+
* configuration specifies. When `createNextIntlPlugin` is used (the default),
|
|
7
|
+
* this is `NEXT_LOCALE`; when the user has configured a custom storage in
|
|
8
|
+
* `intlayer.config.ts`, that name is used instead.
|
|
9
|
+
*
|
|
10
|
+
* Must be called inside a Server Action.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* 'use server';
|
|
15
|
+
* await setLocale('fr');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare const setLocale: (locale: string) => Promise<void>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { setLocale };
|
|
21
|
+
//# sourceMappingURL=setLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setLocale.d.ts","names":[],"sources":["../../../src/server/setLocale.ts"],"mappings":";;AAoBA;;;;;;;;;;;;;;;cAAa,SAAA,GAAmB,MAAA,aAAiB,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
2
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
|
+
|
|
4
|
+
//#region src/useDictionary.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Dictionary-accepting variant of `useTranslations`.
|
|
7
|
+
*
|
|
8
|
+
* Used internally by the SWC optimization: instead of looking up the dictionary
|
|
9
|
+
* at runtime by key, the SWC plugin pre-imports the dictionary JSON at build time
|
|
10
|
+
* and passes it directly here. This enables tree-shaking of unused locale content.
|
|
11
|
+
*
|
|
12
|
+
* @example (generated by SWC, not written manually)
|
|
13
|
+
* import _abc from '.intlayer/dictionaries/about.json' with { type: 'json' };
|
|
14
|
+
* const t = useDictionary(_abc);
|
|
15
|
+
*/
|
|
16
|
+
declare const useDictionary: <T extends Dictionary>(dictionary: T, namespacePrefix?: string) => (<P extends ValidDotPathsFor<any>>(lookup: P, params?: Record<string, unknown>) => string) & {
|
|
17
|
+
has: <P extends ValidDotPathsFor<any>>(lookup: P) => boolean;
|
|
18
|
+
raw: <P extends ValidDotPathsFor<any>>(lookup: P) => unknown;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useDictionary };
|
|
22
|
+
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../src/useDictionary.ts"],"mappings":";;;;;;AAkCA;;;;;;;;;cAAa,aAAA,aAA2B,UAAA,EACtC,UAAA,EAAY,CAAA,EACZ,eAAA,0BAQa,gBAAA,OAAqB,MAAA,EACtB,CAAA,EAAC,MAAA,GACA,MAAA;kBAUO,gBAAA,OAAqB,MAAA,EAAU,CAAA;kBAE/B,gBAAA,OAAqB,MAAA,EAAU,CAAA;AAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
3
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
+
|
|
5
|
+
//#region src/useDictionaryDynamic.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Dynamic dictionary-accepting variant of `useTranslations`.
|
|
8
|
+
*/
|
|
9
|
+
declare const useDictionaryDynamic: <const T extends Dictionary, const K extends string>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, namespacePrefix?: string) => (<P extends ValidDotPathsFor<any>>(lookup: P, params?: Record<string, unknown>) => string) & {
|
|
10
|
+
has: <P extends ValidDotPathsFor<any>>(lookup: P) => boolean;
|
|
11
|
+
raw: <P extends ValidDotPathsFor<any>>(lookup: P) => unknown;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { useDictionaryDynamic };
|
|
15
|
+
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../src/useDictionaryDynamic.ts"],"mappings":";;;;;;;AA2BA;cAAa,oBAAA,mBACK,UAAA,0BAGhB,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,eAAA,0BAWa,gBAAA,OAAqB,MAAA,EACtB,CAAA,EAAC,MAAA,GACA,MAAA;kBAUO,gBAAA,OAAqB,MAAA,EAAU,CAAA;kBAE/B,gBAAA,OAAqB,MAAA,EAAU,CAAA;AAAA"}
|