@intlayer/next-intl 9.7.1 → 9.7.3
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 +1 -1
- package/dist/cjs/client/NextIntlClientProvider.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/middleware.cjs.map +1 -1
- package/dist/cjs/navigation/Link.cjs.map +1 -1
- package/dist/cjs/navigation/createNavigation.cjs.map +1 -1
- package/dist/cjs/navigation/hooks.cjs +1 -1
- package/dist/cjs/navigation/hooks.cjs.map +1 -1
- package/dist/esm/client/NextIntlClientProvider.mjs +1 -1
- package/dist/esm/client/NextIntlClientProvider.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/middleware.mjs.map +1 -1
- package/dist/esm/navigation/Link.mjs.map +1 -1
- package/dist/esm/navigation/createNavigation.mjs.map +1 -1
- package/dist/esm/navigation/hooks.mjs +1 -1
- package/dist/esm/navigation/hooks.mjs.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +49 -49
|
@@ -5,8 +5,8 @@ let _intlayer_config_built = require("@intlayer/config/built");
|
|
|
5
5
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
6
6
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
7
7
|
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
8
|
-
let next_navigation = require("next/navigation");
|
|
9
8
|
let next_intlayer = require("next-intlayer");
|
|
9
|
+
let next_navigation = require("next/navigation");
|
|
10
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
11
|
|
|
12
12
|
// src/client/NextIntlClientProvider.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextIntlClientProvider.cjs","names":["getAppLogger","colorize","CYAN","usePathname","routing","getLocaleFromPath","IntlayerProvider"],"sources":["../../../src/client/NextIntlClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { log, routing } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getLocaleFromPath } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {
|
|
1
|
+
{"version":3,"file":"NextIntlClientProvider.cjs","names":["getAppLogger","colorize","CYAN","usePathname","routing","getLocaleFromPath","IntlayerProvider"],"sources":["../../../src/client/NextIntlClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { log, routing } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getLocaleFromPath } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { NextIntlClientProvider as _NextIntlClientProvider } from 'next-intl';\nimport { IntlayerProvider } from 'next-intlayer';\nimport { usePathname } from 'next/navigation';\nimport type { ComponentProps } from 'react';\n\n/**\n * Drop-in for next-intl's `NextIntlClientProvider`.\n * `messages`, `timeZone`, and `now` are accepted for API compatibility\n * but have no effect — Intlayer uses its own compiled dictionaries.\n */\nexport const NextIntlClientProvider: typeof _NextIntlClientProvider = ({\n locale,\n children,\n messages: _messages,\n timeZone: _timeZone,\n now: _now,\n ...rest\n}) => {\n if (\n process.env.NODE_ENV === 'development' &&\n typeof _messages !== 'undefined'\n ) {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('NextIntlClientProvider', CYAN)} do not pass the messages prop with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`\n );\n }\n\n // next-intl drives the locale from the request: apps render\n // `<NextIntlClientProvider>` without a `locale` prop and the server resolves it\n // from the `[locale]` route segment. As a client component we cannot read the\n // server request here, so when no explicit `locale` is given we derive it from\n // the URL (the same `[locale]` segment) using Intlayer's routing config. This\n // keeps `useLocale`, `Link` and the locale switcher in sync with the URL\n // instead of falling back to the stored cookie / default locale.\n //\n // Only prefix-based routing carries the locale in the path. For `no-prefix` /\n // `search-params` the path has no locale segment, so we leave `locale`\n // undefined and let the provider resolve it from storage (cookie) — deriving\n // from the path there would wrongly clobber the cookie with the default locale.\n const pathname = usePathname();\n const mode = routing?.mode ?? 'prefix-no-default';\n const isPrefixMode = mode === 'prefix-all' || mode === 'prefix-no-default';\n const resolvedLocale =\n locale ?? (isPrefixMode ? getLocaleFromPath(pathname) : undefined);\n\n // `key={resolvedLocale}` remounts the provider when the locale changes via\n // navigation (next-intl switches locale by routing to a locale-prefixed path).\n // This re-seeds the client locale context so client components re-render in\n // the new language instead of keeping the previous one.\n return (\n <IntlayerProvider\n key={String(resolvedLocale)}\n locale={resolvedLocale}\n {...rest}\n >\n {children}\n </IntlayerProvider>\n );\n};\n\n/**\n *\n */\nexport type NextIntlClientProviderProps = Omit<\n ComponentProps<typeof _NextIntlClientProvider>,\n 'messages'\n> & {\n /**\n * @deprecated\n * has no use case with intlayer. Messages are loaded automatically under the hood for bundle optimization reason\n */\n messages?: never;\n /**\n * locale\n */\n locale: LocalesValues;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA0D,EACrE,QACA,UACA,UAAU,WACV,UAAU,WACV,KAAK,MACL,GAAG,WACC;CACJ,6BAC2B,iBACzB,OAAO,cAAc,aAGrB,IADkBA,sCAAa,EAAE,gCAAI,CAC7B,CAAC,CACP,OAAGC,kCAAS,0BAA0BC,4BAAI,EAAE,8HAC9C;CAeF,MAAM,eAAWC,6BAAY;CAC7B,MAAM,OAAOC,gCAAS,QAAQ;CAE9B,MAAM,iBACJ,WAFmB,SAAS,gBAAgB,SAAS,0BAE3BC,+CAAkB,QAAQ,IAAI;CAM1D,OACE,2CAACC,gCAAD;EAEE,QAAQ;EACR,GAAI;EAEH;CACe,GALX,OAAO,cAAc,CAKV;AAEtB"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_routing = require("./routing.cjs");
|
|
2
3
|
const require_client_NextIntlClientProvider = require("./client/NextIntlClientProvider.cjs");
|
|
3
4
|
const require_client_useLocale = require("./client/useLocale.cjs");
|
|
4
|
-
const require_routing = require("./routing.cjs");
|
|
5
5
|
let _intlayer_use_intl = require("@intlayer/use-intl");
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "IntlError", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.cjs","names":["intlayerMiddleware"],"sources":["../../src/middleware.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"middleware.cjs","names":["intlayerMiddleware"],"sources":["../../src/middleware.ts"],"sourcesContent":["import type _createMiddleware from 'next-intl/middleware';\nimport { intlayerMiddleware } from 'next-intlayer/middleware';\nimport type { NextFetchEvent, NextRequest } from 'next/server';\n\n/**\n * Drop-in replacement for next-intl's `createMiddleware`.\n *\n * Returns Intlayer's proxy/middleware, which handles locale detection and\n * routing from the Intlayer configuration. The `routing` argument is accepted\n * for API compatibility but ignored — locales come from `intlayer.config`.\n *\n * @example\n * ```ts\n * // proxy.ts (or middleware.ts on Next <= 15)\n * import createMiddleware from 'next-intl/middleware';\n * export default createMiddleware(routing);\n * export const config = { matcher: ['/((?!api|_next|.*\\\\..*).*)'] };\n * ```\n */\nexport const createMiddleware: typeof _createMiddleware =\n (_routing?: unknown) => (request: NextRequest, event?: NextFetchEvent) => {\n const response = intlayerMiddleware(request, event);\n\n if (response) {\n // Intlayer middleware writes the resolved locale to the x-intlayer-locale header\n // We read it and explicitly set the NEXT_LOCALE cookie to maintain compatibility with next-intl\n const resolvedLocale = response.headers.get('x-intlayer-locale');\n if (resolvedLocale) {\n response.cookies.set('NEXT_LOCALE', resolvedLocale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n }\n }\n\n return response;\n };\n\nexport default createMiddleware;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAa,oBACV,cAAwB,SAAsB,UAA2B;CACxE,MAAM,eAAWA,6CAAmB,SAAS,KAAK;CAElD,IAAI,UAAU;EAGZ,MAAM,iBAAiB,SAAS,QAAQ,IAAI,mBAAmB;EAC/D,IAAI,gBACF,SAAS,QAAQ,IAAI,eAAe,gBAAgB;GAClD,MAAM;GACN,UAAU;GACV,QAAQ;EACV,CAAC;CAEL;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.cjs","names":["forwardRef","useLocale","NextLink","localizeHref"],"sources":["../../../src/navigation/Link.tsx"],"sourcesContent":["'use client';\n\nimport
|
|
1
|
+
{"version":3,"file":"Link.cjs","names":["forwardRef","useLocale","NextLink","localizeHref"],"sources":["../../../src/navigation/Link.tsx"],"sourcesContent":["'use client';\n\nimport { useLocale } from 'next-intlayer';\nimport NextLink from 'next/link';\nimport { type ComponentPropsWithoutRef, forwardRef, type Ref } from 'react';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/**\n * Props for the compat `Link`: identical to `next/link` except `href` accepts a\n * `next-intl` href and an optional `locale` overrides the current one.\n */\nexport type LinkProps = Omit<\n ComponentPropsWithoutRef<typeof NextLink>,\n 'href' | 'locale'\n> & {\n href: NextIntlHref;\n locale?: string;\n};\n\n/**\n * Drop-in for the `Link` returned by next-intl's `createNavigation`. Prefixes\n * `href` with the active locale (or the `locale` prop) before delegating to\n * `next/link`.\n */\nexport const Link = forwardRef(\n ({ href, locale, ...rest }: LinkProps, ref: Ref<HTMLAnchorElement>) => {\n const { locale: currentLocale } = useLocale();\n const targetLocale = locale ?? (currentLocale as string);\n\n return (\n <NextLink ref={ref} href={localizeHref(href, targetLocale)} {...rest} />\n );\n }\n);\n\nLink.displayName = 'Link';\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,MAAa,WAAOA,mBACjB,EAAE,MAAM,QAAQ,GAAG,QAAmB,QAAgC;CACrE,MAAM,EAAE,QAAQ,sBAAkBC,yBAAU;CAG5C,OACE,2CAACC,mBAAD;EAAe;EAAK,MAAMC,6CAAa,MAHpB,UAAW,aAG2B;EAAG,GAAI;CAAO;AAE3E,CACF;AAEA,KAAK,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNavigation.cjs","names":["localizeHref","nextRedirect","nextPermanentRedirect","Link"],"sources":["../../../src/navigation/createNavigation.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"createNavigation.cjs","names":["localizeHref","nextRedirect","nextPermanentRedirect","Link"],"sources":["../../../src/navigation/createNavigation.ts"],"sourcesContent":["import type { createNavigation as _createNavigation } from 'next-intl/navigation';\nimport {\n permanentRedirect as nextPermanentRedirect,\n redirect as nextRedirect,\n} from 'next/navigation';\nimport { usePathname, useRouter } from './hooks';\nimport { Link } from './Link';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/** Arguments shared by `getPathname`, `redirect` and `permanentRedirect`. */\ntype LocalizedHrefArgs = { href: NextIntlHref; locale: string };\n\n/** The optional `RedirectType` accepted by `next/navigation`'s redirect APIs. */\ntype RedirectTypeArg = Parameters<typeof nextRedirect>[1];\n\n/**\n * Drop-in replacement for next-intl's `createNavigation`.\n *\n * Returns locale-aware navigation APIs (`Link`, `usePathname`, `useRouter`,\n * `getPathname`, `redirect`, `permanentRedirect`) backed by Intlayer's routing\n * configuration. The `routing` argument is accepted for API compatibility;\n * locales come from the Intlayer configuration.\n *\n * @example\n * ```ts\n * export const { Link, redirect, usePathname, useRouter, getPathname } =\n * createNavigation();\n * ```\n */\nexport const createNavigation: typeof _createNavigation = (\n _routing?: unknown\n) => {\n const getPathname = ({ href, locale }: LocalizedHrefArgs): string =>\n localizeHref(href, locale);\n\n const redirect = (\n { href, locale }: LocalizedHrefArgs,\n type?: RedirectTypeArg\n ) => nextRedirect(localizeHref(href, locale), type);\n\n const permanentRedirect = (\n { href, locale }: LocalizedHrefArgs,\n type?: RedirectTypeArg\n ) => nextPermanentRedirect(localizeHref(href, locale), type);\n\n return {\n Link: Link as ReturnType<typeof _createNavigation>['Link'],\n usePathname,\n useRouter,\n getPathname,\n redirect,\n permanentRedirect,\n } as ReturnType<typeof _createNavigation>;\n};\n\nexport default createNavigation;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,oBACX,aACG;CACH,MAAM,eAAe,EAAE,MAAM,aAC3BA,6CAAa,MAAM,MAAM;CAE3B,MAAM,YACJ,EAAE,MAAM,UACR,aACGC,0BAAaD,6CAAa,MAAM,MAAM,GAAG,IAAI;CAElD,MAAM,qBACJ,EAAE,MAAM,UACR,aACGE,mCAAsBF,6CAAa,MAAM,MAAM,GAAG,IAAI;CAE3D,OAAO;EACL,MAAMG;EACN;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_navigation_localizeHref = require("./localizeHref.cjs");
|
|
5
|
-
let next_navigation = require("next/navigation");
|
|
6
5
|
let next_intlayer = require("next-intlayer");
|
|
6
|
+
let next_navigation = require("next/navigation");
|
|
7
7
|
|
|
8
8
|
// src/navigation/hooks.ts
|
|
9
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.cjs","names":["useNextPathname","useLocale","useNextRouter","localizeHref"],"sources":["../../../src/navigation/hooks.ts"],"sourcesContent":["'use client';\n\nimport {\n usePathname as useNextPathname,\n useRouter as useNextRouter,\n} from 'next/navigation';\nimport {
|
|
1
|
+
{"version":3,"file":"hooks.cjs","names":["useNextPathname","useLocale","useNextRouter","localizeHref"],"sources":["../../../src/navigation/hooks.ts"],"sourcesContent":["'use client';\n\nimport { useLocale } from 'next-intlayer';\nimport {\n usePathname as useNextPathname,\n useRouter as useNextRouter,\n} from 'next/navigation';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/**\n * Options accepted by the locale-aware router methods: the standard Next.js\n * navigate options plus an optional target `locale`.\n */\ntype NavigateOptions = { locale?: string } & Record<string, unknown>;\n\n/**\n * Drop-in for the `usePathname` returned by next-intl's `createNavigation`.\n * Returns the current pathname with the locale prefix stripped.\n */\nexport const usePathname = (): string => {\n const pathname = useNextPathname();\n const { locale } = useLocale();\n const prefix = `/${locale}`;\n\n if (pathname === prefix) return '/';\n if (pathname.startsWith(`${prefix}/`)) return pathname.slice(prefix.length);\n return pathname;\n};\n\n/**\n * Drop-in for the `useRouter` returned by next-intl's `createNavigation`.\n * Wraps the Next.js router so `push`/`replace`/`prefetch` localize their href\n * (honouring an optional `locale` option) before navigating.\n */\nexport const useRouter = () => {\n const router = useNextRouter();\n const { locale: currentLocale } = useLocale();\n\n const localize = (href: NextIntlHref, locale?: string): string =>\n localizeHref(href, locale ?? (currentLocale as string));\n\n return {\n ...router,\n push: (href: NextIntlHref, options?: NavigateOptions) =>\n router.push(\n localize(href, options?.locale),\n options as Parameters<typeof router.push>[1]\n ),\n replace: (href: NextIntlHref, options?: NavigateOptions) =>\n router.replace(\n localize(href, options?.locale),\n options as Parameters<typeof router.replace>[1]\n ),\n prefetch: (href: NextIntlHref, options?: NavigateOptions) =>\n router.prefetch(localize(href, options?.locale)),\n };\n};\n"],"mappings":";;;;;;;;;;;;AAmBA,MAAa,oBAA4B;CACvC,MAAM,eAAWA,6BAAgB;CACjC,MAAM,EAAE,eAAWC,yBAAU;CAC7B,MAAM,SAAS,IAAI;CAEnB,IAAI,aAAa,QAAQ,OAAO;CAChC,IAAI,SAAS,WAAW,GAAG,OAAO,EAAE,GAAG,OAAO,SAAS,MAAM,OAAO,MAAM;CAC1E,OAAO;AACT;;;;;;AAOA,MAAa,kBAAkB;CAC7B,MAAM,aAASC,2BAAc;CAC7B,MAAM,EAAE,QAAQ,sBAAkBD,yBAAU;CAE5C,MAAM,YAAY,MAAoB,WACpCE,6CAAa,MAAM,UAAW,aAAwB;CAExD,OAAO;EACL,GAAG;EACH,OAAO,MAAoB,YACzB,OAAO,KACL,SAAS,MAAM,SAAS,MAAM,GAC9B,OACF;EACF,UAAU,MAAoB,YAC5B,OAAO,QACL,SAAS,MAAM,SAAS,MAAM,GAC9B,OACF;EACF,WAAW,MAAoB,YAC7B,OAAO,SAAS,SAAS,MAAM,SAAS,MAAM,CAAC;CACnD;AACF"}
|
|
@@ -4,8 +4,8 @@ import { log, routing } from "@intlayer/config/built";
|
|
|
4
4
|
import { CYAN } from "@intlayer/config/colors";
|
|
5
5
|
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
6
6
|
import { getLocaleFromPath } from "@intlayer/core/localization";
|
|
7
|
-
import { usePathname } from "next/navigation";
|
|
8
7
|
import { IntlayerProvider } from "next-intlayer";
|
|
8
|
+
import { usePathname } from "next/navigation";
|
|
9
9
|
import { jsx } from "react/jsx-runtime";
|
|
10
10
|
|
|
11
11
|
// src/client/NextIntlClientProvider.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextIntlClientProvider.mjs","names":[],"sources":["../../../src/client/NextIntlClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { log, routing } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getLocaleFromPath } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {
|
|
1
|
+
{"version":3,"file":"NextIntlClientProvider.mjs","names":[],"sources":["../../../src/client/NextIntlClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { log, routing } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getLocaleFromPath } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { NextIntlClientProvider as _NextIntlClientProvider } from 'next-intl';\nimport { IntlayerProvider } from 'next-intlayer';\nimport { usePathname } from 'next/navigation';\nimport type { ComponentProps } from 'react';\n\n/**\n * Drop-in for next-intl's `NextIntlClientProvider`.\n * `messages`, `timeZone`, and `now` are accepted for API compatibility\n * but have no effect — Intlayer uses its own compiled dictionaries.\n */\nexport const NextIntlClientProvider: typeof _NextIntlClientProvider = ({\n locale,\n children,\n messages: _messages,\n timeZone: _timeZone,\n now: _now,\n ...rest\n}) => {\n if (\n process.env.NODE_ENV === 'development' &&\n typeof _messages !== 'undefined'\n ) {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('NextIntlClientProvider', CYAN)} do not pass the messages prop with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`\n );\n }\n\n // next-intl drives the locale from the request: apps render\n // `<NextIntlClientProvider>` without a `locale` prop and the server resolves it\n // from the `[locale]` route segment. As a client component we cannot read the\n // server request here, so when no explicit `locale` is given we derive it from\n // the URL (the same `[locale]` segment) using Intlayer's routing config. This\n // keeps `useLocale`, `Link` and the locale switcher in sync with the URL\n // instead of falling back to the stored cookie / default locale.\n //\n // Only prefix-based routing carries the locale in the path. For `no-prefix` /\n // `search-params` the path has no locale segment, so we leave `locale`\n // undefined and let the provider resolve it from storage (cookie) — deriving\n // from the path there would wrongly clobber the cookie with the default locale.\n const pathname = usePathname();\n const mode = routing?.mode ?? 'prefix-no-default';\n const isPrefixMode = mode === 'prefix-all' || mode === 'prefix-no-default';\n const resolvedLocale =\n locale ?? (isPrefixMode ? getLocaleFromPath(pathname) : undefined);\n\n // `key={resolvedLocale}` remounts the provider when the locale changes via\n // navigation (next-intl switches locale by routing to a locale-prefixed path).\n // This re-seeds the client locale context so client components re-render in\n // the new language instead of keeping the previous one.\n return (\n <IntlayerProvider\n key={String(resolvedLocale)}\n locale={resolvedLocale}\n {...rest}\n >\n {children}\n </IntlayerProvider>\n );\n};\n\n/**\n *\n */\nexport type NextIntlClientProviderProps = Omit<\n ComponentProps<typeof _NextIntlClientProvider>,\n 'messages'\n> & {\n /**\n * @deprecated\n * has no use case with intlayer. Messages are loaded automatically under the hood for bundle optimization reason\n */\n messages?: never;\n /**\n * locale\n */\n locale: LocalesValues;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA0D,EACrE,QACA,UACA,UAAU,WACV,UAAU,WACV,KAAK,MACL,GAAG,WACC;CACJ,6BAC2B,iBACzB,OAAO,cAAc,aAGrB,AADkB,aAAa,EAAE,IAAI,CAC7B,CAAC,CACP,GAAG,SAAS,0BAA0B,IAAI,EAAE,8HAC9C;CAeF,MAAM,WAAW,YAAY;CAC7B,MAAM,OAAO,SAAS,QAAQ;CAE9B,MAAM,iBACJ,WAFmB,SAAS,gBAAgB,SAAS,sBAE3B,kBAAkB,QAAQ,IAAI;CAM1D,OACE,oBAAC,kBAAD;EAEE,QAAQ;EACR,GAAI;EAEH;CACe,GALX,OAAO,cAAc,CAKV;AAEtB"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { IntlProvider, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useMessages, useNow, useTimeZone, useTranslations } from "./client/index.mjs";
|
|
1
2
|
import { NextIntlClientProvider } from "./client/NextIntlClientProvider.mjs";
|
|
2
3
|
import { useLocale } from "./client/useLocale.mjs";
|
|
3
|
-
import { IntlProvider, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useMessages, useNow, useTimeZone, useTranslations } from "./client/index.mjs";
|
|
4
4
|
import { defineRouting } from "./routing.mjs";
|
|
5
5
|
import { IntlError, IntlErrorCode, createFormatter, createTranslator, hasLocale, initializeConfig } from "@intlayer/use-intl";
|
|
6
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.mjs","names":[],"sources":["../../src/middleware.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"middleware.mjs","names":[],"sources":["../../src/middleware.ts"],"sourcesContent":["import type _createMiddleware from 'next-intl/middleware';\nimport { intlayerMiddleware } from 'next-intlayer/middleware';\nimport type { NextFetchEvent, NextRequest } from 'next/server';\n\n/**\n * Drop-in replacement for next-intl's `createMiddleware`.\n *\n * Returns Intlayer's proxy/middleware, which handles locale detection and\n * routing from the Intlayer configuration. The `routing` argument is accepted\n * for API compatibility but ignored — locales come from `intlayer.config`.\n *\n * @example\n * ```ts\n * // proxy.ts (or middleware.ts on Next <= 15)\n * import createMiddleware from 'next-intl/middleware';\n * export default createMiddleware(routing);\n * export const config = { matcher: ['/((?!api|_next|.*\\\\..*).*)'] };\n * ```\n */\nexport const createMiddleware: typeof _createMiddleware =\n (_routing?: unknown) => (request: NextRequest, event?: NextFetchEvent) => {\n const response = intlayerMiddleware(request, event);\n\n if (response) {\n // Intlayer middleware writes the resolved locale to the x-intlayer-locale header\n // We read it and explicitly set the NEXT_LOCALE cookie to maintain compatibility with next-intl\n const resolvedLocale = response.headers.get('x-intlayer-locale');\n if (resolvedLocale) {\n response.cookies.set('NEXT_LOCALE', resolvedLocale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n }\n }\n\n return response;\n };\n\nexport default createMiddleware;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAa,oBACV,cAAwB,SAAsB,UAA2B;CACxE,MAAM,WAAW,mBAAmB,SAAS,KAAK;CAElD,IAAI,UAAU;EAGZ,MAAM,iBAAiB,SAAS,QAAQ,IAAI,mBAAmB;EAC/D,IAAI,gBACF,SAAS,QAAQ,IAAI,eAAe,gBAAgB;GAClD,MAAM;GACN,UAAU;GACV,QAAQ;EACV,CAAC;CAEL;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.mjs","names":[],"sources":["../../../src/navigation/Link.tsx"],"sourcesContent":["'use client';\n\nimport
|
|
1
|
+
{"version":3,"file":"Link.mjs","names":[],"sources":["../../../src/navigation/Link.tsx"],"sourcesContent":["'use client';\n\nimport { useLocale } from 'next-intlayer';\nimport NextLink from 'next/link';\nimport { type ComponentPropsWithoutRef, forwardRef, type Ref } from 'react';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/**\n * Props for the compat `Link`: identical to `next/link` except `href` accepts a\n * `next-intl` href and an optional `locale` overrides the current one.\n */\nexport type LinkProps = Omit<\n ComponentPropsWithoutRef<typeof NextLink>,\n 'href' | 'locale'\n> & {\n href: NextIntlHref;\n locale?: string;\n};\n\n/**\n * Drop-in for the `Link` returned by next-intl's `createNavigation`. Prefixes\n * `href` with the active locale (or the `locale` prop) before delegating to\n * `next/link`.\n */\nexport const Link = forwardRef(\n ({ href, locale, ...rest }: LinkProps, ref: Ref<HTMLAnchorElement>) => {\n const { locale: currentLocale } = useLocale();\n const targetLocale = locale ?? (currentLocale as string);\n\n return (\n <NextLink ref={ref} href={localizeHref(href, targetLocale)} {...rest} />\n );\n }\n);\n\nLink.displayName = 'Link';\n"],"mappings":";;;;;;;;;;;;;;AAwBA,MAAa,OAAO,YACjB,EAAE,MAAM,QAAQ,GAAG,QAAmB,QAAgC;CACrE,MAAM,EAAE,QAAQ,kBAAkB,UAAU;CAG5C,OACE,oBAAC,UAAD;EAAe;EAAK,MAAM,aAAa,MAHpB,UAAW,aAG2B;EAAG,GAAI;CAAO;AAE3E,CACF;AAEA,KAAK,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNavigation.mjs","names":["redirect","nextRedirect","permanentRedirect","nextPermanentRedirect"],"sources":["../../../src/navigation/createNavigation.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"createNavigation.mjs","names":["redirect","nextRedirect","permanentRedirect","nextPermanentRedirect"],"sources":["../../../src/navigation/createNavigation.ts"],"sourcesContent":["import type { createNavigation as _createNavigation } from 'next-intl/navigation';\nimport {\n permanentRedirect as nextPermanentRedirect,\n redirect as nextRedirect,\n} from 'next/navigation';\nimport { usePathname, useRouter } from './hooks';\nimport { Link } from './Link';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/** Arguments shared by `getPathname`, `redirect` and `permanentRedirect`. */\ntype LocalizedHrefArgs = { href: NextIntlHref; locale: string };\n\n/** The optional `RedirectType` accepted by `next/navigation`'s redirect APIs. */\ntype RedirectTypeArg = Parameters<typeof nextRedirect>[1];\n\n/**\n * Drop-in replacement for next-intl's `createNavigation`.\n *\n * Returns locale-aware navigation APIs (`Link`, `usePathname`, `useRouter`,\n * `getPathname`, `redirect`, `permanentRedirect`) backed by Intlayer's routing\n * configuration. The `routing` argument is accepted for API compatibility;\n * locales come from the Intlayer configuration.\n *\n * @example\n * ```ts\n * export const { Link, redirect, usePathname, useRouter, getPathname } =\n * createNavigation();\n * ```\n */\nexport const createNavigation: typeof _createNavigation = (\n _routing?: unknown\n) => {\n const getPathname = ({ href, locale }: LocalizedHrefArgs): string =>\n localizeHref(href, locale);\n\n const redirect = (\n { href, locale }: LocalizedHrefArgs,\n type?: RedirectTypeArg\n ) => nextRedirect(localizeHref(href, locale), type);\n\n const permanentRedirect = (\n { href, locale }: LocalizedHrefArgs,\n type?: RedirectTypeArg\n ) => nextPermanentRedirect(localizeHref(href, locale), type);\n\n return {\n Link: Link as ReturnType<typeof _createNavigation>['Link'],\n usePathname,\n useRouter,\n getPathname,\n redirect,\n permanentRedirect,\n } as ReturnType<typeof _createNavigation>;\n};\n\nexport default createNavigation;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,oBACX,aACG;CACH,MAAM,eAAe,EAAE,MAAM,aAC3B,aAAa,MAAM,MAAM;CAE3B,MAAMA,cACJ,EAAE,MAAM,UACR,SACGC,SAAa,aAAa,MAAM,MAAM,GAAG,IAAI;CAElD,MAAMC,uBACJ,EAAE,MAAM,UACR,SACGC,kBAAsB,aAAa,MAAM,MAAM,GAAG,IAAI;CAE3D,OAAO;EACC;EACN;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { localizeHref } from "./localizeHref.mjs";
|
|
4
|
-
import { usePathname as usePathname$1, useRouter as useRouter$1 } from "next/navigation";
|
|
5
4
|
import { useLocale } from "next-intlayer";
|
|
5
|
+
import { usePathname as usePathname$1, useRouter as useRouter$1 } from "next/navigation";
|
|
6
6
|
|
|
7
7
|
// src/navigation/hooks.ts
|
|
8
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.mjs","names":["useNextPathname","useNextRouter"],"sources":["../../../src/navigation/hooks.ts"],"sourcesContent":["'use client';\n\nimport {\n usePathname as useNextPathname,\n useRouter as useNextRouter,\n} from 'next/navigation';\nimport {
|
|
1
|
+
{"version":3,"file":"hooks.mjs","names":["useNextPathname","useNextRouter"],"sources":["../../../src/navigation/hooks.ts"],"sourcesContent":["'use client';\n\nimport { useLocale } from 'next-intlayer';\nimport {\n usePathname as useNextPathname,\n useRouter as useNextRouter,\n} from 'next/navigation';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/**\n * Options accepted by the locale-aware router methods: the standard Next.js\n * navigate options plus an optional target `locale`.\n */\ntype NavigateOptions = { locale?: string } & Record<string, unknown>;\n\n/**\n * Drop-in for the `usePathname` returned by next-intl's `createNavigation`.\n * Returns the current pathname with the locale prefix stripped.\n */\nexport const usePathname = (): string => {\n const pathname = useNextPathname();\n const { locale } = useLocale();\n const prefix = `/${locale}`;\n\n if (pathname === prefix) return '/';\n if (pathname.startsWith(`${prefix}/`)) return pathname.slice(prefix.length);\n return pathname;\n};\n\n/**\n * Drop-in for the `useRouter` returned by next-intl's `createNavigation`.\n * Wraps the Next.js router so `push`/`replace`/`prefetch` localize their href\n * (honouring an optional `locale` option) before navigating.\n */\nexport const useRouter = () => {\n const router = useNextRouter();\n const { locale: currentLocale } = useLocale();\n\n const localize = (href: NextIntlHref, locale?: string): string =>\n localizeHref(href, locale ?? (currentLocale as string));\n\n return {\n ...router,\n push: (href: NextIntlHref, options?: NavigateOptions) =>\n router.push(\n localize(href, options?.locale),\n options as Parameters<typeof router.push>[1]\n ),\n replace: (href: NextIntlHref, options?: NavigateOptions) =>\n router.replace(\n localize(href, options?.locale),\n options as Parameters<typeof router.replace>[1]\n ),\n prefetch: (href: NextIntlHref, options?: NavigateOptions) =>\n router.prefetch(localize(href, options?.locale)),\n };\n};\n"],"mappings":";;;;;;;;;;;AAmBA,MAAa,oBAA4B;CACvC,MAAM,WAAWA,cAAgB;CACjC,MAAM,EAAE,WAAW,UAAU;CAC7B,MAAM,SAAS,IAAI;CAEnB,IAAI,aAAa,QAAQ,OAAO;CAChC,IAAI,SAAS,WAAW,GAAG,OAAO,EAAE,GAAG,OAAO,SAAS,MAAM,OAAO,MAAM;CAC1E,OAAO;AACT;;;;;;AAOA,MAAa,kBAAkB;CAC7B,MAAM,SAASC,YAAc;CAC7B,MAAM,EAAE,QAAQ,kBAAkB,UAAU;CAE5C,MAAM,YAAY,MAAoB,WACpC,aAAa,MAAM,UAAW,aAAwB;CAExD,OAAO;EACL,GAAG;EACH,OAAO,MAAoB,YACzB,OAAO,KACL,SAAS,MAAM,SAAS,MAAM,GAC9B,OACF;EACF,UAAU,MAAoB,YAC5B,OAAO,QACL,SAAS,MAAM,SAAS,MAAM,GAC9B,OACF;EACF,WAAW,MAAoB,YAC7B,OAAO,SAAS,SAAS,MAAM,SAAS,MAAM,CAAC;CACnD;AACF"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { IntlProvider, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useMessages, useNow, useTimeZone, useTranslations } from "./client/index.js";
|
|
1
2
|
import { NextIntlClientProvider, NextIntlClientProviderProps } from "./client/NextIntlClientProvider.js";
|
|
2
3
|
import { useLocale } from "./client/useLocale.js";
|
|
3
|
-
import { IntlProvider, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useMessages, useNow, useTimeZone, useTranslations } from "./client/index.js";
|
|
4
4
|
import { Routing, defineRouting } from "./routing.js";
|
|
5
5
|
import { IntlError, IntlErrorCode, createFormatter, createTranslator, hasLocale, initializeConfig } from "@intlayer/use-intl";
|
|
6
6
|
export { IntlError, IntlErrorCode, IntlProvider, NextIntlClientProvider, type NextIntlClientProviderProps, type Routing, createFormatter, createTranslator, defineRouting, hasLocale, initializeConfig, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
|
package/package.json
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/next-intl",
|
|
3
|
-
"version": "9.7.
|
|
3
|
+
"version": "9.7.3",
|
|
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": [
|
|
7
|
+
"adapter",
|
|
8
|
+
"compatibility",
|
|
9
|
+
"i18n",
|
|
7
10
|
"intlayer",
|
|
8
11
|
"next-intl",
|
|
9
12
|
"next.js",
|
|
10
|
-
"react"
|
|
11
|
-
"i18n",
|
|
12
|
-
"adapter",
|
|
13
|
-
"compatibility"
|
|
13
|
+
"react"
|
|
14
14
|
],
|
|
15
15
|
"homepage": "https://intlayer.org",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/aymericzip/intlayer/issues"
|
|
18
18
|
},
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/aymericzip/intlayer.git"
|
|
22
|
-
},
|
|
23
19
|
"license": "Apache-2.0",
|
|
24
20
|
"author": {
|
|
25
21
|
"name": "Aymeric PINEAU",
|
|
@@ -32,7 +28,37 @@
|
|
|
32
28
|
"url": "https://github.com/aymericzip"
|
|
33
29
|
}
|
|
34
30
|
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/aymericzip/intlayer.git"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"./dist",
|
|
37
|
+
"./package.json"
|
|
38
|
+
],
|
|
35
39
|
"sideEffects": false,
|
|
40
|
+
"main": "dist/cjs/index.cjs",
|
|
41
|
+
"module": "dist/esm/index.mjs",
|
|
42
|
+
"types": "dist/types/index.d.ts",
|
|
43
|
+
"typesVersions": {
|
|
44
|
+
"*": {
|
|
45
|
+
"server": [
|
|
46
|
+
"./dist/types/server/index.d.ts"
|
|
47
|
+
],
|
|
48
|
+
"routing": [
|
|
49
|
+
"./dist/types/routing.d.ts"
|
|
50
|
+
],
|
|
51
|
+
"navigation": [
|
|
52
|
+
"./dist/types/navigation/index.d.ts"
|
|
53
|
+
],
|
|
54
|
+
"middleware": [
|
|
55
|
+
"./dist/types/middleware.d.ts"
|
|
56
|
+
],
|
|
57
|
+
"plugin": [
|
|
58
|
+
"./dist/types/plugin/index.d.ts"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
36
62
|
"exports": {
|
|
37
63
|
".": {
|
|
38
64
|
"types": "./dist/types/index.d.ts",
|
|
@@ -67,41 +93,15 @@
|
|
|
67
93
|
},
|
|
68
94
|
"./package.json": "./package.json"
|
|
69
95
|
},
|
|
70
|
-
"main": "dist/cjs/index.cjs",
|
|
71
|
-
"module": "dist/esm/index.mjs",
|
|
72
|
-
"types": "dist/types/index.d.ts",
|
|
73
|
-
"typesVersions": {
|
|
74
|
-
"*": {
|
|
75
|
-
"server": [
|
|
76
|
-
"./dist/types/server/index.d.ts"
|
|
77
|
-
],
|
|
78
|
-
"routing": [
|
|
79
|
-
"./dist/types/routing.d.ts"
|
|
80
|
-
],
|
|
81
|
-
"navigation": [
|
|
82
|
-
"./dist/types/navigation/index.d.ts"
|
|
83
|
-
],
|
|
84
|
-
"middleware": [
|
|
85
|
-
"./dist/types/middleware.d.ts"
|
|
86
|
-
],
|
|
87
|
-
"plugin": [
|
|
88
|
-
"./dist/types/plugin/index.d.ts"
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
"files": [
|
|
93
|
-
"./dist",
|
|
94
|
-
"./package.json"
|
|
95
|
-
],
|
|
96
96
|
"scripts": {
|
|
97
97
|
"build": "bun --bun tsdown --config tsdown.config.ts",
|
|
98
98
|
"build:ci": "bun --bun tsdown --config tsdown.config.ts",
|
|
99
99
|
"clean": "bun --bun rimraf ./dist .turbo",
|
|
100
100
|
"dev": "bun --bun tsdown --config tsdown.config.ts --watch",
|
|
101
|
-
"format": "
|
|
102
|
-
"format:fix": "
|
|
103
|
-
"lint": "
|
|
104
|
-
"lint:fix": "
|
|
101
|
+
"format": "oxfmt --check .",
|
|
102
|
+
"format:fix": "oxfmt .",
|
|
103
|
+
"lint": "oxlint .",
|
|
104
|
+
"lint:fix": "oxlint --fix .",
|
|
105
105
|
"prepublish": "cp -f ../../README.md ./README.md",
|
|
106
106
|
"publish": "bun publish || true",
|
|
107
107
|
"publish:canary": "bun publish --access public --tag canary || true",
|
|
@@ -112,14 +112,14 @@
|
|
|
112
112
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
113
113
|
},
|
|
114
114
|
"dependencies": {
|
|
115
|
-
"@intlayer/config": "9.7.
|
|
116
|
-
"@intlayer/core": "9.7.
|
|
117
|
-
"@intlayer/dictionaries-entry": "9.7.
|
|
118
|
-
"@intlayer/engine": "9.7.
|
|
119
|
-
"@intlayer/types": "9.7.
|
|
120
|
-
"@intlayer/use-intl": "9.7.
|
|
121
|
-
"next-intlayer": "9.7.
|
|
122
|
-
"react-intlayer": "9.7.
|
|
115
|
+
"@intlayer/config": "9.7.3",
|
|
116
|
+
"@intlayer/core": "9.7.3",
|
|
117
|
+
"@intlayer/dictionaries-entry": "9.7.3",
|
|
118
|
+
"@intlayer/engine": "9.7.3",
|
|
119
|
+
"@intlayer/types": "9.7.3",
|
|
120
|
+
"@intlayer/use-intl": "9.7.3",
|
|
121
|
+
"next-intlayer": "9.7.3",
|
|
122
|
+
"react-intlayer": "9.7.3"
|
|
123
123
|
},
|
|
124
124
|
"devDependencies": {
|
|
125
125
|
"@types/node": "^26",
|
|
@@ -128,8 +128,8 @@
|
|
|
128
128
|
"@utils/ts-config-types": "1.0.4",
|
|
129
129
|
"@utils/tsdown-config": "1.0.4",
|
|
130
130
|
"next-intl": "4.14.9",
|
|
131
|
-
"rimraf": "6.1.
|
|
132
|
-
"tsdown": "0.23.
|
|
131
|
+
"rimraf": "6.1.4",
|
|
132
|
+
"tsdown": "0.23.7",
|
|
133
133
|
"typescript": "7.0.2",
|
|
134
134
|
"vitest": "5.1.0"
|
|
135
135
|
},
|