@intlayer/next-intl 9.0.0-canary.4 → 9.0.0-canary.6

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.
@@ -19,7 +19,8 @@ let react_jsx_runtime = require("react/jsx-runtime");
19
19
  const NextIntlClientProvider = ({ locale, children, messages: _messages, timeZone: _timeZone, now: _now, ...rest }) => {
20
20
  if (process.env.NODE_ENV === "development" && typeof _messages !== "undefined") (0, _intlayer_config_logger.getAppLogger)({ log: _intlayer_config_built.log })(`${(0, _intlayer_config_logger.colorize)("NextIntlClientProvider", _intlayer_config_colors.CYAN)} do not pass the messages prop with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`);
21
21
  const pathname = (0, next_navigation.usePathname)();
22
- const resolvedLocale = locale ?? (0, _intlayer_core_localization.getLocaleFromPath)(pathname);
22
+ const mode = _intlayer_config_built.routing?.mode ?? "prefix-no-default";
23
+ const resolvedLocale = locale ?? (mode === "prefix-all" || mode === "prefix-no-default" ? (0, _intlayer_core_localization.getLocaleFromPath)(pathname) : void 0);
23
24
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(next_intlayer.IntlayerClientProvider, {
24
25
  locale: resolvedLocale,
25
26
  ...rest,
@@ -1 +1 @@
1
- {"version":3,"file":"NextIntlClientProvider.cjs","names":["CYAN","IntlayerClientProvider"],"sources":["../../../src/client/NextIntlClientProvider.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 { getLocaleFromPath } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { usePathname } from 'next/navigation';\nimport type { NextIntlClientProvider as _NextIntlClientProvider } from 'next-intl';\nimport { IntlayerClientProvider } from 'next-intlayer';\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 const pathname = usePathname();\n const resolvedLocale = locale ?? getLocaleFromPath(pathname);\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 <IntlayerClientProvider\n key={String(resolvedLocale)}\n locale={resolvedLocale}\n {...rest}\n >\n {children}\n </IntlayerClientProvider>\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;AACJ,KACE,QAAQ,IAAI,aAAa,iBACzB,OAAO,cAAc,YAGrB,2CAD+B,EAAE,iCAAK,CAC7B,CACP,yCAAY,0BAA0BA,6BAAK,CAAC,+HAC7C;CAUH,MAAM,6CAAwB;CAC9B,MAAM,iBAAiB,6DAA4B,SAAS;AAM5D,QACE,2CAACC,sCAAD;EAEE,QAAQ;EACR,GAAI;EAEH;EACsB,EALlB,OAAO,eAAe,CAKJ"}
1
+ {"version":3,"file":"NextIntlClientProvider.cjs","names":["CYAN","routing","IntlayerClientProvider"],"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 { usePathname } from 'next/navigation';\nimport type { NextIntlClientProvider as _NextIntlClientProvider } from 'next-intl';\nimport { IntlayerClientProvider } from 'next-intlayer';\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 <IntlayerClientProvider\n key={String(resolvedLocale)}\n locale={resolvedLocale}\n {...rest}\n >\n {children}\n </IntlayerClientProvider>\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;AACJ,KACE,QAAQ,IAAI,aAAa,iBACzB,OAAO,cAAc,YAGrB,2CAD+B,EAAE,iCAAK,CAC7B,CACP,yCAAY,0BAA0BA,6BAAK,CAAC,+HAC7C;CAeH,MAAM,6CAAwB;CAC9B,MAAM,OAAOC,gCAAS,QAAQ;CAE9B,MAAM,iBACJ,WAFmB,SAAS,gBAAgB,SAAS,yEAET,SAAS,GAAG;AAM1D,QACE,2CAACC,sCAAD;EAEE,QAAQ;EACR,GAAI;EAEH;EACsB,EALlB,OAAO,eAAe,CAKJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/next-intl",
3
- "version": "9.0.0-canary.4",
3
+ "version": "9.0.0-canary.6",
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,31 +36,37 @@
36
36
  "exports": {
37
37
  ".": {
38
38
  "types": "./dist/types/index.d.ts",
39
+ "require": "./dist/cjs/index.cjs",
39
40
  "import": "./dist/esm/index.mjs"
40
41
  },
41
42
  "./server": {
42
43
  "types": "./dist/types/server/index.d.ts",
44
+ "require": "./dist/cjs/server/index.cjs",
43
45
  "import": "./dist/esm/server/index.mjs"
44
46
  },
45
47
  "./routing": {
46
48
  "types": "./dist/types/routing.d.ts",
49
+ "require": "./dist/cjs/routing.cjs",
47
50
  "import": "./dist/esm/routing.mjs"
48
51
  },
49
52
  "./navigation": {
50
53
  "types": "./dist/types/navigation/index.d.ts",
54
+ "require": "./dist/cjs/navigation/index.cjs",
51
55
  "import": "./dist/esm/navigation/index.mjs"
52
56
  },
53
57
  "./middleware": {
54
58
  "types": "./dist/types/middleware.d.ts",
59
+ "require": "./dist/cjs/middleware.cjs",
55
60
  "import": "./dist/esm/middleware.mjs"
56
61
  },
57
62
  "./plugin": {
58
63
  "types": "./dist/types/plugin/index.d.ts",
64
+ "require": "./dist/cjs/plugin/index.cjs",
59
65
  "import": "./dist/esm/plugin/index.mjs"
60
66
  },
61
67
  "./package.json": "./package.json"
62
68
  },
63
- "main": "dist/esm/index.mjs",
69
+ "main": "dist/cjs/index.cjs",
64
70
  "module": "dist/esm/index.mjs",
65
71
  "types": "dist/types/index.d.ts",
66
72
  "typesVersions": {
@@ -104,14 +110,14 @@
104
110
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
105
111
  },
106
112
  "dependencies": {
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"
113
+ "@intlayer/chokidar": "9.0.0-canary.6",
114
+ "@intlayer/config": "9.0.0-canary.6",
115
+ "@intlayer/core": "9.0.0-canary.6",
116
+ "@intlayer/dictionaries-entry": "9.0.0-canary.6",
117
+ "@intlayer/types": "9.0.0-canary.6",
118
+ "@intlayer/use-intl": "9.0.0-canary.6",
119
+ "next-intlayer": "9.0.0-canary.6",
120
+ "react-intlayer": "9.0.0-canary.6"
115
121
  },
116
122
  "devDependencies": {
117
123
  "@types/node": "25.9.4",