next-intl 3.26.2 → 3.26.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/development/navigation/shared/createSharedNavigationFns.js +1 -1
- package/dist/development/react-client/useLocale.js +5 -0
- package/dist/development/server/react-server/RequestLocale.js +2 -1
- package/dist/development/server/react-server/getConfig.js +20 -5
- package/dist/development/shared/utils.js +5 -0
- package/dist/esm/navigation/shared/createSharedNavigationFns.js +1 -1
- package/dist/esm/react-client/useLocale.js +1 -1
- package/dist/esm/server/react-server/RequestLocale.js +1 -1
- package/dist/esm/server/react-server/getConfig.js +1 -1
- package/dist/esm/shared/utils.js +1 -1
- package/dist/production/navigation/shared/createSharedNavigationFns.js +1 -1
- package/dist/production/server/react-server/RequestLocale.js +1 -1
- package/dist/production/server/react-server/getConfig.js +1 -1
- package/dist/production/shared/utils.js +1 -1
- package/dist/types/src/navigation/react-client/createLocalizedPathnamesNavigation.d.ts +1 -1
- package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +1 -1
- package/dist/types/src/server/react-server/getRequestConfig.d.ts +1 -8
- package/dist/types/src/shared/utils.d.ts +1 -0
- package/package.json +3 -3
|
@@ -49,7 +49,7 @@ function createSharedNavigationFns(getLocale, routing) {
|
|
|
49
49
|
// @ts-expect-error -- This is ok
|
|
50
50
|
const isLocalizable = utils$1.isLocalizableHref(href);
|
|
51
51
|
const localePromiseOrValue = getLocale();
|
|
52
|
-
const curLocale = localePromiseOrValue
|
|
52
|
+
const curLocale = utils$1.isPromise(localePromiseOrValue) ? React.use(localePromiseOrValue) : localePromiseOrValue;
|
|
53
53
|
const finalPathname = isLocalizable ? getPathname(
|
|
54
54
|
// @ts-expect-error -- This is ok
|
|
55
55
|
{
|
|
@@ -6,6 +6,7 @@ var navigation = require('next/navigation');
|
|
|
6
6
|
var _useLocale = require('use-intl/_useLocale');
|
|
7
7
|
var constants = require('../shared/constants.js');
|
|
8
8
|
|
|
9
|
+
let hasWarnedForParams = false;
|
|
9
10
|
function useLocale() {
|
|
10
11
|
// The types aren't entirely correct here. Outside of Next.js
|
|
11
12
|
// `useParams` can be called, but the return type is `null`.
|
|
@@ -17,6 +18,10 @@ function useLocale() {
|
|
|
17
18
|
locale = _useLocale.useLocale();
|
|
18
19
|
} catch (error) {
|
|
19
20
|
if (typeof (params === null || params === void 0 ? void 0 : params[constants.LOCALE_SEGMENT_NAME]) === 'string') {
|
|
21
|
+
if (!hasWarnedForParams) {
|
|
22
|
+
console.warn('Deprecation warning: `useLocale` has returned a default from `useParams().locale` since no `NextIntlClientProvider` ancestor was found for the calling component. This behavior will be removed in the next major version. Please ensure all Client Components that use `next-intl` are wrapped in a `NextIntlClientProvider`.');
|
|
23
|
+
hasWarnedForParams = true;
|
|
24
|
+
}
|
|
20
25
|
locale = params[constants.LOCALE_SEGMENT_NAME];
|
|
21
26
|
} else {
|
|
22
27
|
throw error;
|
|
@@ -5,13 +5,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var headers = require('next/headers');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var constants = require('../../shared/constants.js');
|
|
8
|
+
var utils = require('../../shared/utils.js');
|
|
8
9
|
var RequestLocaleCache = require('./RequestLocaleCache.js');
|
|
9
10
|
|
|
10
11
|
async function getHeadersImpl() {
|
|
11
12
|
const promiseOrValue = headers.headers();
|
|
12
13
|
|
|
13
14
|
// Compatibility with Next.js <15
|
|
14
|
-
return promiseOrValue
|
|
15
|
+
return utils.isPromise(promiseOrValue) ? await promiseOrValue : promiseOrValue;
|
|
15
16
|
}
|
|
16
17
|
const getHeaders = React.cache(getHeadersImpl);
|
|
17
18
|
async function getLocaleFromHeaderImpl() {
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var navigation = require('next/navigation');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var core = require('use-intl/core');
|
|
8
|
+
var utils = require('../../shared/utils.js');
|
|
8
9
|
var RequestLocale = require('./RequestLocale.js');
|
|
9
10
|
var RequestLocaleLegacy = require('./RequestLocaleLegacy.js');
|
|
10
11
|
var getRuntimeConfig = require('next-intl/config');
|
|
@@ -13,6 +14,9 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
13
14
|
|
|
14
15
|
var getRuntimeConfig__default = /*#__PURE__*/_interopDefault(getRuntimeConfig);
|
|
15
16
|
|
|
17
|
+
let hasWarnedForMissingReturnedLocale = false;
|
|
18
|
+
let hasWarnedForAccessedLocaleParam = false;
|
|
19
|
+
|
|
16
20
|
// Make sure `now` is consistent across the request in case none was configured
|
|
17
21
|
function getDefaultNowImpl() {
|
|
18
22
|
return new Date();
|
|
@@ -34,6 +38,10 @@ async function receiveRuntimeConfigImpl(getConfig, localeOverride) {
|
|
|
34
38
|
// `locale` (either in a single-language workflow or because the locale is
|
|
35
39
|
// read from the user settings), don't attempt to read the request locale.
|
|
36
40
|
get locale() {
|
|
41
|
+
if (!hasWarnedForAccessedLocaleParam) {
|
|
42
|
+
console.warn("\nThe `locale` parameter in `getRequestConfig` is deprecated, please switch to `await requestLocale`. See https://next-intl.dev/blog/next-intl-3-22#await-request-locale\n");
|
|
43
|
+
hasWarnedForAccessedLocaleParam = true;
|
|
44
|
+
}
|
|
37
45
|
return localeOverride || RequestLocaleLegacy.getRequestLocale();
|
|
38
46
|
},
|
|
39
47
|
get requestLocale() {
|
|
@@ -41,15 +49,22 @@ async function receiveRuntimeConfigImpl(getConfig, localeOverride) {
|
|
|
41
49
|
}
|
|
42
50
|
};
|
|
43
51
|
let result = getConfig(params);
|
|
44
|
-
if (result
|
|
52
|
+
if (utils.isPromise(result)) {
|
|
45
53
|
result = await result;
|
|
46
54
|
}
|
|
47
|
-
|
|
55
|
+
let locale = result.locale;
|
|
48
56
|
if (!locale) {
|
|
49
|
-
{
|
|
50
|
-
console.error("\
|
|
57
|
+
if (!hasWarnedForMissingReturnedLocale) {
|
|
58
|
+
console.error("\nA `locale` is expected to be returned from `getRequestConfig`, but none was returned. This will be an error in the next major version of next-intl.\n\nSee: https://next-intl.dev/blog/next-intl-3-22#await-request-locale\n");
|
|
59
|
+
hasWarnedForMissingReturnedLocale = true;
|
|
60
|
+
}
|
|
61
|
+
locale = await params.requestLocale;
|
|
62
|
+
if (!locale) {
|
|
63
|
+
{
|
|
64
|
+
console.error("\nUnable to find `next-intl` locale because the middleware didn't run on this request and no `locale` was returned in `getRequestConfig`. See https://next-intl.dev/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.\n");
|
|
65
|
+
}
|
|
66
|
+
navigation.notFound();
|
|
51
67
|
}
|
|
52
|
-
navigation.notFound();
|
|
53
68
|
}
|
|
54
69
|
return {
|
|
55
70
|
...result,
|
|
@@ -156,12 +156,17 @@ function comparePathnamePairs(a, b) {
|
|
|
156
156
|
function getSortedPathnames(pathnames) {
|
|
157
157
|
return pathnames.sort(comparePathnamePairs);
|
|
158
158
|
}
|
|
159
|
+
function isPromise(value) {
|
|
160
|
+
// https://github.com/amannn/next-intl/issues/1711
|
|
161
|
+
return typeof value.then === 'function';
|
|
162
|
+
}
|
|
159
163
|
|
|
160
164
|
exports.getLocaleAsPrefix = getLocaleAsPrefix;
|
|
161
165
|
exports.getLocalePrefix = getLocalePrefix;
|
|
162
166
|
exports.getSortedPathnames = getSortedPathnames;
|
|
163
167
|
exports.hasPathnamePrefixed = hasPathnamePrefixed;
|
|
164
168
|
exports.isLocalizableHref = isLocalizableHref;
|
|
169
|
+
exports.isPromise = isPromise;
|
|
165
170
|
exports.localizeHref = localizeHref;
|
|
166
171
|
exports.matchesPathname = matchesPathname;
|
|
167
172
|
exports.normalizeTrailingSlash = normalizeTrailingSlash;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import{redirect as o,permanentRedirect as a}from"next/navigation";import t,{forwardRef as n,use as r}from"react";import{receiveRoutingConfig as l}from"../../routing/config.js";import{isLocalizableHref as i}from"../../shared/utils.js";import
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import{redirect as o,permanentRedirect as a}from"next/navigation";import t,{forwardRef as n,use as r}from"react";import{receiveRoutingConfig as l}from"../../routing/config.js";import{isLocalizableHref as i,isPromise as m}from"../../shared/utils.js";import c from"./BaseLink.js";import{validateReceivedConfig as f,serializeSearchParams as s,compileLocalizedPathname as u,applyPathnamePrefix as p,normalizeNameOrNameWithParams as d}from"./utils.js";function h(h,j){const g=l(j||{});f(g);const v=g.pathnames,y="as-needed"===g.localePrefix.mode&&g.domains||void 0;function x(o,a){let n,l,{href:f,locale:s,...u}=o;"object"==typeof f?(n=f.pathname,l=f.params):n=f;const p=i(f),d=h(),j=m(d)?r(d):d,x=p?b({locale:s||j,href:null==v?n:{pathname:n,params:l}},null!=s||y||void 0):n;return t.createElement(c,e({ref:a,defaultLocale:g.defaultLocale,href:"object"==typeof f?{...f,pathname:x}:x,locale:s,localeCookie:g.localeCookie,unprefixed:y&&p?{domains:g.domains.reduce(((e,o)=>(e[o.domain]=o.defaultLocale,e)),{}),pathname:b({locale:j,href:null==v?n:{pathname:n,params:l}},!1)}:void 0},u))}const L=n(x);function b(e,o){const{href:a,locale:t}=e;let n;return null==v?"object"==typeof a?(n=a.pathname,a.query&&(n+=s(a.query))):n=a:n=u({locale:t,...d(a),pathnames:g.pathnames}),p(n,t,g,e.domain,o)}function k(e){return function(o){for(var a=arguments.length,t=new Array(a>1?a-1:0),n=1;n<a;n++)t[n-1]=arguments[n];return e(b(o,o.domain?void 0:y),...t)}}const P=k(o),q=k(a);return{config:g,Link:L,redirect:P,permanentRedirect:q,getPathname:b}}export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useParams as
|
|
1
|
+
import{useParams as e}from"next/navigation";import{useLocale as t}from"use-intl/_useLocale";import{LOCALE_SEGMENT_NAME as n}from"../shared/constants.js";let o=!1;function r(){const r=e();let a;try{a=t()}catch(e){if("string"!=typeof(null==r?void 0:r[n]))throw e;o||(console.warn("Deprecation warning: `useLocale` has returned a default from `useParams().locale` since no `NextIntlClientProvider` ancestor was found for the calling component. This behavior will be removed in the next major version. Please ensure all Client Components that use `next-intl` are wrapped in a `NextIntlClientProvider`."),o=!0),a=r[n]}return a}export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{headers as t}from"next/headers";import{cache as e}from"react";import{HEADER_LOCALE_NAME as n}from"../../shared/constants.js";import{
|
|
1
|
+
import{headers as t}from"next/headers";import{cache as e}from"react";import{HEADER_LOCALE_NAME as n}from"../../shared/constants.js";import{isPromise as r}from"../../shared/utils.js";import{getCachedRequestLocale as o}from"./RequestLocaleCache.js";const i=e((async function(){const e=t();return r(e)?await e:e}));const s=e((async function(){let t;try{t=(await i()).get(n)||void 0}catch(t){if(t instanceof Error&&"DYNAMIC_SERVER_USAGE"===t.digest){const e=new Error("Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `setRequestLocale` API to enable static rendering, see https://next-intl.dev/docs/getting-started/app-router/with-i18n-routing#static-rendering",{cause:t});throw e.digest=t.digest,e}throw t}return t}));async function a(){return o()||await s()}export{a as getRequestLocale};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{notFound as e}from"next/navigation";import{cache as t}from"react";import{_createIntlFormatters as n,_createCache as o,initializeConfig as r}from"use-intl/core";import{
|
|
1
|
+
import{notFound as e}from"next/navigation";import{cache as t}from"react";import{_createIntlFormatters as n,_createCache as o,initializeConfig as r}from"use-intl/core";import{isPromise as i}from"../../shared/utils.js";import{getRequestLocale as a}from"./RequestLocale.js";import{getRequestLocale as l}from"./RequestLocaleLegacy.js";import s from"next-intl/config";let c=!1,u=!1;const f=t((function(){return new Date}));const d=t((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const m=t((async function(t,n){if("function"!=typeof t)throw new Error("Invalid i18n request configuration detected.\n\nPlease verify that:\n1. In case you've specified a custom location in your Next.js config, make sure that the path is correct.\n2. You have a default export in your i18n request configuration file.\n\nSee also: https://next-intl.dev/docs/usage/configuration#i18n-request\n");const o={get locale(){return u||(console.warn("\nThe `locale` parameter in `getRequestConfig` is deprecated, please switch to `await requestLocale`. See https://next-intl.dev/blog/next-intl-3-22#await-request-locale\n"),u=!0),n||l()},get requestLocale(){return n?Promise.resolve(n):a()}};let r=t(o);i(r)&&(r=await r);let s=r.locale;return s||(c||(console.error("\nA `locale` is expected to be returned from `getRequestConfig`, but none was returned. This will be an error in the next major version of next-intl.\n\nSee: https://next-intl.dev/blog/next-intl-3-22#await-request-locale\n"),c=!0),s=await o.requestLocale,s||(console.error("\nUnable to find `next-intl` locale because the middleware didn't run on this request and no `locale` was returned in `getRequestConfig`. See https://next-intl.dev/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.\n"),e())),{...r,locale:s,now:r.now||f(),timeZone:r.timeZone||d()}})),p=t(n),g=t(o);const w=t((async function(e){const t=await m(s,e);return{...r(t),_formatters:p(g())}}));export{w as default};
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function n(n){return function(n){return"object"==typeof n?null==n.host&&null==n.hostname:!/^[a-z]+:/i.test(n)}(n)&&!function(n){const t="object"==typeof n?n.pathname:n;return null!=t&&!t.startsWith("/")}(n)}function t(t,r){let u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r,
|
|
1
|
+
function n(n){return function(n){return"object"==typeof n?null==n.host&&null==n.hostname:!/^[a-z]+:/i.test(n)}(n)&&!function(n){const t="object"==typeof n?n.pathname:n;return null!=t&&!t.startsWith("/")}(n)}function t(t,r){let u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r,o=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0;if(!n(t))return t;const f=r!==u,l=i(c,o);return(f||l)&&null!=c?e(t,c):t}function e(n,t){let e;return"string"==typeof n?e=u(t,n):(e={...n},n.pathname&&(e.pathname=u(t,n.pathname))),e}function r(n,t){return n.replace(new RegExp("^".concat(t)),"")||"/"}function u(n,t){let e=n;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),e+=t,e}function i(n,t){return t===n||t.startsWith("".concat(n,"/"))}function o(n){const t=function(){try{return"true"===process.env._next_intl_trailing_slash}catch(n){return!1}}();if("/"!==n){const e=n.endsWith("/");t&&!e?n+="/":!t&&e&&(n=n.slice(0,-1))}return n}function c(n,t){const e=o(n),r=o(t);return s(e).test(r)}function f(n,t){var e;return"never"!==t.mode&&(null===(e=t.prefixes)||void 0===e?void 0:e[n])||l(n)}function l(n){return"/"+n}function s(n){const t=n.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}function a(n){return n.includes("[[...")}function p(n){return n.includes("[...")}function h(n){return n.includes("[")}function g(n,t){const e=n.split("/"),r=t.split("/"),u=Math.max(e.length,r.length);for(let n=0;n<u;n++){const t=e[n],u=r[n];if(!t&&u)return-1;if(t&&!u)return 1;if(t||u){if(!h(t)&&h(u))return-1;if(h(t)&&!h(u))return 1;if(!p(t)&&p(u))return-1;if(p(t)&&!p(u))return 1;if(!a(t)&&a(u))return-1;if(a(t)&&!a(u))return 1}}return 0}function d(n){return n.sort(g)}function v(n){return"function"==typeof n.then}export{l as getLocaleAsPrefix,f as getLocalePrefix,d as getSortedPathnames,i as hasPathnamePrefixed,n as isLocalizableHref,v as isPromise,t as localizeHref,c as matchesPathname,o as normalizeTrailingSlash,e as prefixHref,u as prefixPathname,s as templateToRegex,r as unprefixPathname};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),a=require("next/navigation"),r=require("react"),t=require("../../routing/config.js"),n=require("../../shared/utils.js"),o=require("./BaseLink.js"),i=require("./utils.js");function l(e){return e&&e.__esModule?e:{default:e}}var u=l(r);exports.default=function(l,c){const s=t.receiveRoutingConfig(c||{}),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),a=require("next/navigation"),r=require("react"),t=require("../../routing/config.js"),n=require("../../shared/utils.js"),o=require("./BaseLink.js"),i=require("./utils.js");function l(e){return e&&e.__esModule?e:{default:e}}var u=l(r);exports.default=function(l,c){const s=t.receiveRoutingConfig(c||{}),d=s.pathnames,f="as-needed"===s.localePrefix.mode&&s.domains||void 0;function m(a,t){let i,c,{href:m,locale:p,...v}=a;"object"==typeof m?(i=m.pathname,c=m.params):i=m;const P=n.isLocalizableHref(m),g=l(),j=n.isPromise(g)?r.use(g):g,q=P?h({locale:p||j,href:null==d?i:{pathname:i,params:c}},null!=p||f||void 0):i;return u.default.createElement(o.default,e.extends({ref:t,defaultLocale:s.defaultLocale,href:"object"==typeof m?{...m,pathname:q}:q,locale:p,localeCookie:s.localeCookie,unprefixed:f&&P?{domains:s.domains.reduce(((e,a)=>(e[a.domain]=a.defaultLocale,e)),{}),pathname:h({locale:j,href:null==d?i:{pathname:i,params:c}},!1)}:void 0},v))}const p=r.forwardRef(m);function h(e,a){const{href:r,locale:t}=e;let n;return null==d?"object"==typeof r?(n=r.pathname,r.query&&(n+=i.serializeSearchParams(r.query))):n=r:n=i.compileLocalizedPathname({locale:t,...i.normalizeNameOrNameWithParams(r),pathnames:s.pathnames}),i.applyPathnamePrefix(n,t,s,e.domain,a)}function v(e){return function(a){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return e(h(a,a.domain?void 0:f),...t)}}const P=v(a.redirect),g=v(a.permanentRedirect);return{config:s,Link:p,redirect:P,permanentRedirect:g,getPathname:h}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/headers"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/headers"),t=require("react"),r=require("../../shared/constants.js"),s=require("../../shared/utils.js"),n=require("./RequestLocaleCache.js");const i=t.cache((async function(){const t=e.headers();return s.isPromise(t)?await t:t}));const a=t.cache((async function(){let e;try{e=(await i()).get(r.HEADER_LOCALE_NAME)||void 0}catch(e){if(e instanceof Error&&"DYNAMIC_SERVER_USAGE"===e.digest){const t=new Error("Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `setRequestLocale` API to enable static rendering, see https://next-intl.dev/docs/getting-started/app-router/with-i18n-routing#static-rendering",{cause:e});throw t.digest=e.digest,t}throw e}return e}));exports.getRequestLocale=async function(){return n.getCachedRequestLocale()||await a()};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),t=require("react"),r=require("use-intl/core"),n=require("../../shared/utils.js"),o=require("./RequestLocale.js"),a=require("./RequestLocaleLegacy.js");function c(e){return e&&e.__esModule?e:{default:e}}var i=c(require("next-intl/config"));const u=t.cache((function(){return new Date}));const s=t.cache((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const l=t.cache((async function(t,r){const c={get locale(){return r||a.getRequestLocale()},get requestLocale(){return r?Promise.resolve(r):o.getRequestLocale()}};let i=t(c);n.isPromise(i)&&(i=await i);let l=i.locale;return l||(l=await c.requestLocale,l||e.notFound()),{...i,locale:l,now:i.now||u(),timeZone:i.timeZone||s()}})),q=t.cache(r._createIntlFormatters),f=t.cache(r._createCache);const d=t.cache((async function(e){const t=await l(i.default,e);return{...r.initializeConfig(t),_formatters:q(f())}}));exports.default=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function t(t){return function(t){return"object"==typeof t?null==t.host&&null==t.hostname:!/^[a-z]+:/i.test(t)}(t)&&!function(t){const e="object"==typeof t?t.pathname:t;return null!=e&&!e.startsWith("/")}(t)}function e(t,e){let r;return"string"==typeof t?r=n(e,t):(r={...t},t.pathname&&(r.pathname=n(e,t.pathname))),r}function n(t,e){let n=t;return/^\/(\?.*)?$/.test(e)&&(e=e.slice(1)),n+=e,n}function r(t,e){return e===t||e.startsWith("".concat(t,"/"))}function o(t){const e=function(){try{return"true"===process.env._next_intl_trailing_slash}catch(t){return!1}}();if("/"!==t){const n=t.endsWith("/");e&&!n?t+="/":!e&&n&&(t=t.slice(0,-1))}return t}function i(t){return"/"+t}function u(t){const e=t.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(e,"$"))}function
|
|
1
|
+
"use strict";function t(t){return function(t){return"object"==typeof t?null==t.host&&null==t.hostname:!/^[a-z]+:/i.test(t)}(t)&&!function(t){const e="object"==typeof t?t.pathname:t;return null!=e&&!e.startsWith("/")}(t)}function e(t,e){let r;return"string"==typeof t?r=n(e,t):(r={...t},t.pathname&&(r.pathname=n(e,t.pathname))),r}function n(t,e){let n=t;return/^\/(\?.*)?$/.test(e)&&(e=e.slice(1)),n+=e,n}function r(t,e){return e===t||e.startsWith("".concat(t,"/"))}function o(t){const e=function(){try{return"true"===process.env._next_intl_trailing_slash}catch(t){return!1}}();if("/"!==t){const n=t.endsWith("/");e&&!n?t+="/":!e&&n&&(t=t.slice(0,-1))}return t}function i(t){return"/"+t}function u(t){const e=t.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(e,"$"))}function s(t){return t.includes("[[...")}function c(t){return t.includes("[...")}function f(t){return t.includes("[")}function a(t,e){const n=t.split("/"),r=e.split("/"),o=Math.max(n.length,r.length);for(let t=0;t<o;t++){const e=n[t],o=r[t];if(!e&&o)return-1;if(e&&!o)return 1;if(e||o){if(!f(e)&&f(o))return-1;if(f(e)&&!f(o))return 1;if(!c(e)&&c(o))return-1;if(c(e)&&!c(o))return 1;if(!s(e)&&s(o))return-1;if(s(e)&&!s(o))return 1}}return 0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getLocaleAsPrefix=i,exports.getLocalePrefix=function(t,e){var n;return"never"!==e.mode&&(null===(n=e.prefixes)||void 0===n?void 0:n[t])||i(t)},exports.getSortedPathnames=function(t){return t.sort(a)},exports.hasPathnamePrefixed=r,exports.isLocalizableHref=t,exports.isPromise=function(t){return"function"==typeof t.then},exports.localizeHref=function(n,o){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,u=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;if(!t(n))return n;const c=o!==i,f=r(s,u);return(c||f)&&null!=s?e(n,s):n},exports.matchesPathname=function(t,e){const n=o(t),r=o(e);return u(n).test(r)},exports.normalizeTrailingSlash=o,exports.prefixHref=e,exports.prefixPathname=n,exports.templateToRegex=u,exports.unprefixPathname=function(t,e){return t.replace(new RegExp("^".concat(e)),"")||"/"};
|
|
@@ -53,7 +53,7 @@ export default function createLocalizedPathnamesNavigation<AppLocales extends Lo
|
|
|
53
53
|
};
|
|
54
54
|
} & {
|
|
55
55
|
ref?: React.LegacyRef<HTMLAnchorElement> | undefined;
|
|
56
|
-
}, "
|
|
56
|
+
}, "href" | "name" | "localePrefix" | "localeCookie"> & {
|
|
57
57
|
href: Pathname extends `${string}[[...${string}` ? Pathname | ({
|
|
58
58
|
pathname: Pathname;
|
|
59
59
|
params?: import("../shared/StrictParams").default<Pathname> | undefined;
|
|
@@ -47,7 +47,7 @@ export default function createLocalizedPathnamesNavigation<AppLocales extends Lo
|
|
|
47
47
|
mode: "as-needed";
|
|
48
48
|
prefixes?: Partial<Record<string, string>> | undefined;
|
|
49
49
|
};
|
|
50
|
-
}, "
|
|
50
|
+
}, "href" | "name" | "localePrefix" | "localeCookie"> & {
|
|
51
51
|
href: Pathname extends `${string}[[...${string}` ? Pathname | ({
|
|
52
52
|
pathname: Pathname;
|
|
53
53
|
params?: import("../shared/StrictParams").default<Pathname> | undefined;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import type { IntlConfig } from 'use-intl/core';
|
|
2
2
|
export type RequestConfig = Omit<IntlConfig, 'locale'> & {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* function within `getRequestConfig`, you can include a locale as part of the
|
|
6
|
-
* returned request configuration.
|
|
7
|
-
*
|
|
8
|
-
* This can be helpful for the following use cases:
|
|
9
|
-
* - Apps that only support a single language
|
|
10
|
-
* - Apps where the locale should be read from user settings instead of the pathname
|
|
11
|
-
* - Providing a fallback locale in case the locale was not matched by the middleware
|
|
4
|
+
* @see https://next-intl.dev/docs/usage/configuration#i18n-request
|
|
12
5
|
**/
|
|
13
6
|
locale?: IntlConfig['locale'];
|
|
14
7
|
};
|
|
@@ -21,4 +21,5 @@ export declare function getLocalePrefix<AppLocales extends Locales, AppLocalePre
|
|
|
21
21
|
export declare function getLocaleAsPrefix(locale: string): string;
|
|
22
22
|
export declare function templateToRegex(template: string): RegExp;
|
|
23
23
|
export declare function getSortedPathnames(pathnames: Array<string>): string[];
|
|
24
|
+
export declare function isPromise<Value>(value: Value | Promise<Value>): value is Promise<Value>;
|
|
24
25
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.26.
|
|
3
|
+
"version": "3.26.4",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -88,11 +88,11 @@
|
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
90
90
|
"negotiator": "^1.0.0",
|
|
91
|
-
"use-intl": "^3.26.
|
|
91
|
+
"use-intl": "^3.26.4"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
95
95
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "a881e6286bfb9dfb3f4b1ac152ea3fad1e5c5043"
|
|
98
98
|
}
|