next-intl 3.9.0 → 3.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -9
- package/dist/development/index.react-server.js +2 -2
- package/dist/development/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/development/navigation/react-client/useBaseRouter.js +6 -2
- package/dist/development/navigation/shared/syncLocaleCookie.js +2 -1
- package/dist/development/navigation/shared/utils.js +4 -0
- package/dist/development/plugin.js +4 -2
- package/dist/development/react-server/{NextIntlClientProvider.js → NextIntlClientProviderServer.js} +4 -4
- package/dist/development/shared/utils.js +2 -2
- package/dist/esm/index.react-server.js +1 -1
- package/dist/esm/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-client/useBaseRouter.js +1 -1
- package/dist/esm/navigation/shared/syncLocaleCookie.js +1 -1
- package/dist/esm/navigation/shared/utils.js +1 -1
- package/dist/esm/plugin.js +1 -1
- package/dist/production/index.react-server.js +1 -1
- package/dist/production/navigation/react-client/useBaseRouter.js +1 -1
- package/dist/production/navigation/shared/syncLocaleCookie.js +1 -1
- package/dist/production/navigation/shared/utils.js +1 -1
- package/dist/production/plugin.js +1 -1
- package/dist/types/src/navigation/shared/utils.d.ts +1 -0
- package/dist/types/src/react-server/{NextIntlClientProvider.d.ts → NextIntlClientProviderServer.d.ts} +1 -1
- package/dist/types/src/react-server/index.d.ts +1 -1
- package/dist/types/src/shared/utils.d.ts +2 -2
- package/package.json +5 -5
- package/plugin.d.ts +4 -2
- /package/dist/esm/react-server/{NextIntlClientProvider.js → NextIntlClientProviderServer.js} +0 -0
- /package/dist/production/react-server/{NextIntlClientProvider.js → NextIntlClientProviderServer.js} +0 -0
- /package/dist/types/test/react-server/{NextIntlClientProvider.test.d.ts → NextIntlClientProviderServer.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
<br>
|
|
3
|
+
<a href="https://next-intl-docs.vercel.app/">
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="media/logo-dark-mode.svg">
|
|
6
|
+
<source media="(prefers-color-scheme: light)" srcset="media/logo.svg">
|
|
7
|
+
<img alt="next-intl" src="media/logo.svg" width="600">
|
|
8
|
+
</picture>
|
|
9
|
+
</a>
|
|
10
|
+
<br>
|
|
11
|
+
<br>
|
|
10
12
|
</h1>
|
|
11
13
|
|
|
12
14
|
> Internationalization (i18n) for Next.js that gets out of your way.
|
|
@@ -19,7 +21,7 @@
|
|
|
19
21
|
|
|
20
22
|
## Features
|
|
21
23
|
|
|
22
|
-
Internationalization is an essential part of the user experience. next-intl gives you everything you need to get language subtleties right and has always got your back whenever you need to fine-tune a translation.
|
|
24
|
+
Internationalization is an essential part of the user experience. `next-intl` gives you everything you need to get language subtleties right and has always got your back whenever you need to fine-tune a translation.
|
|
23
25
|
|
|
24
26
|
- 🌟 **ICU message syntax**: Localize your messages with interpolation, cardinal & ordinal plurals, enum-based label selection and rich text.
|
|
25
27
|
- 📅 **Dates, times & numbers**: Apply appropriate formatting without worrying about server/client differences like time zones.
|
|
@@ -8,7 +8,7 @@ var useFormatter = require('./react-server/useFormatter.js');
|
|
|
8
8
|
var useNow = require('./react-server/useNow.js');
|
|
9
9
|
var useTimeZone = require('./react-server/useTimeZone.js');
|
|
10
10
|
var useMessages = require('./react-server/useMessages.js');
|
|
11
|
-
var
|
|
11
|
+
var NextIntlClientProviderServer = require('./react-server/NextIntlClientProviderServer.js');
|
|
12
12
|
var core = require('use-intl/core');
|
|
13
13
|
|
|
14
14
|
|
|
@@ -19,7 +19,7 @@ exports.useFormatter = useFormatter.default;
|
|
|
19
19
|
exports.useNow = useNow.default;
|
|
20
20
|
exports.useTimeZone = useTimeZone.default;
|
|
21
21
|
exports.useMessages = useMessages.default;
|
|
22
|
-
exports.NextIntlClientProvider =
|
|
22
|
+
exports.NextIntlClientProvider = NextIntlClientProviderServer.default;
|
|
23
23
|
Object.keys(core).forEach(function (k) {
|
|
24
24
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
25
25
|
enumerable: true,
|
|
@@ -21,7 +21,7 @@ function createLocalizedPathnamesNavigation(opts) {
|
|
|
21
21
|
const locale = useLocale.default();
|
|
22
22
|
const isValid = opts.locales.includes(locale);
|
|
23
23
|
if (!isValid) {
|
|
24
|
-
throw new Error("Unknown locale encountered: \"".concat(locale, "\". Make sure to validate the locale in `
|
|
24
|
+
throw new Error("Unknown locale encountered: \"".concat(locale, "\". Make sure to validate the locale in `i18n.ts`.") );
|
|
25
25
|
}
|
|
26
26
|
return locale;
|
|
27
27
|
}
|
|
@@ -5,8 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var navigation = require('next/navigation');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var useLocale = require('../../react-client/useLocale.js');
|
|
8
|
-
var utils = require('../../shared/utils.js');
|
|
8
|
+
var utils$1 = require('../../shared/utils.js');
|
|
9
9
|
var syncLocaleCookie = require('../shared/syncLocaleCookie.js');
|
|
10
|
+
var utils = require('../shared/utils.js');
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Returns a wrapped instance of `useRouter` from `next/navigation` that
|
|
@@ -33,7 +34,10 @@ function useBaseRouter() {
|
|
|
33
34
|
const pathname = navigation.usePathname();
|
|
34
35
|
return React.useMemo(() => {
|
|
35
36
|
function localize(href, nextLocale) {
|
|
36
|
-
|
|
37
|
+
let curPathname = window.location.pathname;
|
|
38
|
+
const basePath = utils.getBasePath(pathname);
|
|
39
|
+
if (basePath) curPathname = curPathname.replace(basePath, '');
|
|
40
|
+
return utils$1.localizeHref(href, nextLocale || locale, locale, curPathname);
|
|
37
41
|
}
|
|
38
42
|
function createHandler(fn) {
|
|
39
43
|
return function handler(href, options) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var constants = require('../../shared/constants.js');
|
|
6
|
+
var utils = require('./utils.js');
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* We have to keep the cookie value in sync as Next.js might
|
|
@@ -17,7 +18,7 @@ function syncLocaleCookie(pathname, locale, nextLocale) {
|
|
|
17
18
|
!pathname) {
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
|
-
const basePath =
|
|
21
|
+
const basePath = utils.getBasePath(pathname);
|
|
21
22
|
const hasBasePath = basePath !== '';
|
|
22
23
|
const path = hasBasePath ? basePath : '/';
|
|
23
24
|
|
|
@@ -101,8 +101,12 @@ function getRoute(_ref3) {
|
|
|
101
101
|
}
|
|
102
102
|
return template;
|
|
103
103
|
}
|
|
104
|
+
function getBasePath(pathname) {
|
|
105
|
+
return window.location.pathname.replace(pathname, '');
|
|
106
|
+
}
|
|
104
107
|
|
|
105
108
|
exports.compileLocalizedPathname = compileLocalizedPathname;
|
|
109
|
+
exports.getBasePath = getBasePath;
|
|
106
110
|
exports.getRoute = getRoute;
|
|
107
111
|
exports.normalizeNameOrNameWithParams = normalizeNameOrNameWithParams;
|
|
108
112
|
exports.serializeSearchParams = serializeSearchParams;
|
|
@@ -77,6 +77,8 @@ function initPlugin(i18nPath, nextConfig) {
|
|
|
77
77
|
}
|
|
78
78
|
return Object.assign({}, nextConfig, nextIntlConfig);
|
|
79
79
|
}
|
|
80
|
-
module.exports = function
|
|
81
|
-
return
|
|
80
|
+
module.exports = function createNextIntlPlugin(i18nPath) {
|
|
81
|
+
return function withNextIntl(nextConfig) {
|
|
82
|
+
return initPlugin(i18nPath, nextConfig);
|
|
83
|
+
};
|
|
82
84
|
};
|
package/dist/development/react-server/{NextIntlClientProvider.js → NextIntlClientProviderServer.js}
RENAMED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var NextIntlClientProvider
|
|
7
|
+
var NextIntlClientProvider = require('../shared/NextIntlClientProvider.js');
|
|
8
8
|
var getLocale = require('../server/react-server/getLocale.js');
|
|
9
9
|
var getNow = require('../server/react-server/getNow.js');
|
|
10
10
|
var getTimeZone = require('../server/react-server/getTimeZone.js');
|
|
@@ -13,14 +13,14 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
13
13
|
|
|
14
14
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
15
15
|
|
|
16
|
-
async function
|
|
16
|
+
async function NextIntlClientProviderServer(_ref) {
|
|
17
17
|
let {
|
|
18
18
|
locale,
|
|
19
19
|
now,
|
|
20
20
|
timeZone,
|
|
21
21
|
...rest
|
|
22
22
|
} = _ref;
|
|
23
|
-
return /*#__PURE__*/React__default.default.createElement(NextIntlClientProvider
|
|
23
|
+
return /*#__PURE__*/React__default.default.createElement(NextIntlClientProvider.default
|
|
24
24
|
// We need to be careful about potentially reading from headers here.
|
|
25
25
|
// See https://github.com/amannn/next-intl/issues/631
|
|
26
26
|
, _rollupPluginBabelHelpers.extends({
|
|
@@ -30,4 +30,4 @@ async function NextIntlClientProvider(_ref) {
|
|
|
30
30
|
}, rest));
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
exports.default =
|
|
33
|
+
exports.default = NextIntlClientProviderServer;
|
|
@@ -16,12 +16,12 @@ function isLocalHref(href) {
|
|
|
16
16
|
}
|
|
17
17
|
function localizeHref(href, locale) {
|
|
18
18
|
let curLocale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : locale;
|
|
19
|
-
let
|
|
19
|
+
let curPathname = arguments.length > 3 ? arguments[3] : undefined;
|
|
20
20
|
if (!isLocalHref(href) || isRelativeHref(href)) {
|
|
21
21
|
return href;
|
|
22
22
|
}
|
|
23
23
|
const isSwitchingLocale = locale !== curLocale;
|
|
24
|
-
const isPathnamePrefixed = locale == null || hasPathnamePrefixed(locale,
|
|
24
|
+
const isPathnamePrefixed = locale == null || hasPathnamePrefixed(locale, curPathname);
|
|
25
25
|
const shouldPrefix = isSwitchingLocale || isPathnamePrefixed;
|
|
26
26
|
if (shouldPrefix && locale != null) {
|
|
27
27
|
return prefixHref(href, locale);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as useLocale}from"./react-server/useLocale.js";export{default as useTranslations}from"./react-server/useTranslations.js";export{default as useFormatter}from"./react-server/useFormatter.js";export{default as useNow}from"./react-server/useNow.js";export{default as useTimeZone}from"./react-server/useTimeZone.js";export{default as useMessages}from"./react-server/useMessages.js";export{default as NextIntlClientProvider}from"./react-server/
|
|
1
|
+
export{default as useLocale}from"./react-server/useLocale.js";export{default as useTranslations}from"./react-server/useTranslations.js";export{default as useFormatter}from"./react-server/useFormatter.js";export{default as useNow}from"./react-server/useNow.js";export{default as useTimeZone}from"./react-server/useTimeZone.js";export{default as useMessages}from"./react-server/useMessages.js";export{default as NextIntlClientProvider}from"./react-server/NextIntlClientProviderServer.js";export*from"use-intl/core";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import n from"../../react-client/useLocale.js";import{getRoute as a,compileLocalizedPathname as o,normalizeNameOrNameWithParams as l}from"../shared/utils.js";import c from"./ClientLink.js";import
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import n from"../../react-client/useLocale.js";import{getRoute as a,compileLocalizedPathname as o,normalizeNameOrNameWithParams as l}from"../shared/utils.js";import c from"./ClientLink.js";import i from"./clientPermanentRedirect.js";import s from"./clientRedirect.js";import u from"./useBasePathname.js";import f from"./useBaseRouter.js";function m(m){function h(){const e=n();if(!m.locales.includes(e))throw new Error('Unknown locale encountered: "'.concat(e,'". Make sure to validate the locale in `i18n.ts`.'));return e}function p(t,n){let{href:a,locale:l,...i}=t;const s=h(),u=l||s;return r.createElement(c,e({ref:n,href:o({locale:u,pathname:a,params:"object"==typeof a?a.params:void 0,pathnames:m.pathnames}),locale:l,localePrefix:m.localePrefix},i))}const d=t(p);function v(e){let{href:r,locale:t}=e;return o({...l(r),locale:t,pathnames:m.pathnames})}return d.displayName="Link",{Link:d,redirect:function(e){const r=v({href:e,locale:h()});for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return s({...m,pathname:r},...n)},permanentRedirect:function(e){const r=v({href:e,locale:h()});for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return i({...m,pathname:r},...n)},usePathname:function(){const e=u(),r=h();return e?a({pathname:e,locale:r,pathnames:m.pathnames}):e},useRouter:function(){const e=f(),r=h();return{...e,push(t){for(var n,a=arguments.length,o=new Array(a>1?a-1:0),l=1;l<a;l++)o[l-1]=arguments[l];const c=v({href:t,locale:(null===(n=o[0])||void 0===n?void 0:n.locale)||r});return e.push(c,...o)},replace(t){for(var n,a=arguments.length,o=new Array(a>1?a-1:0),l=1;l<a;l++)o[l-1]=arguments[l];const c=v({href:t,locale:(null===(n=o[0])||void 0===n?void 0:n.locale)||r});return e.replace(c,...o)},prefetch(t){for(var n,a=arguments.length,o=new Array(a>1?a-1:0),l=1;l<a;l++)o[l-1]=arguments[l];const c=v({href:t,locale:(null===(n=o[0])||void 0===n?void 0:n.locale)||r});return e.prefetch(c,...o)}}},getPathname:v}}export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRouter as t,usePathname as e}from"next/navigation";import{useMemo as r}from"react";import o from"../../react-client/useLocale.js";import{localizeHref as n}from"../../shared/utils.js";import c from"../shared/syncLocaleCookie.js";function a(){const a=t(),i=o(),
|
|
1
|
+
import{useRouter as t,usePathname as e}from"next/navigation";import{useMemo as r}from"react";import o from"../../react-client/useLocale.js";import{localizeHref as n}from"../../shared/utils.js";import c from"../shared/syncLocaleCookie.js";import{getBasePath as s}from"../shared/utils.js";function a(){const a=t(),i=o(),p=e();return r((()=>{function t(t,e){let r=window.location.pathname;const o=s(p);return o&&(r=r.replace(o,"")),n(t,e||i,i,r)}function e(e){return function(r,o){const{locale:n,...s}=o||{};c(p,i,n);const a=[t(r,n)];return Object.keys(s).length>0&&a.push(s),e(...a)}}return{...a,push:e(a.push),replace:e(a.replace),prefetch:e(a.prefetch)}}),[i,p,a])}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{COOKIE_LOCALE_NAME as t,COOKIE_MAX_AGE as
|
|
1
|
+
import{COOKIE_LOCALE_NAME as t,COOKIE_MAX_AGE as o,COOKIE_SAME_SITE as c}from"../../shared/constants.js";import{getBasePath as a}from"./utils.js";function n(n,e,s){if(!(s!==e&&null!=s)||!n)return;const r=a(n),i=""!==r?r:"/";document.cookie="".concat(t,"=").concat(s,"; path=").concat(i,"; max-age=").concat(o,"; sameSite=").concat(c)}export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{unlocalizePathname as t,matchesPathname as n}from"../../shared/utils.js";function
|
|
1
|
+
import{unlocalizePathname as t,matchesPathname as n}from"../../shared/utils.js";function e(t){return"string"==typeof t?{pathname:t}:t}function r(t){function n(t){return String(t)}const e=new URLSearchParams;for(const[r,a]of Object.entries(t))Array.isArray(a)?a.forEach((t=>{e.append(r,n(t))})):e.set(r,n(a));return"?"+e.toString()}function a(t){let{pathname:n,locale:e,params:a,pathnames:o,query:i}=t;function c(t){let n=o[t];return n||(n=t),n}function s(t){const n="string"==typeof t?t:t[e];let o=n;if(a&&Object.entries(a).forEach((t=>{let[n,e]=t;o=Array.isArray(e)?o.replace(new RegExp("(\\[)?\\[...".concat(n,"\\](\\])?"),"g"),e.map((t=>String(t))).join("/")):o.replace("[".concat(n,"]"),String(e))})),o.includes("["))throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(n,"\nParams: ").concat(JSON.stringify(a)));return i&&(o+=r(i)),o}if("string"==typeof n){return s(c(n))}{const{pathname:t,...e}=n;return{...e,pathname:s(c(t))}}}function o(e){var r;let{locale:a,pathname:o,pathnames:i}=e;const c=t(o,a);let s=null===(r=Object.entries(i).find((t=>{let[,e]=t;const r="string"!=typeof e?e[a]:e;return n(r,c)})))||void 0===r?void 0:r[0];return s||(s=o),s}function i(t){return window.location.pathname.replace(t,"")}export{a as compileLocalizedPathname,i as getBasePath,o as getRoute,e as normalizeNameOrNameWithParams,r as serializeSearchParams};
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from"fs";import e from"path";function t(t,o){function r(t){return n.existsSync(function(n){const t=[];return o&&t.push(o),t.push(n),e.resolve(...t)}(t))}if(t){if(!r(t))throw new Error("Could not find i18n config at ".concat(t,", please provide a valid path."));return t}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(r(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return o
|
|
1
|
+
import n from"fs";import e from"path";function t(t,o){function r(t){return n.existsSync(function(n){const t=[];return o&&t.push(o),t.push(n),e.resolve(...t)}(t))}if(t){if(!r(t))throw new Error("Could not find i18n config at ".concat(t,", please provide a valid path."));return t}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(r(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return function(o){return function(n,o){let r;if(null!=(null==o?void 0:o.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://github.com/amannn/next-intl/tree/main/examples/example-app-router-migration\n"),null!=process.env.TURBOPACK){var i,s;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");r={experimental:{...null==o?void 0:o.experimental,turbo:{...null==o||null===(i=o.experimental)||void 0===i?void 0:i.turbo,resolveAlias:{...null==o||null===(s=o.experimental)||void 0===s||null===(s=s.turbo)||void 0===s?void 0:s.resolveAlias,"next-intl/config":t(n)}}}}}else r={webpack(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];let[l,u]=i;return l.resolve.alias["next-intl/config"]=e.resolve(l.context,t(n,l.context)),"function"==typeof(null==o?void 0:o.webpack)?o.webpack(l,u):l}};return Object.assign({},o,r)}(n,o)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./react-server/useLocale.js"),r=require("./react-server/useTranslations.js"),t=require("./react-server/useFormatter.js"),s=require("./react-server/useNow.js"),u=require("./react-server/useTimeZone.js"),o=require("./react-server/useMessages.js"),a=require("./react-server/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./react-server/useLocale.js"),r=require("./react-server/useTranslations.js"),t=require("./react-server/useFormatter.js"),s=require("./react-server/useNow.js"),u=require("./react-server/useTimeZone.js"),o=require("./react-server/useMessages.js"),a=require("./react-server/NextIntlClientProviderServer.js"),i=require("use-intl/core");exports.useLocale=e.default,exports.useTranslations=r.default,exports.useFormatter=t.default,exports.useNow=s.default,exports.useTimeZone=u.default,exports.useMessages=o.default,exports.NextIntlClientProvider=a.default,Object.keys(i).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return i[e]}})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("react"),t=require("../../react-client/useLocale.js"),u=require("../../shared/utils.js"),n=require("../shared/syncLocaleCookie.js");exports.default=function(){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("react"),t=require("../../react-client/useLocale.js"),u=require("../../shared/utils.js"),n=require("../shared/syncLocaleCookie.js"),s=require("../shared/utils.js");exports.default=function(){const a=e.useRouter(),c=t.default(),o=e.usePathname();return r.useMemo((()=>{function e(e,r){let t=window.location.pathname;const n=s.getBasePath(o);return n&&(t=t.replace(n,"")),u.localizeHref(e,r||c,c,t)}function r(r){return function(t,u){const{locale:s,...a}=u||{};n.default(o,c,s);const i=[e(t,s)];return Object.keys(a).length>0&&i.push(a),r(...i)}}return{...a,push:r(a.push),replace:r(a.replace),prefetch:r(a.prefetch)}}),[c,o,a])};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/constants.js");exports.default=function(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/constants.js"),t=require("./utils.js");exports.default=function(c,a,o){if(!(o!==a&&null!=o)||!c)return;const n=t.getBasePath(c),s=""!==n?n:"/";document.cookie="".concat(e.COOKIE_LOCALE_NAME,"=").concat(o,"; path=").concat(s,"; max-age=").concat(e.COOKIE_MAX_AGE,"; sameSite=").concat(e.COOKIE_SAME_SITE)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/utils.js");function t(e){function t(e){return String(e)}const r=new URLSearchParams;for(const[n,a]of Object.entries(e))Array.isArray(a)?a.forEach((e=>{r.append(n,t(e))})):r.set(n,t(a));return"?"+r.toString()}exports.compileLocalizedPathname=function(e){let{pathname:r,locale:n,params:a,pathnames:o,query:i}=e;function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/utils.js");function t(e){function t(e){return String(e)}const r=new URLSearchParams;for(const[n,a]of Object.entries(e))Array.isArray(a)?a.forEach((e=>{r.append(n,t(e))})):r.set(n,t(a));return"?"+r.toString()}exports.compileLocalizedPathname=function(e){let{pathname:r,locale:n,params:a,pathnames:o,query:i}=e;function c(e){let t=o[e];return t||(t=e),t}function s(e){let r="string"==typeof e?e:e[n];return a&&Object.entries(a).forEach((e=>{let[t,n]=e;r=Array.isArray(n)?r.replace(new RegExp("(\\[)?\\[...".concat(t,"\\](\\])?"),"g"),n.map((e=>String(e))).join("/")):r.replace("[".concat(t,"]"),String(n))})),i&&(r+=t(i)),r}if("string"==typeof r){return s(c(r))}{const{pathname:e,...t}=r;return{...t,pathname:s(c(e))}}},exports.getBasePath=function(e){return window.location.pathname.replace(e,"")},exports.getRoute=function(t){var r;let{locale:n,pathname:a,pathnames:o}=t;const i=e.unlocalizePathname(a,n);let c=null===(r=Object.entries(o).find((t=>{let[,r]=t;const a="string"!=typeof r?r[n]:r;return e.matchesPathname(a,i)})))||void 0===r?void 0:r[0];return c||(c=a),c},exports.normalizeNameOrNameWithParams=function(e){return"string"==typeof e?{pathname:e}:e},exports.serializeSearchParams=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var
|
|
1
|
+
"use strict";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var r=t(n),o=t(e);function i(n,e){function t(n){return r.default.existsSync(function(n){const t=[];return e&&t.push(e),t.push(n),o.default.resolve(...t)}(n))}if(n){if(!t(n))throw new Error("Could not find i18n config at ".concat(n,", please provide a valid path."));return n}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(t(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return function(e){return function(n,e){let t;if(null!=(null==e?void 0:e.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://github.com/amannn/next-intl/tree/main/examples/example-app-router-migration\n"),null!=process.env.TURBOPACK){var r,s;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");t={experimental:{...null==e?void 0:e.experimental,turbo:{...null==e||null===(r=e.experimental)||void 0===r?void 0:r.turbo,resolveAlias:{...null==e||null===(s=e.experimental)||void 0===s||null===(s=s.turbo)||void 0===s?void 0:s.resolveAlias,"next-intl/config":i(n)}}}}}else t={webpack(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];let[l,u]=r;return l.resolve.alias["next-intl/config"]=o.default.resolve(l.context,i(n,l.context)),"function"==typeof(null==e?void 0:e.webpack)?e.webpack(l,u):l}};return Object.assign({},e,t)}(n,e)}};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ComponentProps } from 'react';
|
|
2
2
|
import BaseNextIntlClientProvider from '../shared/NextIntlClientProvider';
|
|
3
3
|
type Props = ComponentProps<typeof BaseNextIntlClientProvider>;
|
|
4
|
-
export default function
|
|
4
|
+
export default function NextIntlClientProviderServer({ locale, now, timeZone, ...rest }: Props): Promise<React.JSX.Element>;
|
|
5
5
|
export {};
|
|
@@ -11,5 +11,5 @@ export { default as useFormatter } from './useFormatter';
|
|
|
11
11
|
export { default as useNow } from './useNow';
|
|
12
12
|
export { default as useTimeZone } from './useTimeZone';
|
|
13
13
|
export { default as useMessages } from './useMessages';
|
|
14
|
-
export { default as NextIntlClientProvider } from './
|
|
14
|
+
export { default as NextIntlClientProvider } from './NextIntlClientProviderServer';
|
|
15
15
|
export * from 'use-intl/core';
|
|
@@ -5,8 +5,8 @@ import { ComponentProps } from 'react';
|
|
|
5
5
|
type Href = ComponentProps<typeof NextLink>['href'];
|
|
6
6
|
export declare function isRelativeHref(href: Href): boolean;
|
|
7
7
|
export declare function isLocalHref(href: Href): boolean;
|
|
8
|
-
export declare function localizeHref(href: string, locale: string, curLocale: string,
|
|
9
|
-
export declare function localizeHref(href: UrlObject | string, locale: string, curLocale: string,
|
|
8
|
+
export declare function localizeHref(href: string, locale: string, curLocale: string, curPathname: string): string;
|
|
9
|
+
export declare function localizeHref(href: UrlObject | string, locale: string, curLocale: string, curPathname: string): UrlObject | string;
|
|
10
10
|
export declare function prefixHref(href: string, locale: string): string;
|
|
11
11
|
export declare function prefixHref(href: UrlObject | string, locale: string): UrlObject | string;
|
|
12
12
|
export declare function unlocalizePathname(pathname: string, locale: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
84
84
|
"negotiator": "^0.6.3",
|
|
85
|
-
"use-intl": "^3.9.
|
|
85
|
+
"use-intl": "^3.9.2"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -122,11 +122,11 @@
|
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
124
|
"path": "dist/production/navigation.react-client.js",
|
|
125
|
-
"limit": "2.
|
|
125
|
+
"limit": "2.94 KB"
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
"path": "dist/production/navigation.react-server.js",
|
|
129
|
-
"limit": "3.
|
|
129
|
+
"limit": "3.03 KB"
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
"path": "dist/production/server.react-client.js",
|
|
@@ -141,5 +141,5 @@
|
|
|
141
141
|
"limit": "5.855 KB"
|
|
142
142
|
}
|
|
143
143
|
],
|
|
144
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "2a6199609c0a77f897d994c8d52796f5615bcfff"
|
|
145
145
|
}
|
package/plugin.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {NextConfig} from 'next';
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
function createNextIntlPlugin(
|
|
4
|
+
i18nPath?: string
|
|
5
|
+
): (config?: NextConfig) => NextConfig;
|
|
4
6
|
|
|
5
7
|
// Currently only available via CJS
|
|
6
|
-
export =
|
|
8
|
+
export = createNextIntlPlugin;
|
/package/dist/esm/react-server/{NextIntlClientProvider.js → NextIntlClientProviderServer.js}
RENAMED
|
File without changes
|
/package/dist/production/react-server/{NextIntlClientProvider.js → NextIntlClientProviderServer.js}
RENAMED
|
File without changes
|
|
File without changes
|