@intlayer/next-intl 9.0.0-canary.2 → 9.0.0-canary.4
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/dist/cjs/client/NextIntlClientProvider.cjs +7 -3
- package/dist/cjs/client/NextIntlClientProvider.cjs.map +1 -1
- package/dist/cjs/client/index.cjs +56 -13
- package/dist/cjs/index.cjs +92 -15
- package/dist/cjs/server/getLocale.cjs +15 -1
- package/dist/cjs/server/getLocale.cjs.map +1 -1
- package/dist/cjs/server/getRequestConfig.cjs +28 -0
- package/dist/cjs/server/getRequestConfig.cjs.map +1 -0
- package/dist/cjs/server/getTranslations.cjs +9 -4
- package/dist/cjs/server/getTranslations.cjs.map +1 -1
- package/dist/cjs/server/helpers.cjs +5 -3
- package/dist/cjs/server/helpers.cjs.map +1 -1
- package/dist/cjs/server/index.cjs +5 -1
- package/dist/cjs/server/requestLocaleCache.cjs +36 -0
- package/dist/cjs/server/requestLocaleCache.cjs.map +1 -0
- package/dist/cjs/server/setRequestLocale.cjs +33 -0
- package/dist/cjs/server/setRequestLocale.cjs.map +1 -0
- package/dist/esm/client/NextIntlClientProvider.mjs +9 -4
- package/dist/esm/client/NextIntlClientProvider.mjs.map +1 -1
- package/dist/esm/client/index.mjs +1 -4
- package/dist/esm/index.mjs +3 -6
- package/dist/esm/server/getLocale.mjs +15 -1
- package/dist/esm/server/getLocale.mjs.map +1 -1
- package/dist/esm/server/getRequestConfig.mjs +25 -0
- package/dist/esm/server/getRequestConfig.mjs.map +1 -0
- package/dist/esm/server/getTranslations.mjs +8 -4
- package/dist/esm/server/getTranslations.mjs.map +1 -1
- package/dist/esm/server/helpers.mjs +4 -3
- package/dist/esm/server/helpers.mjs.map +1 -1
- package/dist/esm/server/index.mjs +3 -1
- package/dist/esm/server/requestLocaleCache.mjs +33 -0
- package/dist/esm/server/requestLocaleCache.mjs.map +1 -0
- package/dist/esm/server/setRequestLocale.mjs +32 -0
- package/dist/esm/server/setRequestLocale.mjs.map +1 -0
- package/dist/types/client/NextIntlClientProvider.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +1 -4
- package/dist/types/index.d.ts +3 -6
- package/dist/types/server/getLocale.d.ts +9 -0
- package/dist/types/server/getLocale.d.ts.map +1 -1
- package/dist/types/server/getRequestConfig.d.ts +19 -0
- package/dist/types/server/getRequestConfig.d.ts.map +1 -0
- package/dist/types/server/getTranslations.d.ts +7 -29
- package/dist/types/server/getTranslations.d.ts.map +1 -1
- package/dist/types/server/helpers.d.ts +2 -1
- package/dist/types/server/helpers.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +3 -1
- package/dist/types/server/requestLocaleCache.d.ts +17 -0
- package/dist/types/server/requestLocaleCache.d.ts.map +1 -0
- package/dist/types/server/setRequestLocale.d.ts +29 -0
- package/dist/types/server/setRequestLocale.d.ts.map +1 -0
- package/package.json +11 -16
- package/dist/cjs/client/helpers.cjs +0 -66
- package/dist/cjs/client/helpers.cjs.map +0 -1
- package/dist/cjs/client/useTranslations.cjs +0 -39
- package/dist/cjs/client/useTranslations.cjs.map +0 -1
- package/dist/cjs/createFormatter.cjs +0 -59
- package/dist/cjs/createFormatter.cjs.map +0 -1
- package/dist/cjs/createTranslator.cjs +0 -111
- package/dist/cjs/createTranslator.cjs.map +0 -1
- package/dist/cjs/getTranslationsDictionary.cjs +0 -31
- package/dist/cjs/getTranslationsDictionary.cjs.map +0 -1
- package/dist/cjs/getTranslationsDictionaryDynamic.cjs +0 -27
- package/dist/cjs/getTranslationsDictionaryDynamic.cjs.map +0 -1
- package/dist/cjs/hasLocale.cjs +0 -25
- package/dist/cjs/hasLocale.cjs.map +0 -1
- package/dist/cjs/package.cjs +0 -122
- package/dist/cjs/package.cjs.map +0 -1
- package/dist/cjs/useDictionary.cjs +0 -45
- package/dist/cjs/useDictionary.cjs.map +0 -1
- package/dist/cjs/useDictionaryDynamic.cjs +0 -37
- package/dist/cjs/useDictionaryDynamic.cjs.map +0 -1
- package/dist/cjs/useTranslationsDictionary.cjs +0 -37
- package/dist/cjs/useTranslationsDictionary.cjs.map +0 -1
- package/dist/cjs/useTranslationsDictionaryDynamic.cjs +0 -29
- package/dist/cjs/useTranslationsDictionaryDynamic.cjs.map +0 -1
- package/dist/esm/_virtual/_rolldown/runtime.mjs +0 -8
- package/dist/esm/client/helpers.mjs +0 -59
- package/dist/esm/client/helpers.mjs.map +0 -1
- package/dist/esm/client/useTranslations.mjs +0 -37
- package/dist/esm/client/useTranslations.mjs.map +0 -1
- package/dist/esm/createFormatter.mjs +0 -57
- package/dist/esm/createFormatter.mjs.map +0 -1
- package/dist/esm/createTranslator.mjs +0 -108
- package/dist/esm/createTranslator.mjs.map +0 -1
- package/dist/esm/getTranslationsDictionary.mjs +0 -29
- package/dist/esm/getTranslationsDictionary.mjs.map +0 -1
- package/dist/esm/getTranslationsDictionaryDynamic.mjs +0 -25
- package/dist/esm/getTranslationsDictionaryDynamic.mjs.map +0 -1
- package/dist/esm/hasLocale.mjs +0 -23
- package/dist/esm/hasLocale.mjs.map +0 -1
- package/dist/esm/package.mjs +0 -119
- package/dist/esm/package.mjs.map +0 -1
- package/dist/esm/useDictionary.mjs +0 -43
- package/dist/esm/useDictionary.mjs.map +0 -1
- package/dist/esm/useDictionaryDynamic.mjs +0 -35
- package/dist/esm/useDictionaryDynamic.mjs.map +0 -1
- package/dist/esm/useTranslationsDictionary.mjs +0 -35
- package/dist/esm/useTranslationsDictionary.mjs.map +0 -1
- package/dist/esm/useTranslationsDictionaryDynamic.mjs +0 -27
- package/dist/esm/useTranslationsDictionaryDynamic.mjs.map +0 -1
- package/dist/types/client/helpers.d.ts +0 -45
- package/dist/types/client/helpers.d.ts.map +0 -1
- package/dist/types/client/useTranslations.d.ts +0 -74
- package/dist/types/client/useTranslations.d.ts.map +0 -1
- package/dist/types/createFormatter.d.ts +0 -15
- package/dist/types/createFormatter.d.ts.map +0 -1
- package/dist/types/createTranslator.d.ts +0 -40
- package/dist/types/createTranslator.d.ts.map +0 -1
- package/dist/types/getTranslationsDictionary.d.ts +0 -15
- package/dist/types/getTranslationsDictionary.d.ts.map +0 -1
- package/dist/types/getTranslationsDictionaryDynamic.d.ts +0 -12
- package/dist/types/getTranslationsDictionaryDynamic.d.ts.map +0 -1
- package/dist/types/hasLocale.d.ts +0 -20
- package/dist/types/hasLocale.d.ts.map +0 -1
- package/dist/types/useDictionary.d.ts +0 -22
- package/dist/types/useDictionary.d.ts.map +0 -1
- package/dist/types/useDictionaryDynamic.d.ts +0 -15
- package/dist/types/useDictionaryDynamic.d.ts.map +0 -1
- package/dist/types/useTranslationsDictionary.d.ts +0 -19
- package/dist/types/useTranslationsDictionary.d.ts.map +0 -1
- package/dist/types/useTranslationsDictionaryDynamic.d.ts +0 -12
- package/dist/types/useTranslationsDictionaryDynamic.d.ts.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { log } from "@intlayer/config/built";
|
|
2
|
+
import { CYAN } from "@intlayer/config/colors";
|
|
3
|
+
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
4
|
+
|
|
5
|
+
//#region src/server/getRequestConfig.ts
|
|
6
|
+
/**
|
|
7
|
+
* Drop-in for next-intl's `getRequestConfig`.
|
|
8
|
+
*
|
|
9
|
+
* In next-intl this registers the per-request config (locale + messages) read
|
|
10
|
+
* by its own plugin. With intlayer the locale is resolved from routing /
|
|
11
|
+
* storage and messages come from compiled dictionaries, so the returned config
|
|
12
|
+
* is never consumed — this is an identity passthrough kept so existing
|
|
13
|
+
* `i18n/request.ts` files keep resolving and type-checking.
|
|
14
|
+
*
|
|
15
|
+
* @deprecated getRequestConfig has no use case with intlayer. The locale and
|
|
16
|
+
* messages are resolved automatically; the file can be removed.
|
|
17
|
+
*/
|
|
18
|
+
const getRequestConfig = (createRequestConfig) => {
|
|
19
|
+
getAppLogger({ log })(`${colorize("getRequestConfig", CYAN)} has no use case with intlayer. The locale and messages are resolved automatically; the i18n/request.ts file can be removed`);
|
|
20
|
+
return createRequestConfig;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { getRequestConfig as default, getRequestConfig };
|
|
25
|
+
//# sourceMappingURL=getRequestConfig.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRequestConfig.mjs","names":[],"sources":["../../../src/server/getRequestConfig.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { getRequestConfig as _getRequestConfig } from 'next-intl/server';\n\n/**\n * Drop-in for next-intl's `getRequestConfig`.\n *\n * In next-intl this registers the per-request config (locale + messages) read\n * by its own plugin. With intlayer the locale is resolved from routing /\n * storage and messages come from compiled dictionaries, so the returned config\n * is never consumed — this is an identity passthrough kept so existing\n * `i18n/request.ts` files keep resolving and type-checking.\n *\n * @deprecated getRequestConfig has no use case with intlayer. The locale and\n * messages are resolved automatically; the file can be removed.\n */\nexport const getRequestConfig: typeof _getRequestConfig = (\n createRequestConfig\n) => {\n if (process.env.NODE_ENV === 'development') {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('getRequestConfig', CYAN)} has no use case with intlayer. The locale and messages are resolved automatically; the i18n/request.ts file can be removed`\n );\n }\n\n return createRequestConfig;\n};\n\nexport default getRequestConfig;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,oBACX,wBACG;AAGD,CADkB,aAAa,EAAE,KAAK,CAC7B,CACP,GAAG,SAAS,oBAAoB,KAAK,CAAC,6HACvC;AAGH,QAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getLocale } from "./getLocale.mjs";
|
|
2
|
-
import { createTranslator } from "
|
|
2
|
+
import { createTranslator } from "@intlayer/use-intl";
|
|
3
3
|
|
|
4
4
|
//#region src/server/getTranslations.ts
|
|
5
5
|
/**
|
|
@@ -10,8 +10,9 @@ import { createTranslator } from "../createTranslator.mjs";
|
|
|
10
10
|
* arguments (`{value, number}`). Rich text is available through `t.rich()`
|
|
11
11
|
* and `t.markup()`.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* Resolves the active locale from the current request (or the `locale` option)
|
|
14
|
+
* and delegates to `@intlayer/use-intl`'s `createTranslator`, the same runtime
|
|
15
|
+
* that backs the client `useTranslations`.
|
|
15
16
|
*
|
|
16
17
|
* @example
|
|
17
18
|
* ```ts
|
|
@@ -36,7 +37,10 @@ const getTranslations = (async (namespaceOrOptions) => {
|
|
|
36
37
|
namespace = namespaceOrOptions.namespace;
|
|
37
38
|
localeOverride = namespaceOrOptions.locale;
|
|
38
39
|
} else namespace = namespaceOrOptions;
|
|
39
|
-
return createTranslator(
|
|
40
|
+
return createTranslator({
|
|
41
|
+
locale: localeOverride ?? await getLocale(),
|
|
42
|
+
namespace
|
|
43
|
+
});
|
|
40
44
|
});
|
|
41
45
|
|
|
42
46
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTranslations.mjs","names":[],"sources":["../../../src/server/getTranslations.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"getTranslations.mjs","names":[],"sources":["../../../src/server/getTranslations.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n createTranslator,\n type LooseTranslateFunction,\n type TranslateFunction,\n} from '@intlayer/use-intl';\nimport { getLocale } from './getLocale';\n\n/**\n * Options accepted by the options-object overload of {@link getTranslations}.\n */\ntype GetTranslationsOptions<N extends DictionaryKeys> = {\n /** The dictionary namespace to scope translations to. */\n namespace?: N;\n /** Override the locale instead of reading it from the current request. */\n locale?: LocalesValues;\n};\n\n/**\n * Overload set for {@link getTranslations}:\n *\n * 1. A bare dictionary key → fully-typed `t()` (autocompleted dot-paths).\n * 2. An options object `{ namespace?, locale? }` → typed when namespace is\n * a known `DictionaryKeys` value.\n * 3. A nested namespace `'dictionary.sub.scope'` → `t()` accepts relative\n * `string` paths, matching next-intl's scoped-namespace behaviour.\n * 4. No namespace → root scope; the first segment of each key designates\n * the dictionary (`t('about.title')`).\n *\n * The translate function shape (`t`, `t.rich`, `t.markup`, `t.raw`, `t.has`)\n * is shared with `@intlayer/use-intl`.\n */\ntype GetTranslations = {\n <N extends DictionaryKeys>(namespace: N): Promise<TranslateFunction<N>>;\n <N extends DictionaryKeys>(\n options: GetTranslationsOptions<N>\n ): Promise<TranslateFunction<N>>;\n (namespace: `${string}.${string}`): Promise<LooseTranslateFunction>;\n (): Promise<LooseTranslateFunction>;\n};\n\n/**\n * Drop-in for next-intl's server `getTranslations()`.\n *\n * Messages support ICU MessageFormat syntax: simple arguments (`{name}`),\n * plural (`{count, plural, one {…} other {…}}`, `#`), select, and formatted\n * arguments (`{value, number}`). Rich text is available through `t.rich()`\n * and `t.markup()`.\n *\n * Resolves the active locale from the current request (or the `locale` option)\n * and delegates to `@intlayer/use-intl`'s `createTranslator`, the same runtime\n * that backs the client `useTranslations`.\n *\n * @example\n * ```ts\n * // Bare namespace — fully typed dot-paths\n * const t = await getTranslations('about');\n * return <h1>{t('counter.label')}</h1>;\n *\n * // ICU plural\n * t('items', { count: 3 });\n *\n * // Options object with locale override\n * const t = await getTranslations({ namespace: 'about', locale: 'fr' });\n *\n * // Rich text\n * t.rich('terms', { link: (chunks) => <a href=\"/terms\">{chunks}</a> });\n * ```\n */\nexport const getTranslations: GetTranslations = (async (\n namespaceOrOptions?: string | GetTranslationsOptions<DictionaryKeys>\n) => {\n let namespace: string | undefined;\n let localeOverride: LocalesValues | undefined;\n\n if (typeof namespaceOrOptions === 'object' && namespaceOrOptions !== null) {\n namespace = namespaceOrOptions.namespace;\n localeOverride = namespaceOrOptions.locale;\n } else {\n namespace = namespaceOrOptions as string | undefined;\n }\n\n const locale = localeOverride ?? (await getLocale());\n\n return createTranslator({ locale: locale as LocalesValues, namespace });\n}) as GetTranslations;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,MAAa,mBAAoC,OAC/C,uBACG;CACH,IAAI;CACJ,IAAI;AAEJ,KAAI,OAAO,uBAAuB,YAAY,uBAAuB,MAAM;AACzE,cAAY,mBAAmB;AAC/B,mBAAiB,mBAAmB;OAEpC,aAAY;AAKd,QAAO,iBAAiB;EAAE,QAFX,kBAAmB,MAAM,WAAW;EAEQ;EAAW,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { createFormatter } from "../createFormatter.mjs";
|
|
2
1
|
import { getLocale } from "./getLocale.mjs";
|
|
2
|
+
import { createFormatter } from "@intlayer/use-intl";
|
|
3
3
|
|
|
4
4
|
//#region src/server/helpers.ts
|
|
5
5
|
/**
|
|
6
6
|
* Drop-in for next-intl's server `getFormatter()`.
|
|
7
|
-
* Returns locale-aware formatters backed by the native `Intl.*` APIs
|
|
7
|
+
* Returns locale-aware formatters backed by the native `Intl.*` APIs,
|
|
8
|
+
* built by `@intlayer/use-intl`'s `createFormatter`.
|
|
8
9
|
*/
|
|
9
10
|
const getFormatter = (async (options) => {
|
|
10
|
-
return createFormatter(options?.locale ?? await getLocale());
|
|
11
|
+
return createFormatter({ locale: options?.locale ?? await getLocale() });
|
|
11
12
|
});
|
|
12
13
|
/**
|
|
13
14
|
* Drop-in for next-intl's server `getNow()`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../../src/server/helpers.ts"],"sourcesContent":["import type {\n getFormatter as _getFormatter,\n getNow as _getNow,\n getTimeZone as _getTimeZone,\n} from 'next-intl/server';\nimport {
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../../src/server/helpers.ts"],"sourcesContent":["import { createFormatter } from '@intlayer/use-intl';\nimport type {\n getFormatter as _getFormatter,\n getNow as _getNow,\n getTimeZone as _getTimeZone,\n} from 'next-intl/server';\nimport { getLocale } from './getLocale';\n\n/**\n * Drop-in for next-intl's server `getFormatter()`.\n * Returns locale-aware formatters backed by the native `Intl.*` APIs,\n * built by `@intlayer/use-intl`'s `createFormatter`.\n */\nexport const getFormatter: typeof _getFormatter = (async (options?: {\n locale?: string;\n}) => {\n const locale = options?.locale ?? (await getLocale());\n return createFormatter({ locale: locale as string });\n}) as typeof _getFormatter;\n\n/**\n * Drop-in for next-intl's server `getNow()`.\n * Returns the current `Date`.\n */\nexport const getNow: typeof _getNow = (async () =>\n new Date()) as typeof _getNow;\n\n/**\n * Drop-in for next-intl's server `getTimeZone()`.\n * Returns the system time zone resolved from `Intl.DateTimeFormat`.\n */\nexport const getTimeZone: typeof _getTimeZone = (async () =>\n Intl.DateTimeFormat().resolvedOptions().timeZone) as typeof _getTimeZone;\n"],"mappings":";;;;;;;;;AAaA,MAAa,gBAAsC,OAAO,YAEpD;AAEJ,QAAO,gBAAgB,EAAE,QADV,SAAS,UAAW,MAAM,WAAW,EACD,CAAC;;;;;;AAOtD,MAAa,UAA0B,4BACrC,IAAI,MAAM;;;;;AAMZ,MAAa,eAAoC,YAC/C,KAAK,gBAAgB,CAAC,iBAAiB,CAAC"}
|
|
@@ -2,8 +2,10 @@ import { getLocale } from "./getLocale.mjs";
|
|
|
2
2
|
import { getDictionary } from "../getDictionary.mjs";
|
|
3
3
|
import { getDictionaryDynamic } from "../getDictionaryDynamic.mjs";
|
|
4
4
|
import { getFormatter, getNow, getTimeZone } from "./helpers.mjs";
|
|
5
|
+
import getRequestConfig from "./getRequestConfig.mjs";
|
|
6
|
+
import { setRequestLocale } from "./setRequestLocale.mjs";
|
|
5
7
|
import { setLocale } from "./setLocale.mjs";
|
|
6
8
|
import { getTranslations } from "./getTranslations.mjs";
|
|
7
9
|
import { getMessages } from "./getMessages.mjs";
|
|
8
10
|
|
|
9
|
-
export { getDictionary, getDictionaryDynamic, getFormatter, getLocale, getMessages, getNow, getTimeZone, getTranslations, setLocale };
|
|
11
|
+
export { getDictionary, getDictionaryDynamic, getFormatter, getLocale, getMessages, getNow, getRequestConfig, getTimeZone, getTranslations, setLocale, setRequestLocale };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cache } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/server/requestLocaleCache.ts
|
|
4
|
+
/**
|
|
5
|
+
* Request-scoped holder for the locale provided through {@link setRequestLocale}.
|
|
6
|
+
*
|
|
7
|
+
* next-intl resolves the active locale per request from the `[locale]` route
|
|
8
|
+
* segment, which the app forwards via `setRequestLocale(locale)`. React's
|
|
9
|
+
* `cache()` gives a per-request singleton (the same trick next-intl uses in its
|
|
10
|
+
* own `RequestLocaleCache`), so the value set in the layout/page is readable by
|
|
11
|
+
* the other server APIs (`getLocale`, `getTranslations`, …) during the same
|
|
12
|
+
* render.
|
|
13
|
+
*
|
|
14
|
+
* @see https://github.com/vercel/next.js/discussions/58862
|
|
15
|
+
*/
|
|
16
|
+
const getRequestLocaleHolder = cache(() => ({ locale: void 0 }));
|
|
17
|
+
/**
|
|
18
|
+
* Read the locale stored for the current request, or `undefined` when
|
|
19
|
+
* `setRequestLocale` has not been called.
|
|
20
|
+
*/
|
|
21
|
+
const getCachedRequestLocale = () => getRequestLocaleHolder().locale;
|
|
22
|
+
/**
|
|
23
|
+
* Store the locale for the current request. Called by `setRequestLocale`.
|
|
24
|
+
*
|
|
25
|
+
* @param locale - The locale resolved from the `[locale]` route segment.
|
|
26
|
+
*/
|
|
27
|
+
const setCachedRequestLocale = (locale) => {
|
|
28
|
+
getRequestLocaleHolder().locale = locale;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { getCachedRequestLocale, setCachedRequestLocale };
|
|
33
|
+
//# sourceMappingURL=requestLocaleCache.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestLocaleCache.mjs","names":[],"sources":["../../../src/server/requestLocaleCache.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { cache } from 'react';\n\n/**\n * Request-scoped holder for the locale provided through {@link setRequestLocale}.\n *\n * next-intl resolves the active locale per request from the `[locale]` route\n * segment, which the app forwards via `setRequestLocale(locale)`. React's\n * `cache()` gives a per-request singleton (the same trick next-intl uses in its\n * own `RequestLocaleCache`), so the value set in the layout/page is readable by\n * the other server APIs (`getLocale`, `getTranslations`, …) during the same\n * render.\n *\n * @see https://github.com/vercel/next.js/discussions/58862\n */\nconst getRequestLocaleHolder = cache((): { locale?: LocalesValues } => ({\n locale: undefined,\n}));\n\n/**\n * Read the locale stored for the current request, or `undefined` when\n * `setRequestLocale` has not been called.\n */\nexport const getCachedRequestLocale = (): LocalesValues | undefined =>\n getRequestLocaleHolder().locale;\n\n/**\n * Store the locale for the current request. Called by `setRequestLocale`.\n *\n * @param locale - The locale resolved from the `[locale]` route segment.\n */\nexport const setCachedRequestLocale = (locale: LocalesValues): void => {\n getRequestLocaleHolder().locale = locale;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,yBAAyB,aAAyC,EACtE,QAAQ,QACT,EAAE;;;;;AAMH,MAAa,+BACX,wBAAwB,CAAC;;;;;;AAO3B,MAAa,0BAA0B,WAAgC;AACrE,yBAAwB,CAAC,SAAS"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { setCachedRequestLocale } from "./requestLocaleCache.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/server/setRequestLocale.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in for next-intl's `setRequestLocale`.
|
|
6
|
+
*
|
|
7
|
+
* In next-intl this stores the locale (typically the `[locale]` route segment)
|
|
8
|
+
* in a request-scoped cache so the rest of the request can render in that
|
|
9
|
+
* locale and opt into static rendering. The compat keeps the same contract:
|
|
10
|
+
* the locale is stored per-request and read back by `getLocale()` (and, through
|
|
11
|
+
* it, `getTranslations` / `getDictionary` / metadata). This is what makes the
|
|
12
|
+
* per-request locale — and therefore the locale switcher — work without relying
|
|
13
|
+
* on a cookie.
|
|
14
|
+
*
|
|
15
|
+
* @param locale - The locale resolved from the `[locale]` route segment.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* export default async function LocaleLayout({ params }) {
|
|
20
|
+
* const { locale } = await params;
|
|
21
|
+
* setRequestLocale(locale);
|
|
22
|
+
* // …
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
const setRequestLocale = (locale) => {
|
|
27
|
+
setCachedRequestLocale(locale);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { setRequestLocale };
|
|
32
|
+
//# sourceMappingURL=setRequestLocale.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setRequestLocale.mjs","names":[],"sources":["../../../src/server/setRequestLocale.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { setRequestLocale as _setRequestLocale } from 'next-intl/server';\nimport { setCachedRequestLocale } from './requestLocaleCache';\n\n/**\n * Drop-in for next-intl's `setRequestLocale`.\n *\n * In next-intl this stores the locale (typically the `[locale]` route segment)\n * in a request-scoped cache so the rest of the request can render in that\n * locale and opt into static rendering. The compat keeps the same contract:\n * the locale is stored per-request and read back by `getLocale()` (and, through\n * it, `getTranslations` / `getDictionary` / metadata). This is what makes the\n * per-request locale — and therefore the locale switcher — work without relying\n * on a cookie.\n *\n * @param locale - The locale resolved from the `[locale]` route segment.\n *\n * @example\n * ```ts\n * export default async function LocaleLayout({ params }) {\n * const { locale } = await params;\n * setRequestLocale(locale);\n * // …\n * }\n * ```\n */\nexport const setRequestLocale: typeof _setRequestLocale = (locale): void => {\n setCachedRequestLocale(locale as LocalesValues);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,oBAA8C,WAAiB;AAC1E,wBAAuB,OAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextIntlClientProvider.d.ts","names":[],"sources":["../../../src/client/NextIntlClientProvider.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"NextIntlClientProvider.d.ts","names":[],"sources":["../../../src/client/NextIntlClientProvider.tsx"],"mappings":";;;;;;;AAiBA;;;cAAa,sBAAA,SAA+B,wBAAA;;AAsD5C;;KAAY,2BAAA,GAA8B,IAAA,CACxC,cAAA,QAAsB,wBAAA;EAAA;;;;EAOtB,QAAA;EAIqB;;;EAArB,MAAA,EAAQ,aAAA;AAAA"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { NextIntlClientProvider, NextIntlClientProviderProps } from "./NextIntlClientProvider.js";
|
|
2
|
-
import { IntlProvider, useExtracted, useFormatter, useMessages, useNow, useTimeZone } from "./helpers.js";
|
|
3
|
-
import { useDictionary } from "../useDictionary.js";
|
|
4
|
-
import { useDictionaryDynamic } from "../useDictionaryDynamic.js";
|
|
5
2
|
import { useLocale } from "./useLocale.js";
|
|
6
|
-
import { useTranslations } from "
|
|
3
|
+
import { IntlProvider, _useExtracted as useExtracted, useDictionary, useDictionaryDynamic, useFormatter, useMessages, useNow, useTimeZone, useTranslations } from "@intlayer/use-intl";
|
|
7
4
|
export { IntlProvider, NextIntlClientProvider, type NextIntlClientProviderProps, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
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
2
|
import { useLocale } from "./client/useLocale.js";
|
|
6
|
-
import { useTranslations } from "./client/
|
|
7
|
-
import { hasLocale } from "./hasLocale.js";
|
|
3
|
+
import { IntlProvider, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useMessages, useNow, useTimeZone, useTranslations } from "./client/index.js";
|
|
8
4
|
import { Routing, defineRouting } from "./routing.js";
|
|
9
|
-
|
|
5
|
+
import { IntlError, IntlErrorCode, createFormatter, createTranslator, hasLocale, initializeConfig } from "@intlayer/use-intl";
|
|
6
|
+
export { IntlError, IntlErrorCode, IntlProvider, NextIntlClientProvider, NextIntlClientProviderProps, type Routing, createFormatter, createTranslator, defineRouting, hasLocale, initializeConfig, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
|
|
@@ -3,6 +3,15 @@ import { getLocale as getLocale$1 } from "next-intl/server";
|
|
|
3
3
|
//#region src/server/getLocale.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Drop-in for next-intl's `getLocale()` server function.
|
|
6
|
+
*
|
|
7
|
+
* Resolution order mirrors next-intl's per-request model:
|
|
8
|
+
*
|
|
9
|
+
* 1. The locale forwarded through `setRequestLocale(locale)` (the `[locale]`
|
|
10
|
+
* route segment) — the source of truth for URL-driven routing. This is what
|
|
11
|
+
* keeps server-rendered content and the locale switcher in sync with the URL
|
|
12
|
+
* instead of a stale cookie.
|
|
13
|
+
* 2. Otherwise Intlayer's own resolution (cookie / header / Accept-Language),
|
|
14
|
+
* for apps that drive the locale from storage rather than the route.
|
|
6
15
|
*/
|
|
7
16
|
declare const getLocale: typeof getLocale$1;
|
|
8
17
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocale.d.ts","names":[],"sources":["../../../src/server/getLocale.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"getLocale.d.ts","names":[],"sources":["../../../src/server/getLocale.ts"],"mappings":";;;;;AAgBA;;;;;;;;;;cAAa,SAAA,SAAkB,WAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getRequestConfig as getRequestConfig$1 } from "next-intl/server";
|
|
2
|
+
|
|
3
|
+
//#region src/server/getRequestConfig.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in for next-intl's `getRequestConfig`.
|
|
6
|
+
*
|
|
7
|
+
* In next-intl this registers the per-request config (locale + messages) read
|
|
8
|
+
* by its own plugin. With intlayer the locale is resolved from routing /
|
|
9
|
+
* storage and messages come from compiled dictionaries, so the returned config
|
|
10
|
+
* is never consumed — this is an identity passthrough kept so existing
|
|
11
|
+
* `i18n/request.ts` files keep resolving and type-checking.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated getRequestConfig has no use case with intlayer. The locale and
|
|
14
|
+
* messages are resolved automatically; the file can be removed.
|
|
15
|
+
*/
|
|
16
|
+
declare const getRequestConfig: typeof getRequestConfig$1;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { getRequestConfig as default, getRequestConfig };
|
|
19
|
+
//# sourceMappingURL=getRequestConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRequestConfig.d.ts","names":[],"sources":["../../../src/server/getRequestConfig.ts"],"mappings":";;;;;AAiBA;;;;;;;;;;cAAa,gBAAA,SAAyB,kBAAA"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { MarkupChunkRenderer, RichChunkRenderer } from "../createTranslator.js";
|
|
2
1
|
import { DictionaryKeys, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
|
-
import {
|
|
4
|
-
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
2
|
+
import { LooseTranslateFunction, TranslateFunction } from "@intlayer/use-intl";
|
|
5
3
|
|
|
6
4
|
//#region src/server/getTranslations.d.ts
|
|
7
5
|
/**
|
|
@@ -11,30 +9,6 @@ type GetTranslationsOptions<N extends DictionaryKeys> = {
|
|
|
11
9
|
/** The dictionary namespace to scope translations to. */namespace?: N; /** Override the locale instead of reading it from the current request. */
|
|
12
10
|
locale?: LocalesValues;
|
|
13
11
|
};
|
|
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
12
|
/**
|
|
39
13
|
* Overload set for {@link getTranslations}:
|
|
40
14
|
*
|
|
@@ -45,6 +19,9 @@ type LooseTranslateFunction = {
|
|
|
45
19
|
* `string` paths, matching next-intl's scoped-namespace behaviour.
|
|
46
20
|
* 4. No namespace → root scope; the first segment of each key designates
|
|
47
21
|
* the dictionary (`t('about.title')`).
|
|
22
|
+
*
|
|
23
|
+
* The translate function shape (`t`, `t.rich`, `t.markup`, `t.raw`, `t.has`)
|
|
24
|
+
* is shared with `@intlayer/use-intl`.
|
|
48
25
|
*/
|
|
49
26
|
type GetTranslations = {
|
|
50
27
|
<N extends DictionaryKeys>(namespace: N): Promise<TranslateFunction<N>>;
|
|
@@ -60,8 +37,9 @@ type GetTranslations = {
|
|
|
60
37
|
* arguments (`{value, number}`). Rich text is available through `t.rich()`
|
|
61
38
|
* and `t.markup()`.
|
|
62
39
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
40
|
+
* Resolves the active locale from the current request (or the `locale` option)
|
|
41
|
+
* and delegates to `@intlayer/use-intl`'s `createTranslator`, the same runtime
|
|
42
|
+
* that backs the client `useTranslations`.
|
|
65
43
|
*
|
|
66
44
|
* @example
|
|
67
45
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTranslations.d.ts","names":[],"sources":["../../../src/server/getTranslations.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getTranslations.d.ts","names":[],"sources":["../../../src/server/getTranslations.ts"],"mappings":";;;;;;AAQ4B;KAMvB,sBAAA,WAAiC,cAAA;EAAX,yDAEzB,SAAA,GAAY,CAAA,EAAA;EAEZ,MAAA,GAAS,aAAA;AAAA;;;;;;;;;;AAAa;;;;;KAiBnB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+BD,eAAA,EAAiB,eAAA"}
|
|
@@ -3,7 +3,8 @@ import { getFormatter as getFormatter$1, getNow as getNow$1, getTimeZone as getT
|
|
|
3
3
|
//#region src/server/helpers.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Drop-in for next-intl's server `getFormatter()`.
|
|
6
|
-
* Returns locale-aware formatters backed by the native `Intl.*` APIs
|
|
6
|
+
* Returns locale-aware formatters backed by the native `Intl.*` APIs,
|
|
7
|
+
* built by `@intlayer/use-intl`'s `createFormatter`.
|
|
7
8
|
*/
|
|
8
9
|
declare const getFormatter: typeof getFormatter$1;
|
|
9
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/server/helpers.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/server/helpers.ts"],"mappings":";;;;;AAaA;;;cAAa,YAAA,SAAqB,cAAA;;AAWlC;;;cAAa,MAAA,SAAe,QAAA;;AAO5B;;;cAAa,WAAA,SAAoB,aAAA"}
|
|
@@ -2,7 +2,9 @@ import { getDictionary } from "../getDictionary.js";
|
|
|
2
2
|
import { getDictionaryDynamic } from "../getDictionaryDynamic.js";
|
|
3
3
|
import { getLocale } from "./getLocale.js";
|
|
4
4
|
import { getMessages } from "./getMessages.js";
|
|
5
|
+
import getRequestConfig from "./getRequestConfig.js";
|
|
5
6
|
import { getTranslations } from "./getTranslations.js";
|
|
6
7
|
import { getFormatter, getNow, getTimeZone } from "./helpers.js";
|
|
7
8
|
import { setLocale } from "./setLocale.js";
|
|
8
|
-
|
|
9
|
+
import { setRequestLocale } from "./setRequestLocale.js";
|
|
10
|
+
export { getDictionary, getDictionaryDynamic, getFormatter, getLocale, getMessages, getNow, getRequestConfig, getTimeZone, getTranslations, setLocale, setRequestLocale };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
+
|
|
3
|
+
//#region src/server/requestLocaleCache.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Read the locale stored for the current request, or `undefined` when
|
|
6
|
+
* `setRequestLocale` has not been called.
|
|
7
|
+
*/
|
|
8
|
+
declare const getCachedRequestLocale: () => LocalesValues | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Store the locale for the current request. Called by `setRequestLocale`.
|
|
11
|
+
*
|
|
12
|
+
* @param locale - The locale resolved from the `[locale]` route segment.
|
|
13
|
+
*/
|
|
14
|
+
declare const setCachedRequestLocale: (locale: LocalesValues) => void;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { getCachedRequestLocale, setCachedRequestLocale };
|
|
17
|
+
//# sourceMappingURL=requestLocaleCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestLocaleCache.d.ts","names":[],"sources":["../../../src/server/requestLocaleCache.ts"],"mappings":";;;;;AAuBA;;cAAa,sBAAA,QAA6B,aAAA;;;AAQ1C;;;cAAa,sBAAA,GAA0B,MAAA,EAAQ,aAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { setRequestLocale as setRequestLocale$1 } from "next-intl/server";
|
|
2
|
+
|
|
3
|
+
//#region src/server/setRequestLocale.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in for next-intl's `setRequestLocale`.
|
|
6
|
+
*
|
|
7
|
+
* In next-intl this stores the locale (typically the `[locale]` route segment)
|
|
8
|
+
* in a request-scoped cache so the rest of the request can render in that
|
|
9
|
+
* locale and opt into static rendering. The compat keeps the same contract:
|
|
10
|
+
* the locale is stored per-request and read back by `getLocale()` (and, through
|
|
11
|
+
* it, `getTranslations` / `getDictionary` / metadata). This is what makes the
|
|
12
|
+
* per-request locale — and therefore the locale switcher — work without relying
|
|
13
|
+
* on a cookie.
|
|
14
|
+
*
|
|
15
|
+
* @param locale - The locale resolved from the `[locale]` route segment.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* export default async function LocaleLayout({ params }) {
|
|
20
|
+
* const { locale } = await params;
|
|
21
|
+
* setRequestLocale(locale);
|
|
22
|
+
* // …
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare const setRequestLocale: typeof setRequestLocale$1;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { setRequestLocale };
|
|
29
|
+
//# sourceMappingURL=setRequestLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setRequestLocale.d.ts","names":[],"sources":["../../../src/server/setRequestLocale.ts"],"mappings":";;;;;AA0BA;;;;;;;;;;;;;;;;;;;;cAAa,gBAAA,SAAyB,kBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/next-intl",
|
|
3
|
-
"version": "9.0.0-canary.
|
|
3
|
+
"version": "9.0.0-canary.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "next-intl API adapter for intlayer — useTranslations, useLocale, getTranslations, getLocale, NextIntlClientProvider backed by next-intlayer",
|
|
6
6
|
"keywords": [
|
|
@@ -36,37 +36,31 @@
|
|
|
36
36
|
"exports": {
|
|
37
37
|
".": {
|
|
38
38
|
"types": "./dist/types/index.d.ts",
|
|
39
|
-
"require": "./dist/cjs/index.cjs",
|
|
40
39
|
"import": "./dist/esm/index.mjs"
|
|
41
40
|
},
|
|
42
41
|
"./server": {
|
|
43
42
|
"types": "./dist/types/server/index.d.ts",
|
|
44
|
-
"require": "./dist/cjs/server/index.cjs",
|
|
45
43
|
"import": "./dist/esm/server/index.mjs"
|
|
46
44
|
},
|
|
47
45
|
"./routing": {
|
|
48
46
|
"types": "./dist/types/routing.d.ts",
|
|
49
|
-
"require": "./dist/cjs/routing.cjs",
|
|
50
47
|
"import": "./dist/esm/routing.mjs"
|
|
51
48
|
},
|
|
52
49
|
"./navigation": {
|
|
53
50
|
"types": "./dist/types/navigation/index.d.ts",
|
|
54
|
-
"require": "./dist/cjs/navigation/index.cjs",
|
|
55
51
|
"import": "./dist/esm/navigation/index.mjs"
|
|
56
52
|
},
|
|
57
53
|
"./middleware": {
|
|
58
54
|
"types": "./dist/types/middleware.d.ts",
|
|
59
|
-
"require": "./dist/cjs/middleware.cjs",
|
|
60
55
|
"import": "./dist/esm/middleware.mjs"
|
|
61
56
|
},
|
|
62
57
|
"./plugin": {
|
|
63
58
|
"types": "./dist/types/plugin/index.d.ts",
|
|
64
|
-
"require": "./dist/cjs/plugin/index.cjs",
|
|
65
59
|
"import": "./dist/esm/plugin/index.mjs"
|
|
66
60
|
},
|
|
67
61
|
"./package.json": "./package.json"
|
|
68
62
|
},
|
|
69
|
-
"main": "dist/
|
|
63
|
+
"main": "dist/esm/index.mjs",
|
|
70
64
|
"module": "dist/esm/index.mjs",
|
|
71
65
|
"types": "dist/types/index.d.ts",
|
|
72
66
|
"typesVersions": {
|
|
@@ -110,16 +104,17 @@
|
|
|
110
104
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
111
105
|
},
|
|
112
106
|
"dependencies": {
|
|
113
|
-
"@intlayer/chokidar": "9.0.0-canary.
|
|
114
|
-
"@intlayer/config": "9.0.0-canary.
|
|
115
|
-
"@intlayer/core": "9.0.0-canary.
|
|
116
|
-
"@intlayer/dictionaries-entry": "9.0.0-canary.
|
|
117
|
-
"@intlayer/types": "9.0.0-canary.
|
|
118
|
-
"
|
|
119
|
-
"
|
|
107
|
+
"@intlayer/chokidar": "9.0.0-canary.4",
|
|
108
|
+
"@intlayer/config": "9.0.0-canary.4",
|
|
109
|
+
"@intlayer/core": "9.0.0-canary.4",
|
|
110
|
+
"@intlayer/dictionaries-entry": "9.0.0-canary.4",
|
|
111
|
+
"@intlayer/types": "9.0.0-canary.4",
|
|
112
|
+
"@intlayer/use-intl": "9.0.0-canary.4",
|
|
113
|
+
"next-intlayer": "9.0.0-canary.4",
|
|
114
|
+
"react-intlayer": "9.0.0-canary.4"
|
|
120
115
|
},
|
|
121
116
|
"devDependencies": {
|
|
122
|
-
"@types/node": "25.9.
|
|
117
|
+
"@types/node": "25.9.4",
|
|
123
118
|
"@types/react": "19.2.17",
|
|
124
119
|
"@utils/ts-config": "1.0.4",
|
|
125
120
|
"@utils/ts-config-types": "1.0.4",
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
5
|
-
const require_createFormatter = require('../createFormatter.cjs');
|
|
6
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
7
|
-
let next_intlayer = require("next-intlayer");
|
|
8
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
-
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
10
|
-
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
11
|
-
|
|
12
|
-
//#region src/client/helpers.tsx
|
|
13
|
-
/**
|
|
14
|
-
* Drop-in for next-intl's `useNow`.
|
|
15
|
-
* Returns the current `Date`. The `updateInterval` option is ignored.
|
|
16
|
-
*/
|
|
17
|
-
const useNow = () => /* @__PURE__ */ new Date();
|
|
18
|
-
/**
|
|
19
|
-
* Drop-in for next-intl's `useTimeZone`.
|
|
20
|
-
* Returns the system time zone resolved from `Intl.DateTimeFormat`.
|
|
21
|
-
*/
|
|
22
|
-
const useTimeZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
23
|
-
/**
|
|
24
|
-
* Drop-in for next-intl's `useMessages`.
|
|
25
|
-
*
|
|
26
|
-
* @deprecated useMessages has no use case with intlayer.
|
|
27
|
-
* Messages are loaded automatically under the hood.
|
|
28
|
-
* @returns An empty object.
|
|
29
|
-
*/
|
|
30
|
-
const useMessages = () => {
|
|
31
|
-
if (process.env.NODE_ENV === "development") (0, _intlayer_config_logger.getAppLogger)({ log: _intlayer_config_built.log })(`${(0, _intlayer_config_logger.colorize)("useMessages", _intlayer_config_colors.CYAN)} has no use case with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`);
|
|
32
|
-
return {};
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Drop-in for next-intl's `useFormatter`.
|
|
36
|
-
* Returns locale-aware formatters backed by the native `Intl.*` APIs:
|
|
37
|
-
* `dateTime`, `number`, `dateTimeRange`, `relativeTime`, `list`, and
|
|
38
|
-
* `displayName`.
|
|
39
|
-
*/
|
|
40
|
-
const useFormatter = () => {
|
|
41
|
-
const { locale } = (0, next_intlayer.useLocale)();
|
|
42
|
-
return require_createFormatter.createFormatter(locale ?? "en");
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Drop-in for next-intl's `IntlProvider`.
|
|
46
|
-
* Renders children as-is — Intlayer provides its own context via
|
|
47
|
-
* `IntlayerClientProvider`.
|
|
48
|
-
*
|
|
49
|
-
* @deprecated IntlProvider has no use case with intlayer.
|
|
50
|
-
* Use `IntlayerClientProvider` or `NextIntlClientProvider` instead.
|
|
51
|
-
*/
|
|
52
|
-
const IntlProvider = ({ children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
|
|
53
|
-
/**
|
|
54
|
-
* @internal Not part of the public next-intl API surface; provided for
|
|
55
|
-
* internal compatibility shims only.
|
|
56
|
-
*/
|
|
57
|
-
const useExtracted = (..._args) => ({});
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
exports.IntlProvider = IntlProvider;
|
|
61
|
-
exports.useExtracted = useExtracted;
|
|
62
|
-
exports.useFormatter = useFormatter;
|
|
63
|
-
exports.useMessages = useMessages;
|
|
64
|
-
exports.useNow = useNow;
|
|
65
|
-
exports.useTimeZone = useTimeZone;
|
|
66
|
-
//# sourceMappingURL=helpers.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.cjs","names":["CYAN","createFormatter"],"sources":["../../../src/client/helpers.tsx"],"sourcesContent":["'use client';\n\nimport { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type {\n IntlProvider as _IntlProvider,\n useFormatter as _useFormatter,\n useMessages as _useMessages,\n useNow as _useNow,\n useTimeZone as _useTimeZone,\n} from 'next-intl';\nimport { useLocale } from 'next-intlayer';\nimport type * as React from 'react';\nimport { createFormatter } from '../createFormatter';\n\n/**\n * Drop-in for next-intl's `useNow`.\n * Returns the current `Date`. The `updateInterval` option is ignored.\n */\nexport const useNow: typeof _useNow = () => new Date();\n\n/**\n * Drop-in for next-intl's `useTimeZone`.\n * Returns the system time zone resolved from `Intl.DateTimeFormat`.\n */\nexport const useTimeZone: typeof _useTimeZone = () =>\n Intl.DateTimeFormat().resolvedOptions().timeZone;\n\n/**\n * Drop-in for next-intl's `useMessages`.\n *\n * @deprecated useMessages has no use case with intlayer.\n * Messages are loaded automatically under the hood.\n * @returns An empty object.\n */\nexport const useMessages: typeof _useMessages = () => {\n if (process.env.NODE_ENV === 'development') {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('useMessages', CYAN)} has no use case with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`\n );\n }\n\n return {} as ReturnType<typeof _useMessages>;\n};\n\n/**\n * Drop-in for next-intl's `useFormatter`.\n * Returns locale-aware formatters backed by the native `Intl.*` APIs:\n * `dateTime`, `number`, `dateTimeRange`, `relativeTime`, `list`, and\n * `displayName`.\n */\nexport const useFormatter: typeof _useFormatter = () => {\n const { locale } = useLocale();\n return createFormatter((locale as string) ?? 'en');\n};\n\ninterface ProviderProps {\n children?: React.ReactNode;\n [key: string]: unknown;\n}\n\n/**\n * Drop-in for next-intl's `IntlProvider`.\n * Renders children as-is — Intlayer provides its own context via\n * `IntlayerClientProvider`.\n *\n * @deprecated IntlProvider has no use case with intlayer.\n * Use `IntlayerClientProvider` or `NextIntlClientProvider` instead.\n */\nexport const IntlProvider: typeof _IntlProvider = ({\n children,\n}: ProviderProps) => <>{children}</>;\n\n/**\n * @internal Not part of the public next-intl API surface; provided for\n * internal compatibility shims only.\n */\nexport const useExtracted = (..._args: unknown[]) => ({});\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,MAAa,+BAA+B,IAAI,MAAM;;;;;AAMtD,MAAa,oBACX,KAAK,gBAAgB,CAAC,iBAAiB,CAAC;;;;;;;;AAS1C,MAAa,oBAAyC;AACpD,KAAI,QAAQ,IAAI,aAAa,cAE3B,2CAD+B,EAAE,iCAAK,CAC7B,CACP,yCAAY,eAAeA,6BAAK,CAAC,iHAClC;AAGH,QAAO,EAAE;;;;;;;;AASX,MAAa,qBAA2C;CACtD,MAAM,EAAE,yCAAsB;AAC9B,QAAOC,wCAAiB,UAAqB,KAAK;;;;;;;;;;AAgBpD,MAAa,gBAAsC,EACjD,eACmB,yEAAG,UAAY;;;;;AAMpC,MAAa,gBAAgB,GAAG,WAAsB,EAAE"}
|