next-intl 4.3.5 → 4.3.7
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/plugin.cjs +15 -4
- package/dist/esm/development/navigation/react-client/useBasePathname.js +1 -1
- package/dist/esm/development/plugin/createMessagesDeclaration.js +15 -4
- package/dist/esm/development/routing/defineRouting.js +1 -1
- package/dist/esm/development/server/react-server/RequestLocale.js +1 -1
- package/dist/esm/production/navigation/react-client/useBasePathname.js +1 -1
- package/dist/esm/production/plugin/createMessagesDeclaration.js +1 -1
- package/dist/esm/production/server/react-server/RequestLocale.js +1 -1
- package/dist/types/routing/config.d.ts +3 -3
- package/package.json +3 -3
|
@@ -40,11 +40,22 @@ function runOnce(fn) {
|
|
|
40
40
|
fn();
|
|
41
41
|
}
|
|
42
42
|
function createMessagesDeclaration(messagesPaths) {
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
//
|
|
43
|
+
// Instead of running _only_ in certain cases, it's
|
|
44
|
+
// safer to _avoid_ running for certain known cases.
|
|
45
|
+
// https://github.com/amannn/next-intl/issues/2006
|
|
46
|
+
const shouldBailOut = ['info', 'start'
|
|
47
|
+
|
|
48
|
+
// Note: These commands don't consult the
|
|
49
|
+
// Next.js config, so we can't detect them here.
|
|
50
|
+
// - telemetry
|
|
51
|
+
// - lint
|
|
52
|
+
//
|
|
53
|
+
// What remains are:
|
|
54
|
+
// - dev
|
|
55
|
+
// - build
|
|
56
|
+
// - typegen
|
|
46
57
|
].some(arg => process.argv.includes(arg));
|
|
47
|
-
if (
|
|
58
|
+
if (shouldBailOut) {
|
|
48
59
|
return;
|
|
49
60
|
}
|
|
50
61
|
|
|
@@ -22,7 +22,7 @@ function useBasePathname(config) {
|
|
|
22
22
|
const isPathnamePrefixed = hasPathnamePrefixed(prefix, pathname);
|
|
23
23
|
if (isPathnamePrefixed) {
|
|
24
24
|
unlocalizedPathname = unprefixPathname(pathname, prefix);
|
|
25
|
-
} else if (config.localePrefix.mode
|
|
25
|
+
} else if (config.localePrefix.mode !== 'never' && config.localePrefix.prefixes) {
|
|
26
26
|
// Workaround for https://github.com/vercel/next.js/issues/73085
|
|
27
27
|
const localeAsPrefix = getLocaleAsPrefix(locale);
|
|
28
28
|
if (hasPathnamePrefixed(localeAsPrefix, pathname)) {
|
|
@@ -11,11 +11,22 @@ function runOnce(fn) {
|
|
|
11
11
|
fn();
|
|
12
12
|
}
|
|
13
13
|
function createMessagesDeclaration(messagesPaths) {
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
//
|
|
14
|
+
// Instead of running _only_ in certain cases, it's
|
|
15
|
+
// safer to _avoid_ running for certain known cases.
|
|
16
|
+
// https://github.com/amannn/next-intl/issues/2006
|
|
17
|
+
const shouldBailOut = ['info', 'start'
|
|
18
|
+
|
|
19
|
+
// Note: These commands don't consult the
|
|
20
|
+
// Next.js config, so we can't detect them here.
|
|
21
|
+
// - telemetry
|
|
22
|
+
// - lint
|
|
23
|
+
//
|
|
24
|
+
// What remains are:
|
|
25
|
+
// - dev
|
|
26
|
+
// - build
|
|
27
|
+
// - typegen
|
|
17
28
|
].some(arg => process.argv.includes(arg));
|
|
18
|
-
if (
|
|
29
|
+
if (shouldBailOut) {
|
|
19
30
|
return;
|
|
20
31
|
}
|
|
21
32
|
|
|
@@ -18,7 +18,7 @@ function validateUniqueLocalesPerDomain(domains) {
|
|
|
18
18
|
}
|
|
19
19
|
const duplicateLocaleMessages = Array.from(domainsByLocale.entries()).filter(([, localeDomains]) => localeDomains.size > 1).map(([locale, localeDomains]) => `- "${locale}" is used by: ${Array.from(localeDomains).join(', ')}`);
|
|
20
20
|
if (duplicateLocaleMessages.length > 0) {
|
|
21
|
-
console.warn('Locales are expected to be unique per domain, but found overlap:\n' + duplicateLocaleMessages.join('\n') + '\nPlease see https://next-intl.dev/docs/routing#domains');
|
|
21
|
+
console.warn('Locales are expected to be unique per domain, but found overlap:\n' + duplicateLocaleMessages.join('\n') + '\nPlease see https://next-intl.dev/docs/routing/configuration#domains');
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -17,7 +17,7 @@ async function getLocaleFromHeaderImpl() {
|
|
|
17
17
|
locale = (await getHeaders()).get(HEADER_LOCALE_NAME) || undefined;
|
|
18
18
|
} catch (error) {
|
|
19
19
|
if (error instanceof Error && error.digest === 'DYNAMIC_SERVER_USAGE') {
|
|
20
|
-
const wrappedError = 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/
|
|
20
|
+
const wrappedError = 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/routing/setup#static-rendering', {
|
|
21
21
|
cause: error
|
|
22
22
|
});
|
|
23
23
|
wrappedError.digest = error.digest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{usePathname as e}from"next/navigation";import{useMemo as r}from"react";import{useLocale as o}from"use-intl";import{hasPathnamePrefixed as t,unprefixPathname as i,getLocalePrefix as f,getLocaleAsPrefix as l}from"../../shared/utils.js";function n(n){const s=e(),a=o();return r((()=>{if(!s)return s;let e=s;const r=f(a,n.localePrefix);if(t(r,s))e=i(s,r);else if("
|
|
1
|
+
import{usePathname as e}from"next/navigation";import{useMemo as r}from"react";import{useLocale as o}from"use-intl";import{hasPathnamePrefixed as t,unprefixPathname as i,getLocalePrefix as f,getLocaleAsPrefix as l}from"../../shared/utils.js";function n(n){const s=e(),a=o();return r((()=>{if(!s)return s;let e=s;const r=f(a,n.localePrefix);if(t(r,s))e=i(s,r);else if("never"!==n.localePrefix.mode&&n.localePrefix.prefixes){const r=l(a);t(r,s)&&(e=i(s,r))}return e}),[n.localePrefix,a,s])}export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"fs";import s from"path";import{throwError as t}from"./utils.js";import o from"./watchFile.js";function n(o){var n;["
|
|
1
|
+
import e from"fs";import s from"path";import{throwError as t}from"./utils.js";import o from"./watchFile.js";function n(o){var n;["info","start"].some((e=>process.argv.includes(e)))||(n=()=>{for(const n of o){const o=s.resolve(n);e.existsSync(o)||t(`\`createMessagesDeclaration\` points to a non-existent file: ${o}`),o.endsWith(".json")||t(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${o}`);const c=process.env["NODE_ENV".trim()];i(n),"development"===c&&r(n)}},"1"!==process.env._NEXT_INTL_COMPILE_MESSAGES&&(process.env._NEXT_INTL_COMPILE_MESSAGES="1",n()))}function r(e){const s=o(e,(()=>{i(e,!0)}));process.on("exit",(()=>{s.close()}))}function i(s,t=!1){const o=s.replace(/\.json$/,".d.json.ts");function n(e){return`// This file is auto-generated by next-intl, do not edit directly.\n// See: https://next-intl.dev/docs/workflows/typescript#messages-arguments\n\ndeclare const messages: ${e.trim()};\nexport default messages;`}if(t)return e.promises.readFile(s,"utf-8").then((s=>e.promises.writeFile(o,n(s))));const r=e.readFileSync(s,"utf-8");e.writeFileSync(o,n(r))}export{n 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{isPromise as r}from"../../shared/utils.js";import{getCachedRequestLocale as o}from"./RequestLocaleCache.js";const s=e((async function(){const e=t();return r(e)?await e:e}));const i=e((async function(){let t;try{t=(await s()).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/
|
|
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 s=e((async function(){const e=t();return r(e)?await e:e}));const i=e((async function(){let t;try{t=(await s()).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/routing/setup#static-rendering",{cause:t});throw e.digest=t.digest,e}throw t}return t}));async function a(){return o()||await i()}export{a as getRequestLocale};
|
|
@@ -14,12 +14,12 @@ export type RoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extend
|
|
|
14
14
|
defaultLocale: AppLocales[number];
|
|
15
15
|
/**
|
|
16
16
|
* Configures whether and which prefix is shown for a given locale.
|
|
17
|
-
* @see https://next-intl.dev/docs/routing#locale-prefix
|
|
17
|
+
* @see https://next-intl.dev/docs/routing/configuration#locale-prefix
|
|
18
18
|
**/
|
|
19
19
|
localePrefix?: LocalePrefix<AppLocales, AppLocalePrefixMode>;
|
|
20
20
|
/**
|
|
21
21
|
* Can be used to change the locale handling per domain.
|
|
22
|
-
* @see https://next-intl.dev/docs/routing#domains
|
|
22
|
+
* @see https://next-intl.dev/docs/routing/configuration#domains
|
|
23
23
|
**/
|
|
24
24
|
domains?: AppDomains;
|
|
25
25
|
/**
|
|
@@ -40,7 +40,7 @@ export type RoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extend
|
|
|
40
40
|
} & ([AppPathnames] extends [never] ? {} : {
|
|
41
41
|
/**
|
|
42
42
|
* A map of localized pathnames per locale.
|
|
43
|
-
* @see https://next-intl.dev/docs/routing#pathnames
|
|
43
|
+
* @see https://next-intl.dev/docs/routing/configuration#pathnames
|
|
44
44
|
**/
|
|
45
45
|
pathnames: AppPathnames;
|
|
46
46
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.7",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
114
114
|
"negotiator": "^1.0.0",
|
|
115
|
-
"use-intl": "^4.3.
|
|
115
|
+
"use-intl": "^4.3.7"
|
|
116
116
|
},
|
|
117
117
|
"peerDependencies": {
|
|
118
118
|
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"optional": true
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "bc4e86eeac892403555af0dd2cdc18117dbefdde"
|
|
128
128
|
}
|