next-intl 4.11.0 → 4.11.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/dist/cjs/development/{JSONCodec-XU-elSg6.cjs → JSONCodec-B-lAnRTg.cjs} +1 -1
- package/dist/cjs/development/{POCodec-cA1pxFGQ.cjs → POCodec-0XdsL-1F.cjs} +1 -1
- package/dist/cjs/development/{plugin-Har7Ebj3.cjs → plugin-0S9vVrVM.cjs} +24 -9
- package/dist/cjs/development/plugin.cjs +1 -1
- package/dist/esm/development/middleware/middleware.js +7 -14
- package/dist/esm/development/plugin/createNextIntlPlugin.js +17 -2
- package/dist/esm/development/plugin/declaration/createMessagesDeclaration.js +1 -1
- package/dist/esm/development/plugin/extractor/initExtractionCompiler.js +1 -1
- package/dist/esm/production/middleware/middleware.js +1 -1
- package/dist/esm/production/plugin/createNextIntlPlugin.js +1 -1
- package/package.json +5 -5
- package/dist/types/extractor/extractor/KeyGenerator.d.ts +0 -3
|
@@ -65,7 +65,7 @@ function createMessagesDeclaration(messagesPaths) {
|
|
|
65
65
|
|
|
66
66
|
// Note: These commands don't consult the
|
|
67
67
|
// Next.js config, so we can't detect them here.
|
|
68
|
-
// - telemetry
|
|
68
|
+
// - telemetry (however, the `detached-flush` DOES - see `createNextIntlPlugin`)
|
|
69
69
|
// - lint
|
|
70
70
|
//
|
|
71
71
|
// What remains are:
|
|
@@ -122,11 +122,11 @@ export default messages;`;
|
|
|
122
122
|
|
|
123
123
|
const formats = {
|
|
124
124
|
json: {
|
|
125
|
-
codec: () => Promise.resolve().then(function () { return require('./JSONCodec-
|
|
125
|
+
codec: () => Promise.resolve().then(function () { return require('./JSONCodec-B-lAnRTg.cjs'); }),
|
|
126
126
|
extension: '.json'
|
|
127
127
|
},
|
|
128
128
|
po: {
|
|
129
|
-
codec: () => Promise.resolve().then(function () { return require('./POCodec-
|
|
129
|
+
codec: () => Promise.resolve().then(function () { return require('./POCodec-0XdsL-1F.cjs'); }),
|
|
130
130
|
extension: '.po'
|
|
131
131
|
}
|
|
132
132
|
};
|
|
@@ -999,7 +999,7 @@ class LRUCache {
|
|
|
999
999
|
}
|
|
1000
1000
|
}
|
|
1001
1001
|
|
|
1002
|
-
const require$2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin-
|
|
1002
|
+
const require$2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin-0S9vVrVM.cjs', document.baseURI).href)));
|
|
1003
1003
|
class MessageExtractor {
|
|
1004
1004
|
compileCache = new LRUCache(750);
|
|
1005
1005
|
constructor(opts) {
|
|
@@ -1116,8 +1116,8 @@ function initExtractionCompiler(pluginConfig) {
|
|
|
1116
1116
|
// - typegen
|
|
1117
1117
|
//
|
|
1118
1118
|
// Doesn't consult Next.js config anyway:
|
|
1119
|
-
// - telemetry
|
|
1120
1119
|
// - lint
|
|
1120
|
+
// - telemetry (however, the `detached-flush` DOES - see `createNextIntlPlugin`)
|
|
1121
1121
|
//
|
|
1122
1122
|
// What remains are:
|
|
1123
1123
|
// - dev (NODE_ENV=development)
|
|
@@ -1157,7 +1157,7 @@ function initExtractionCompiler(pluginConfig) {
|
|
|
1157
1157
|
|
|
1158
1158
|
function getCurrentVersion() {
|
|
1159
1159
|
try {
|
|
1160
|
-
const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin-
|
|
1160
|
+
const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin-0S9vVrVM.cjs', document.baseURI).href)));
|
|
1161
1161
|
const pkg = require$1('next/package.json');
|
|
1162
1162
|
return pkg.version;
|
|
1163
1163
|
} catch (error) {
|
|
@@ -1184,7 +1184,7 @@ function isNextJs16OrHigher() {
|
|
|
1184
1184
|
return compareVersions(getCurrentVersion(), '16.0.0') >= 0;
|
|
1185
1185
|
}
|
|
1186
1186
|
|
|
1187
|
-
const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin-
|
|
1187
|
+
const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin-0S9vVrVM.cjs', document.baseURI).href)));
|
|
1188
1188
|
function withExtensions(localPath) {
|
|
1189
1189
|
return [`${localPath}.ts`, `${localPath}.tsx`, `${localPath}.js`, `${localPath}.jsx`];
|
|
1190
1190
|
}
|
|
@@ -1445,11 +1445,14 @@ function initPlugin(pluginConfig, nextConfig) {
|
|
|
1445
1445
|
if (nextConfig?.i18n != null) {
|
|
1446
1446
|
warn("An `i18n` property was found in your Next.js config. 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 Router, you can refer to this example: https://next-intl.dev/examples#app-router-migration\n");
|
|
1447
1447
|
}
|
|
1448
|
+
const skipWatchers = isNextTelemetryDetachedFlushProcess();
|
|
1448
1449
|
const messagesPathOrPaths = pluginConfig.experimental?.createMessagesDeclaration;
|
|
1449
|
-
if (messagesPathOrPaths) {
|
|
1450
|
+
if (messagesPathOrPaths && !skipWatchers) {
|
|
1450
1451
|
createMessagesDeclaration(typeof messagesPathOrPaths === 'string' ? [messagesPathOrPaths] : messagesPathOrPaths);
|
|
1451
1452
|
}
|
|
1452
|
-
|
|
1453
|
+
if (!skipWatchers) {
|
|
1454
|
+
initExtractionCompiler(pluginConfig);
|
|
1455
|
+
}
|
|
1453
1456
|
return getNextConfig(pluginConfig, nextConfig);
|
|
1454
1457
|
}
|
|
1455
1458
|
function createNextIntlPlugin(i18nPathOrConfig = {}) {
|
|
@@ -1461,6 +1464,18 @@ function createNextIntlPlugin(i18nPathOrConfig = {}) {
|
|
|
1461
1464
|
};
|
|
1462
1465
|
}
|
|
1463
1466
|
|
|
1467
|
+
/**
|
|
1468
|
+
* Next runs `telemetry/detached-flush.js` in a detached process to flush telemetry
|
|
1469
|
+
* (often when `next dev` exits). That loads dev `next.config` with inherited
|
|
1470
|
+
* `NODE_ENV=development`, which would otherwise start orphan plugin watchers.
|
|
1471
|
+
*/
|
|
1472
|
+
function isNextTelemetryDetachedFlushProcess() {
|
|
1473
|
+
const scriptPath = process.argv[1];
|
|
1474
|
+
if (!scriptPath) return false;
|
|
1475
|
+
const normalized = scriptPath.replace(/\\/g, '/');
|
|
1476
|
+
return normalized.includes('/telemetry/detached-flush');
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1464
1479
|
exports.createNextIntlPlugin = createNextIntlPlugin;
|
|
1465
1480
|
exports.getSortedMessages = getSortedMessages;
|
|
1466
1481
|
exports.isForbiddenObjectKey = isForbiddenObjectKey;
|
|
@@ -54,7 +54,6 @@ function createMiddleware(routing) {
|
|
|
54
54
|
}
|
|
55
55
|
function redirect(url, redirectDomain) {
|
|
56
56
|
const urlObj = new URL(url, request.url);
|
|
57
|
-
const forwardedHost = request.headers.get('x-forwarded-host');
|
|
58
57
|
urlObj.pathname = normalizeTrailingSlash(urlObj.pathname);
|
|
59
58
|
if (domainsConfig.length > 0 && !redirectDomain && domain) {
|
|
60
59
|
const bestMatchingDomain = getBestMatchingDomain(domain, locale, domainsConfig);
|
|
@@ -66,19 +65,13 @@ function createMiddleware(routing) {
|
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
urlObj.host = redirectHost;
|
|
77
|
-
}
|
|
78
|
-
if (forwardedHost) {
|
|
79
|
-
urlObj.protocol = request.headers.get('x-forwarded-proto') ?? request.nextUrl.protocol;
|
|
80
|
-
const redirectHostPort = redirectHost?.split(':')[1];
|
|
81
|
-
urlObj.port = redirectHostPort ?? request.headers.get('x-forwarded-port') ?? '';
|
|
68
|
+
if (redirectDomain) {
|
|
69
|
+
urlObj.host = redirectDomain;
|
|
70
|
+
if (request.headers.get('x-forwarded-host')) {
|
|
71
|
+
urlObj.protocol = request.headers.get('x-forwarded-proto') ?? request.nextUrl.protocol;
|
|
72
|
+
const redirectDomainPort = redirectDomain.split(':')[1];
|
|
73
|
+
urlObj.port = redirectDomainPort ?? request.headers.get('x-forwarded-port') ?? '';
|
|
74
|
+
}
|
|
82
75
|
}
|
|
83
76
|
if (request.nextUrl.basePath) {
|
|
84
77
|
urlObj.pathname = applyBasePath(urlObj.pathname, request.nextUrl.basePath);
|
|
@@ -7,11 +7,14 @@ function initPlugin(pluginConfig, nextConfig) {
|
|
|
7
7
|
if (nextConfig?.i18n != null) {
|
|
8
8
|
warn("An `i18n` property was found in your Next.js config. 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 Router, you can refer to this example: https://next-intl.dev/examples#app-router-migration\n");
|
|
9
9
|
}
|
|
10
|
+
const skipWatchers = isNextTelemetryDetachedFlushProcess();
|
|
10
11
|
const messagesPathOrPaths = pluginConfig.experimental?.createMessagesDeclaration;
|
|
11
|
-
if (messagesPathOrPaths) {
|
|
12
|
+
if (messagesPathOrPaths && !skipWatchers) {
|
|
12
13
|
createMessagesDeclaration(typeof messagesPathOrPaths === 'string' ? [messagesPathOrPaths] : messagesPathOrPaths);
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
if (!skipWatchers) {
|
|
16
|
+
initExtractionCompiler(pluginConfig);
|
|
17
|
+
}
|
|
15
18
|
return getNextConfig(pluginConfig, nextConfig);
|
|
16
19
|
}
|
|
17
20
|
function createNextIntlPlugin(i18nPathOrConfig = {}) {
|
|
@@ -23,4 +26,16 @@ function createNextIntlPlugin(i18nPathOrConfig = {}) {
|
|
|
23
26
|
};
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Next runs `telemetry/detached-flush.js` in a detached process to flush telemetry
|
|
31
|
+
* (often when `next dev` exits). That loads dev `next.config` with inherited
|
|
32
|
+
* `NODE_ENV=development`, which would otherwise start orphan plugin watchers.
|
|
33
|
+
*/
|
|
34
|
+
function isNextTelemetryDetachedFlushProcess() {
|
|
35
|
+
const scriptPath = process.argv[1];
|
|
36
|
+
if (!scriptPath) return false;
|
|
37
|
+
const normalized = scriptPath.replace(/\\/g, '/');
|
|
38
|
+
return normalized.includes('/telemetry/detached-flush');
|
|
39
|
+
}
|
|
40
|
+
|
|
26
41
|
export { createNextIntlPlugin as default };
|
|
@@ -12,7 +12,7 @@ function createMessagesDeclaration(messagesPaths) {
|
|
|
12
12
|
|
|
13
13
|
// Note: These commands don't consult the
|
|
14
14
|
// Next.js config, so we can't detect them here.
|
|
15
|
-
// - telemetry
|
|
15
|
+
// - telemetry (however, the `detached-flush` DOES - see `createNextIntlPlugin`)
|
|
16
16
|
// - lint
|
|
17
17
|
//
|
|
18
18
|
// What remains are:
|
|
@@ -17,8 +17,8 @@ function initExtractionCompiler(pluginConfig) {
|
|
|
17
17
|
// - typegen
|
|
18
18
|
//
|
|
19
19
|
// Doesn't consult Next.js config anyway:
|
|
20
|
-
// - telemetry
|
|
21
20
|
// - lint
|
|
21
|
+
// - telemetry (however, the `detached-flush` DOES - see `createNextIntlPlugin`)
|
|
22
22
|
//
|
|
23
23
|
// What remains are:
|
|
24
24
|
// - dev (NODE_ENV=development)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as e}from"next/server";import{receiveRoutingConfig as t}from"../routing/config.js";import{HEADER_LOCALE_NAME as r}from"../shared/constants.js";import{matchesPathname as a,normalizeTrailingSlash as o,getLocalePrefix as n,getLocalizedTemplate as l}from"../shared/utils.js";import s from"./getAlternateLinksHeaderValue.js";import i from"./resolveLocale.js";import c from"./syncCookie.js";import{sanitizePathname as d,isLocaleSupportedOnDomain as f,getNormalizedPathname as m,getPathnameMatch as h,getInternalTemplate as x,formatTemplatePathname as p,formatPathname as u,getBestMatchingDomain as U,applyBasePath as P,getLocaleAsPrefix as g}from"./utils.js";function v(v){const L=t(v);return function(t){let v;try{v=decodeURI(t.nextUrl.pathname)}catch{return e.next()}const j=d(v),{domain:w,locale:k}=i(L,t.headers,t.cookies,j),b=w?w.defaultLocale===k:k===L.defaultLocale,q=L.domains?.filter((e=>f(k,e)))||[],R=null!=L.domains&&!w;function y(a){const n=new URL(a,t.url);t.nextUrl.basePath&&(n.pathname=P(n.pathname,t.nextUrl.basePath));const l=new Headers(t.headers);l.set(r,k);return o(t.nextUrl.pathname)!==o(n.pathname)?e.rewrite(n,{request:{headers:l}}):e.next({request:{headers:l}})}function H(r,a){const n=new URL(r,t.url)
|
|
1
|
+
import{NextResponse as e}from"next/server";import{receiveRoutingConfig as t}from"../routing/config.js";import{HEADER_LOCALE_NAME as r}from"../shared/constants.js";import{matchesPathname as a,normalizeTrailingSlash as o,getLocalePrefix as n,getLocalizedTemplate as l}from"../shared/utils.js";import s from"./getAlternateLinksHeaderValue.js";import i from"./resolveLocale.js";import c from"./syncCookie.js";import{sanitizePathname as d,isLocaleSupportedOnDomain as f,getNormalizedPathname as m,getPathnameMatch as h,getInternalTemplate as x,formatTemplatePathname as p,formatPathname as u,getBestMatchingDomain as U,applyBasePath as P,getLocaleAsPrefix as g}from"./utils.js";function v(v){const L=t(v);return function(t){let v;try{v=decodeURI(t.nextUrl.pathname)}catch{return e.next()}const j=d(v),{domain:w,locale:k}=i(L,t.headers,t.cookies,j),b=w?w.defaultLocale===k:k===L.defaultLocale,q=L.domains?.filter((e=>f(k,e)))||[],R=null!=L.domains&&!w;function y(a){const n=new URL(a,t.url);t.nextUrl.basePath&&(n.pathname=P(n.pathname,t.nextUrl.basePath));const l=new Headers(t.headers);l.set(r,k);return o(t.nextUrl.pathname)!==o(n.pathname)?e.rewrite(n,{request:{headers:l}}):e.next({request:{headers:l}})}function H(r,a){const n=new URL(r,t.url);if(n.pathname=o(n.pathname),q.length>0&&!a&&w){const e=U(w,k,q);if(e){a=e.domain;const t=e.localePrefix||L.localePrefix.mode;e.defaultLocale===k&&"as-needed"===t&&(n.pathname=m(n.pathname,L.locales,L.localePrefix))}}if(a&&(n.host=a,t.headers.get("x-forwarded-host"))){n.protocol=t.headers.get("x-forwarded-proto")??t.nextUrl.protocol;const e=a.split(":")[1];n.port=e??t.headers.get("x-forwarded-port")??""}return t.nextUrl.basePath&&(n.pathname=P(n.pathname,t.nextUrl.basePath)),V=!0,e.redirect(n.toString())}const z=m(j,L.locales,L.localePrefix),A=h(j,L.locales,L.localePrefix,w),C=null!=A,I=w?.localePrefix||L.localePrefix.mode,N="never"===I||b&&"as-needed"===I;let S,T,V,B=z;const D=L.pathnames;if(D){let e;if([e,T]=x(D,z,k),T){const r=D[T],o=l(r,k,T);if(a(o,z))B=p(z,o,T);else{let a;a=e?l(r,e,T):T;const s=N?void 0:n(k,L.localePrefix),i=p(z,a,o);S=H(u(i,s,t.nextUrl.search))}}}if(!S)if("/"!==B||C){const e=u(B,g(k),t.nextUrl.search);if(C){const r=u(z,A.prefix,t.nextUrl.search);if("never"===I)S=H(u(z,void 0,t.nextUrl.search));else if(A.exact)if(b&&N)S=H(u(z,void 0,t.nextUrl.search));else if(L.domains){const t=U(w,A.locale,q);S=w?.domain===t?.domain||R?y(e):H(r,t?.domain)}else S=y(e);else S=H(r)}else S=N?y(e):H(u(z,n(k,L.localePrefix),t.nextUrl.search))}else S=N?y(u(B,g(k),t.nextUrl.search)):H(u(z,n(k,L.localePrefix),t.nextUrl.search));return c(t,S,k,L,w),!V&&"never"!==I&&L.alternateLinks&&L.locales.length>1&&S.headers.set("Link",s({routing:L,internalTemplateName:T,localizedPathnames:null!=T&&D?D[T]:void 0,request:t,resolvedLocale:k})),S}}export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./extractor/initExtractionCompiler.js";import t from"./getNextConfig.js";import{warn as r}from"./utils.js";import o from"./declaration/createMessagesDeclaration.js";function n(n
|
|
1
|
+
import e from"./extractor/initExtractionCompiler.js";import t from"./getNextConfig.js";import{warn as r}from"./utils.js";import o from"./declaration/createMessagesDeclaration.js";function n(n,i){null!=i?.i18n&&r("An `i18n` property was found in your Next.js config. 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 Router, you can refer to this example: https://next-intl.dev/examples#app-router-migration\n");const s=function(){const e=process.argv[1];if(!e)return!1;return e.replace(/\\/g,"/").includes("/telemetry/detached-flush")}(),a=n.experimental?.createMessagesDeclaration;return a&&!s&&o("string"==typeof a?[a]:a),s||e(n),t(n,i)}function i(e={}){const t="string"==typeof e?{requestConfig:e}:e;return function(e){return n(t,e)}}export{i as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -127,11 +127,11 @@
|
|
|
127
127
|
"@formatjs/intl-localematcher": "^0.8.1",
|
|
128
128
|
"@parcel/watcher": "^2.4.1",
|
|
129
129
|
"@swc/core": "^1.15.2",
|
|
130
|
-
"icu-minify": "^4.11.
|
|
130
|
+
"icu-minify": "^4.11.2",
|
|
131
131
|
"negotiator": "^1.0.0",
|
|
132
|
-
"next-intl-swc-plugin-extractor": "^4.11.
|
|
132
|
+
"next-intl-swc-plugin-extractor": "^4.11.2",
|
|
133
133
|
"po-parser": "^2.1.1",
|
|
134
|
-
"use-intl": "^4.11.
|
|
134
|
+
"use-intl": "^4.11.2"
|
|
135
135
|
},
|
|
136
136
|
"peerDependencies": {
|
|
137
137
|
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
@@ -142,5 +142,5 @@
|
|
|
142
142
|
"optional": true
|
|
143
143
|
}
|
|
144
144
|
},
|
|
145
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "940dfbfbad98ceef00bb9c47822c533f384c0e02"
|
|
146
146
|
}
|