next-intl 4.0.0-beta-db95243 → 4.0.0-beta-7e7011d
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 +5 -5
- package/dist/cjs/development/plugin.cjs +2 -2
- package/dist/esm/development/config.js +1 -1
- package/dist/esm/development/middleware/middleware.js +1 -1
- package/dist/esm/development/navigation/react-client/createNavigation.js +6 -6
- package/dist/esm/development/navigation/react-client/useBasePathname.js +15 -6
- package/dist/esm/development/navigation/shared/BaseLink.js +2 -2
- package/dist/esm/development/navigation/shared/createSharedNavigationFns.js +2 -2
- package/dist/esm/development/navigation/shared/utils.js +1 -1
- package/dist/esm/development/plugin/createMessagesDeclaration.js +1 -1
- package/dist/esm/development/plugin/createNextIntlPlugin.js +1 -1
- package/dist/esm/development/react-client/index.js +1 -1
- package/dist/esm/development/react-server/useConfig.js +1 -1
- package/dist/esm/development/server/react-server/RequestLocale.js +2 -2
- package/dist/esm/development/server/react-server/getConfig.js +2 -2
- package/dist/esm/development/server/react-server/getDefaultNow.js +1 -1
- package/dist/esm/development/server/react-server/getMessages.js +1 -1
- package/dist/esm/development/server/react-server/getTranslations.js +3 -3
- package/dist/esm/development/shared/NextIntlClientProvider.js +1 -1
- package/dist/esm/development/shared/utils.js +5 -2
- package/dist/esm/production/config.js +1 -1
- package/dist/esm/production/middleware/middleware.js +1 -1
- package/dist/esm/production/navigation/react-client/createNavigation.js +1 -1
- package/dist/esm/production/navigation/react-client/useBasePathname.js +1 -1
- package/dist/esm/production/navigation/shared/BaseLink.js +1 -1
- package/dist/esm/production/navigation/shared/createSharedNavigationFns.js +1 -1
- package/dist/esm/production/plugin/createMessagesDeclaration.js +1 -1
- package/dist/esm/production/plugin/createNextIntlPlugin.js +1 -1
- package/dist/esm/production/react-server/useConfig.js +1 -1
- package/dist/esm/production/server/react-server/RequestLocale.js +1 -1
- package/dist/esm/production/server/react-server/getConfig.js +1 -1
- package/dist/esm/production/server/react-server/getMessages.js +1 -1
- package/dist/esm/production/shared/utils.js +1 -1
- package/dist/types/navigation/react-client/createNavigation.d.ts +3 -3
- package/dist/types/navigation/react-client/useBasePathname.d.ts +4 -1
- package/dist/types/navigation/shared/createSharedNavigationFns.d.ts +8 -8
- package/dist/types/routing/config.d.ts +8 -8
- package/dist/types/server/react-server/getRequestConfig.d.ts +2 -2
- package/dist/types/shared/utils.d.ts +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
2
|
<br>
|
|
3
|
-
<a href="https://next-intl
|
|
3
|
+
<a href="https://next-intl.dev">
|
|
4
4
|
<picture>
|
|
5
5
|
<source media="(prefers-color-scheme: dark)" srcset="media/logo-dark-mode.svg">
|
|
6
6
|
<source media="(prefers-color-scheme: light)" srcset="media/logo.svg">
|
|
@@ -29,10 +29,10 @@ Internationalization (i18n) is an essential part of the user experience, therefo
|
|
|
29
29
|
```jsx
|
|
30
30
|
// UserProfile.tsx
|
|
31
31
|
import {useTranslations} from 'next-intl';
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
export default function UserProfile({user}) {
|
|
34
34
|
const t = useTranslations('UserProfile');
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
return (
|
|
37
37
|
<section>
|
|
38
38
|
<h1>{t('title', {firstName: user.firstName})}</h1>
|
|
@@ -58,10 +58,10 @@ export default function UserProfile({user}) {
|
|
|
58
58
|
}
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
### [→ Read the docs](https://next-intl
|
|
61
|
+
### [→ Read the docs](https://next-intl.dev)
|
|
62
62
|
|
|
63
63
|
<div align="center">
|
|
64
|
-
<a href="https://next-intl
|
|
64
|
+
<a href="https://next-intl.dev/redirect?href=https://crowdin.com" target="_blank">
|
|
65
65
|
<img width="350" src="media/partner.svg" alt="Crowdin logo">
|
|
66
66
|
</a>
|
|
67
67
|
<br>
|
|
@@ -57,7 +57,7 @@ function compileDeclaration(messagesPath, async = false) {
|
|
|
57
57
|
const declarationPath = messagesPath.replace(/\.json$/, '.d.json.ts');
|
|
58
58
|
function createDeclaration(content) {
|
|
59
59
|
return `// This file is auto-generated by next-intl, do not edit directly.
|
|
60
|
-
// See: https://next-intl
|
|
60
|
+
// See: https://next-intl.dev/docs/workflows/typescript#messages-arguments
|
|
61
61
|
|
|
62
62
|
declare const messages: ${content.trim()};
|
|
63
63
|
export default messages;`;
|
|
@@ -148,7 +148,7 @@ function getNextConfig(pluginConfig, nextConfig) {
|
|
|
148
148
|
|
|
149
149
|
function initPlugin(pluginConfig, nextConfig) {
|
|
150
150
|
if (nextConfig?.i18n != null) {
|
|
151
|
-
warn("\n[next-intl] 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
|
|
151
|
+
warn("\n[next-intl] 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");
|
|
152
152
|
}
|
|
153
153
|
if (pluginConfig.experimental?.createMessagesDeclaration) {
|
|
154
154
|
createMessagesDeclaration(pluginConfig.experimental.createMessagesDeclaration);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function getConfig() {
|
|
2
|
-
throw new Error("Couldn't find next-intl config file. Please follow the instructions at https://next-intl
|
|
2
|
+
throw new Error("Couldn't find next-intl config file. Please follow the instructions at https://next-intl.dev/docs/getting-started/app-router");
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export { getConfig as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NextResponse } from 'next/server
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
2
|
import { receiveRoutingConfig } from '../routing/config.js';
|
|
3
3
|
import { HEADER_LOCALE_NAME } from '../shared/constants.js';
|
|
4
4
|
import { matchesPathname, normalizeTrailingSlash, getLocalePrefix } from '../shared/utils.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRouter, usePathname } from 'next/navigation
|
|
1
|
+
import { useRouter, usePathname } from 'next/navigation';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useLocale } from 'use-intl';
|
|
4
4
|
import createSharedNavigationFns from '../shared/createSharedNavigationFns.js';
|
|
@@ -14,9 +14,9 @@ function createNavigation(routing) {
|
|
|
14
14
|
...redirects
|
|
15
15
|
} = createSharedNavigationFns(useLocale, routing);
|
|
16
16
|
|
|
17
|
-
/** @see https://next-intl
|
|
17
|
+
/** @see https://next-intl.dev/docs/routing/navigation#usepathname */
|
|
18
18
|
function usePathname$1() {
|
|
19
|
-
const pathname = useBasePathname(config
|
|
19
|
+
const pathname = useBasePathname(config);
|
|
20
20
|
const locale = useLocale();
|
|
21
21
|
|
|
22
22
|
// @ts-expect-error -- Mirror the behavior from Next.js, where `null` is returned when `usePathname` is used outside of Next, but the types indicate that a string is always returned.
|
|
@@ -55,11 +55,11 @@ function createNavigation(routing) {
|
|
|
55
55
|
}
|
|
56
56
|
return {
|
|
57
57
|
...router,
|
|
58
|
-
/** @see https://next-intl
|
|
58
|
+
/** @see https://next-intl.dev/docs/routing/navigation#userouter */
|
|
59
59
|
push: createHandler(router.push),
|
|
60
|
-
/** @see https://next-intl
|
|
60
|
+
/** @see https://next-intl.dev/docs/routing/navigation#userouter */
|
|
61
61
|
replace: createHandler(router.replace),
|
|
62
|
-
/** @see https://next-intl
|
|
62
|
+
/** @see https://next-intl.dev/docs/routing/navigation#userouter */
|
|
63
63
|
prefetch: createHandler(router.prefetch)
|
|
64
64
|
};
|
|
65
65
|
}, [curLocale, nextPathname, router]);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { usePathname } from 'next/navigation
|
|
1
|
+
import { usePathname } from 'next/navigation';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useLocale } from 'use-intl';
|
|
4
|
-
import { hasPathnamePrefixed, unprefixPathname, getLocalePrefix } from '../../shared/utils.js';
|
|
4
|
+
import { hasPathnamePrefixed, unprefixPathname, getLocalePrefix, getLocaleAsPrefix } from '../../shared/utils.js';
|
|
5
5
|
|
|
6
|
-
function useBasePathname(
|
|
6
|
+
function useBasePathname(config) {
|
|
7
7
|
// The types aren't entirely correct here. Outside of Next.js
|
|
8
8
|
// `useParams` can be called, but the return type is `null`.
|
|
9
9
|
|
|
@@ -17,11 +17,20 @@ function useBasePathname(localePrefix) {
|
|
|
17
17
|
const locale = useLocale();
|
|
18
18
|
return useMemo(() => {
|
|
19
19
|
if (!pathname) return pathname;
|
|
20
|
-
|
|
20
|
+
let unlocalizedPathname = pathname;
|
|
21
|
+
const prefix = getLocalePrefix(locale, config.localePrefix);
|
|
21
22
|
const isPathnamePrefixed = hasPathnamePrefixed(prefix, pathname);
|
|
22
|
-
|
|
23
|
+
if (isPathnamePrefixed) {
|
|
24
|
+
unlocalizedPathname = unprefixPathname(pathname, prefix);
|
|
25
|
+
} else if (config.localePrefix.mode === 'as-needed' && config.localePrefix.prefixes) {
|
|
26
|
+
// Workaround for https://github.com/vercel/next.js/issues/73085
|
|
27
|
+
const localeAsPrefix = getLocaleAsPrefix(locale);
|
|
28
|
+
if (hasPathnamePrefixed(localeAsPrefix, pathname)) {
|
|
29
|
+
unlocalizedPathname = unprefixPathname(pathname, localeAsPrefix);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
23
32
|
return unlocalizedPathname;
|
|
24
|
-
}, [
|
|
33
|
+
}, [config.localePrefix, locale, pathname]);
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
export { useBasePathname as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import NextLink from 'next/link
|
|
3
|
-
import { usePathname } from 'next/navigation
|
|
2
|
+
import NextLink from 'next/link';
|
|
3
|
+
import { usePathname } from 'next/navigation';
|
|
4
4
|
import { forwardRef, useState, useEffect } from 'react';
|
|
5
5
|
import { useLocale } from 'use-intl';
|
|
6
6
|
import syncLocaleCookie from './syncLocaleCookie.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { redirect, permanentRedirect } from 'next/navigation
|
|
1
|
+
import { redirect, permanentRedirect } from 'next/navigation';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { receiveRoutingConfig } from '../../routing/config.js';
|
|
4
4
|
import use from '../../shared/use.js';
|
|
@@ -116,7 +116,7 @@ function createSharedNavigationFns(getLocale, routing) {
|
|
|
116
116
|
args.domain, _forcePrefix);
|
|
117
117
|
}
|
|
118
118
|
function getRedirectFn(fn) {
|
|
119
|
-
/** @see https://next-intl
|
|
119
|
+
/** @see https://next-intl.dev/docs/routing/navigation#redirect */
|
|
120
120
|
return function redirectFn(args, ...rest) {
|
|
121
121
|
return fn(
|
|
122
122
|
// @ts-expect-error -- We're forcing the prefix when no domain is provided
|
|
@@ -133,7 +133,7 @@ function applyPathnamePrefix(pathname, locale, routing, domain, force) {
|
|
|
133
133
|
defaultLocale = domainConfig.defaultLocale;
|
|
134
134
|
} else {
|
|
135
135
|
if (!domain) {
|
|
136
|
-
console.error("You're using a routing configuration with `localePrefix: 'as-needed'` in combination with `domains`. In order to compute a correct pathname, you need to provide a `domain` parameter.\n\nSee: https://next-intl
|
|
136
|
+
console.error("You're using a routing configuration with `localePrefix: 'as-needed'` in combination with `domains`. In order to compute a correct pathname, you need to provide a `domain` parameter.\n\nSee: https://next-intl.dev/docs/routing#domains-localeprefix-asneeded");
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -46,7 +46,7 @@ function compileDeclaration(messagesPath, async = false) {
|
|
|
46
46
|
const declarationPath = messagesPath.replace(/\.json$/, '.d.json.ts');
|
|
47
47
|
function createDeclaration(content) {
|
|
48
48
|
return `// This file is auto-generated by next-intl, do not edit directly.
|
|
49
|
-
// See: https://next-intl
|
|
49
|
+
// See: https://next-intl.dev/docs/workflows/typescript#messages-arguments
|
|
50
50
|
|
|
51
51
|
declare const messages: ${content.trim()};
|
|
52
52
|
export default messages;`;
|
|
@@ -4,7 +4,7 @@ import { warn } from './utils.js';
|
|
|
4
4
|
|
|
5
5
|
function initPlugin(pluginConfig, nextConfig) {
|
|
6
6
|
if (nextConfig?.i18n != null) {
|
|
7
|
-
warn("\n[next-intl] 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
|
|
7
|
+
warn("\n[next-intl] 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");
|
|
8
8
|
}
|
|
9
9
|
if (pluginConfig.experimental?.createMessagesDeclaration) {
|
|
10
10
|
createMessagesDeclaration(pluginConfig.experimental.createMessagesDeclaration);
|
|
@@ -25,7 +25,7 @@ This can happen because:
|
|
|
25
25
|
failed, and therefore React attempted to render the component on the client
|
|
26
26
|
instead. If this is the case, check the console for server errors.
|
|
27
27
|
2) You intended to render this component on the client side, but no context was found.
|
|
28
|
-
Learn more about this error here: https://next-intl
|
|
28
|
+
Learn more about this error here: https://next-intl.dev/docs/environments/server-client-components#missing-context` );
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
}
|
|
@@ -6,7 +6,7 @@ function useHook(hookName, promise) {
|
|
|
6
6
|
return use(promise);
|
|
7
7
|
} catch (error) {
|
|
8
8
|
if (error instanceof TypeError && error.message.includes("Cannot read properties of null (reading 'use')")) {
|
|
9
|
-
throw new Error(`\`${hookName}\` is not callable within an async component. Please refer to https://next-intl
|
|
9
|
+
throw new Error(`\`${hookName}\` is not callable within an async component. Please refer to https://next-intl.dev/docs/environments/server-client-components#async-components`, {
|
|
10
10
|
cause: error
|
|
11
11
|
});
|
|
12
12
|
} else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { headers } from 'next/headers
|
|
1
|
+
import { headers } from 'next/headers';
|
|
2
2
|
import { cache } from 'react';
|
|
3
3
|
import { HEADER_LOCALE_NAME } from '../../shared/constants.js';
|
|
4
4
|
import { getCachedRequestLocale } from './RequestLocaleCache.js';
|
|
@@ -16,7 +16,7 @@ async function getLocaleFromHeaderImpl() {
|
|
|
16
16
|
locale = (await getHeaders()).get(HEADER_LOCALE_NAME) || undefined;
|
|
17
17
|
} catch (error) {
|
|
18
18
|
if (error instanceof Error && error.digest === 'DYNAMIC_SERVER_USAGE') {
|
|
19
|
-
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
|
|
19
|
+
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/getting-started/app-router/with-i18n-routing#static-rendering', {
|
|
20
20
|
cause: error
|
|
21
21
|
});
|
|
22
22
|
wrappedError.digest = error.digest;
|
|
@@ -17,7 +17,7 @@ Please verify that:
|
|
|
17
17
|
1. In case you've specified a custom location in your Next.js config, make sure that the path is correct.
|
|
18
18
|
2. You have a default export in your i18n request configuration file.
|
|
19
19
|
|
|
20
|
-
See also: https://next-intl
|
|
20
|
+
See also: https://next-intl.dev/docs/usage/configuration#i18n-request
|
|
21
21
|
`);
|
|
22
22
|
}
|
|
23
23
|
const params = {
|
|
@@ -33,7 +33,7 @@ See also: https://next-intl-docs.vercel.app/docs/usage/configuration#i18n-reques
|
|
|
33
33
|
result = await result;
|
|
34
34
|
}
|
|
35
35
|
if (!result.locale) {
|
|
36
|
-
throw new Error('No locale was returned from `getRequestConfig`.\n\nSee https://next-intl
|
|
36
|
+
throw new Error('No locale was returned from `getRequestConfig`.\n\nSee https://next-intl.dev/docs/usage/configuration#i18n-request');
|
|
37
37
|
}
|
|
38
38
|
return result;
|
|
39
39
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cache } from 'react';
|
|
2
2
|
|
|
3
3
|
function defaultNow() {
|
|
4
|
-
// See https://next-intl
|
|
4
|
+
// See https://next-intl.dev/docs/usage/dates-times#relative-times-server
|
|
5
5
|
return new Date();
|
|
6
6
|
}
|
|
7
7
|
const getDefaultNow = cache(defaultNow);
|
|
@@ -3,7 +3,7 @@ import getConfig from './getConfig.js';
|
|
|
3
3
|
|
|
4
4
|
function getMessagesFromConfig(config) {
|
|
5
5
|
if (!config.messages) {
|
|
6
|
-
throw new Error('No messages found. Have you configured them correctly? See https://next-intl
|
|
6
|
+
throw new Error('No messages found. Have you configured them correctly? See https://next-intl.dev/docs/configuration#messages');
|
|
7
7
|
}
|
|
8
8
|
return config.messages;
|
|
9
9
|
}
|
|
@@ -6,11 +6,11 @@ import getServerTranslator from './getServerTranslator.js';
|
|
|
6
6
|
// We need to define these with function overloads, otherwise TypeScript
|
|
7
7
|
// messes up the return type.
|
|
8
8
|
|
|
9
|
-
//
|
|
9
|
+
// Call signature 1: `getTranslations(namespace)`
|
|
10
10
|
|
|
11
|
-
//
|
|
11
|
+
// Call signature 2: `getTranslations({locale, namespace})`
|
|
12
12
|
|
|
13
|
-
//
|
|
13
|
+
// Implementation
|
|
14
14
|
async function getTranslations(namespaceOrOpts) {
|
|
15
15
|
let namespace;
|
|
16
16
|
let locale;
|
|
@@ -7,7 +7,7 @@ function NextIntlClientProvider({
|
|
|
7
7
|
...rest
|
|
8
8
|
}) {
|
|
9
9
|
if (!locale) {
|
|
10
|
-
throw new Error("Couldn't infer the `locale` prop in `NextIntlClientProvider`, please provide it explicitly.\n\nSee https://next-intl
|
|
10
|
+
throw new Error("Couldn't infer the `locale` prop in `NextIntlClientProvider`, please provide it explicitly.\n\nSee https://next-intl.dev/docs/configuration#locale" );
|
|
11
11
|
}
|
|
12
12
|
return /*#__PURE__*/jsx(IntlProvider, {
|
|
13
13
|
locale: locale,
|
|
@@ -61,7 +61,10 @@ function getLocalePrefix(locale, localePrefix) {
|
|
|
61
61
|
return localePrefix.mode !== 'never' && localePrefix.prefixes?.[locale] ||
|
|
62
62
|
// We return a prefix even if `mode: 'never'`. It's up to the consumer
|
|
63
63
|
// to decide to use it or not.
|
|
64
|
-
|
|
64
|
+
getLocaleAsPrefix(locale);
|
|
65
|
+
}
|
|
66
|
+
function getLocaleAsPrefix(locale) {
|
|
67
|
+
return '/' + locale;
|
|
65
68
|
}
|
|
66
69
|
function templateToRegex(template) {
|
|
67
70
|
const regexPattern = template
|
|
@@ -120,4 +123,4 @@ function getSortedPathnames(pathnames) {
|
|
|
120
123
|
return pathnames.sort(comparePathnamePairs);
|
|
121
124
|
}
|
|
122
125
|
|
|
123
|
-
export { getLocalePrefix, getSortedPathnames, hasPathnamePrefixed, isLocalizableHref, matchesPathname, normalizeTrailingSlash, prefixPathname, templateToRegex, unprefixPathname };
|
|
126
|
+
export { getLocaleAsPrefix, getLocalePrefix, getSortedPathnames, hasPathnamePrefixed, isLocalizableHref, matchesPathname, normalizeTrailingSlash, prefixPathname, templateToRegex, unprefixPathname };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(){throw new Error("Couldn't find next-intl config file. Please follow the instructions at https://next-intl
|
|
1
|
+
function t(){throw new Error("Couldn't find next-intl config file. Please follow the instructions at https://next-intl.dev/docs/getting-started/app-router")}export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as e}from"next/server
|
|
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 o,normalizeTrailingSlash as a,getLocalePrefix as l}from"../shared/utils.js";import n from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import i from"./syncCookie.js";import{sanitizePathname as c,isLocaleSupportedOnDomain as d,getNormalizedPathname as f,getPathnameMatch as m,getInternalTemplate as h,formatTemplatePathname as x,formatPathname as p,getBestMatchingDomain as u,applyBasePath as U,getLocaleAsPrefix as P}from"./utils.js";function g(g){const v=t(g);return function(t){let g;try{g=decodeURI(t.nextUrl.pathname)}catch{return e.next()}const L=c(g),{domain:j,locale:w}=s(v,t.headers,t.cookies,L),k=j?j.defaultLocale===w:w===v.defaultLocale,b=v.domains?.filter((e=>d(w,e)))||[],y=null!=v.domains&&!j;function R(o){const a=new URL(o,t.url);t.nextUrl.basePath&&(a.pathname=U(a.pathname,t.nextUrl.basePath));const l=new Headers(t.headers);return l.set(r,w),e.rewrite(a,{request:{headers:l}})}function q(r,o){const l=new URL(r,t.url);if(l.pathname=a(l.pathname),b.length>0&&!o&&j){const e=u(j,w,b);e&&(o=e.domain,e.defaultLocale===w&&"as-needed"===v.localePrefix.mode&&(l.pathname=f(l.pathname,v.locales,v.localePrefix)))}return o&&(l.host=o,t.headers.get("x-forwarded-host")&&(l.protocol=t.headers.get("x-forwarded-proto")??t.nextUrl.protocol,l.port=t.headers.get("x-forwarded-port")??"")),t.nextUrl.basePath&&(l.pathname=U(l.pathname,t.nextUrl.basePath)),e.redirect(l.toString())}const H=f(L,v.locales,v.localePrefix),z=m(L,v.locales,v.localePrefix),A=null!=z,C="never"===v.localePrefix.mode||k&&"as-needed"===v.localePrefix.mode;let I,S,V=H;const B=v.pathnames;if(B){let e;if([e,S]=h(B,H,w),S){const r=B[S],a="string"==typeof r?r:r[w];if(o(a,H))V=x(H,a,S);else{let o;o=e?"string"==typeof r?r:r[e]:S;const n=C?void 0:l(w,v.localePrefix),s=x(H,o,a);I=q(p(s,n,t.nextUrl.search))}}}if(!I)if("/"!==V||A){const e=p(V,P(w),t.nextUrl.search);if(A){const r=p(H,z.prefix,t.nextUrl.search);if("never"===v.localePrefix.mode)I=q(p(H,void 0,t.nextUrl.search));else if(z.exact)if(k&&C)I=q(p(H,void 0,t.nextUrl.search));else if(v.domains){const t=u(j,z.locale,b);I=j?.domain===t?.domain||y?R(e):q(r,t?.domain)}else I=R(e);else I=q(r)}else I=C?R(e):q(p(H,l(w,v.localePrefix),t.nextUrl.search))}else I=C?R(p(V,P(w),t.nextUrl.search)):q(p(H,l(w,v.localePrefix),t.nextUrl.search));return i(t,I,w,v,j),"never"!==v.localePrefix.mode&&v.alternateLinks&&v.locales.length>1&&I.headers.set("Link",n({routing:v,localizedPathnames:null!=S&&B?B[S]:void 0,request:t,resolvedLocale:w})),I}}export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRouter as e,usePathname as t}from"next/navigation
|
|
1
|
+
import{useRouter as e,usePathname as t}from"next/navigation";import{useMemo as o}from"react";import{useLocale as n}from"use-intl";import r from"../shared/createSharedNavigationFns.js";import a from"../shared/syncLocaleCookie.js";import{getRoute as s}from"../shared/utils.js";import i from"./useBasePathname.js";function c(c){const{Link:m,config:u,getPathname:h,...f}=r(n,c);return{...f,Link:m,usePathname:function(){const e=i(u),t=n();return o((()=>e&&u.pathnames?s(t,e,u.pathnames):e),[t,e])},useRouter:function(){const r=e(),s=n(),i=t();return o((()=>{function e(e){return function(t,o){const{locale:n,...r}=o||{},c=[h({href:t,locale:n||s,domain:window.location.host})];Object.keys(r).length>0&&c.push(r),e(...c),a(u.localeCookie,i,s,n)}}return{...r,push:e(r.push),replace:e(r.replace),prefetch:e(r.prefetch)}}),[s,i,r])},getPathname:h}}export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{usePathname as
|
|
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("as-needed"===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,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import o from"next/link
|
|
2
|
+
import o from"next/link";import{usePathname as e}from"next/navigation";import{forwardRef as n,useState as t,useEffect as r}from"react";import{useLocale as i}from"use-intl";import c from"./syncLocaleCookie.js";import{jsx as a}from"react/jsx-runtime";function f({defaultLocale:n,href:f,locale:l,localeCookie:m,onClick:s,prefetch:u,unprefixed:p,...d},h){const k=i(),j=null!=l&&l!==k,x=l||k,C=function(){const[o,e]=t();return r((()=>{e(window.location.host)}),[]),o}(),v=C&&p&&(p.domains[C]===x||!Object.keys(p.domains).includes(C)&&k===n&&!l)?p.pathname:f,L=e();j&&(u=!1);return a(o,{ref:h,href:v,hrefLang:j?l:void 0,onClick:function(o){c(m,L,k,l),s&&s(o)},prefetch:u,...d})}var l=n(f);export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{redirect as e,permanentRedirect as o}from"next/navigation
|
|
1
|
+
import{redirect as e,permanentRedirect as o}from"next/navigation";import{forwardRef as a}from"react";import{receiveRoutingConfig as t}from"../../routing/config.js";import n from"../../shared/use.js";import{isLocalizableHref as r}from"../../shared/utils.js";import i from"./BaseLink.js";import{serializeSearchParams as m,compileLocalizedPathname as l,applyPathnamePrefix as c,normalizeNameOrNameWithParams as f}from"./utils.js";import{jsx as s}from"react/jsx-runtime";function u(u,p){const d=t(p||{}),h=d.pathnames,j="as-needed"===d.localePrefix.mode&&d.domains||void 0;function g({href:e,locale:o,...a},t){let m,l;"object"==typeof e?(m=e.pathname,l=e.params):m=e;const c=r(e),f=u(),p=f instanceof Promise?n(f):f,g=c?x({locale:o||p,href:null==h?m:{pathname:m,params:l}},null!=o||j||void 0):m;return s(i,{ref:t,defaultLocale:d.defaultLocale,href:"object"==typeof e?{...e,pathname:g}:g,locale:o,localeCookie:d.localeCookie,unprefixed:j&&c?{domains:d.domains.reduce(((e,o)=>(e[o.domain]=o.defaultLocale,e)),{}),pathname:x({locale:p,href:null==h?m:{pathname:m,params:l}},!1)}:void 0,...a})}const v=a(g);function x(e,o){const{href:a,locale:t}=e;let n;return null==h?"object"==typeof a?(n=a.pathname,a.query&&(n+=m(a.query))):n=a:n=l({locale:t,...f(a),pathnames:d.pathnames}),c(n,t,d,e.domain,o)}function y(e){return function(o,...a){return e(x(o,o.domain?void 0:j),...a)}}const L=y(e),k=y(o);return{config:d,Link:v,redirect:L,permanentRedirect:k,getPathname:x}}export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"fs";import s from"path";import{throwError as t}from"./utils.js";function n(n){const i=s.resolve(n);e.existsSync(i)||t(`\`createMessagesDeclaration\` points to a non-existent file: ${i}`),i.endsWith(".json")||t(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${i}`);const r=process.argv.includes("dev"),c=process.argv.includes("build");var a;(r||c)&&(a=()=>{o(n),r&&function(s){const t=e.watch(s,(e=>{"change"===e&&o(s,!0)}));process.on("exit",(()=>{t.close()}))}(n)},"1"!==process.env._NEXT_INTL_COMPILE_MESSAGES&&(process.env._NEXT_INTL_COMPILE_MESSAGES="1",a()))}function o(s,t=!1){const n=s.replace(/\.json$/,".d.json.ts");function o(e){return`// This file is auto-generated by next-intl, do not edit directly.\n// See: https://next-intl
|
|
1
|
+
import e from"fs";import s from"path";import{throwError as t}from"./utils.js";function n(n){const i=s.resolve(n);e.existsSync(i)||t(`\`createMessagesDeclaration\` points to a non-existent file: ${i}`),i.endsWith(".json")||t(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${i}`);const r=process.argv.includes("dev"),c=process.argv.includes("build");var a;(r||c)&&(a=()=>{o(n),r&&function(s){const t=e.watch(s,(e=>{"change"===e&&o(s,!0)}));process.on("exit",(()=>{t.close()}))}(n)},"1"!==process.env._NEXT_INTL_COMPILE_MESSAGES&&(process.env._NEXT_INTL_COMPILE_MESSAGES="1",a()))}function o(s,t=!1){const n=s.replace(/\.json$/,".d.json.ts");function o(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(n,o(s))));const i=e.readFileSync(s,"utf-8");e.writeFileSync(n,o(i))}export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./createMessagesDeclaration.js";import t from"./getNextConfig.js";import{warn as r}from"./utils.js";function n(n={}){const o="string"==typeof n?{requestConfig:n}:n;return function(n){return function(n,o){return null!=o?.i18n&&r("\n[next-intl] 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
|
|
1
|
+
import e from"./createMessagesDeclaration.js";import t from"./getNextConfig.js";import{warn as r}from"./utils.js";function n(n={}){const o="string"==typeof n?{requestConfig:n}:n;return function(n){return function(n,o){return null!=o?.i18n&&r("\n[next-intl] 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"),n.experimental?.createMessagesDeclaration&&e(n.experimental.createMessagesDeclaration),t(n,o)}(o,n)}}export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../server/react-server/getConfig.js";import
|
|
1
|
+
import e from"../server/react-server/getConfig.js";import n from"../shared/use.js";function r(r){return function(e,r){try{return n(r)}catch(n){throw n instanceof TypeError&&n.message.includes("Cannot read properties of null (reading 'use')")?new Error(`\`${e}\` is not callable within an async component. Please refer to https://next-intl.dev/docs/environments/server-client-components#async-components`,{cause:n}):n}}(r,e())}export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{headers as t}from"next/headers
|
|
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{getCachedRequestLocale as r}from"./RequestLocaleCache.js";const o=e((async function(){const e=t();return e instanceof Promise?await e:e}));const i=e((async function(){let t;try{t=(await o()).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 s(){return r()||await i()}export{s as getRequestLocale};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as e}from"react";import{_createIntlFormatters as t,_createCache as o,initializeConfig as n}from"use-intl/core";import{getRequestLocale as r}from"./RequestLocale.js";import i from"next-intl/config";const s=e((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const a=e((async function(e,t){let o=e({get requestLocale(){return t?Promise.resolve(t):r()}});if(o instanceof Promise&&(o=await o),!o.locale)throw new Error("No locale was returned from `getRequestConfig`.\n\nSee https://next-intl
|
|
1
|
+
import{cache as e}from"react";import{_createIntlFormatters as t,_createCache as o,initializeConfig as n}from"use-intl/core";import{getRequestLocale as r}from"./RequestLocale.js";import i from"next-intl/config";const s=e((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const a=e((async function(e,t){let o=e({get requestLocale(){return t?Promise.resolve(t):r()}});if(o instanceof Promise&&(o=await o),!o.locale)throw new Error("No locale was returned from `getRequestConfig`.\n\nSee https://next-intl.dev/docs/usage/configuration#i18n-request");return o})),c=e(t),m=e(o);const u=e((async function(e){const t=await a(i,e);return{...n(t),_formatters:c(m()),timeZone:t.timeZone||s()}}));export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as e}from"react";import
|
|
1
|
+
import{cache as e}from"react";import t from"./getConfig.js";function o(e){if(!e.messages)throw new Error("No messages found. Have you configured them correctly? See https://next-intl.dev/docs/configuration#messages");return e.messages}const n=e((async function(e){return o(await t(e))}));async function r(e){return n(e?.locale)}export{r as default,o as getMessagesFromConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
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(n,t){return n.replace(new RegExp(`^${t}`),"")||"/"}function e(n,t){let e=n;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),e+=t,e}function r(n,t){return t===n||t.startsWith(`${n}/`)}function u(n){const t=function(){try{return"true"===process.env._next_intl_trailing_slash}catch{return!1}}();if("/"!==n){const e=n.endsWith("/");t&&!e?n+="/":!t&&e&&(n=n.slice(0,-1))}return n}function i(n,t){const e=u(n),r=u(t);return f(e).test(r)}function c(n,t){return"never"!==t.mode&&t.prefixes?.[n]||o(n)}function o(n){return"/"+n}function f(n){const t=n.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp(`^${t}$`)}function s(n){return n.includes("[[...")}function l(n){return n.includes("[...")}function a(n){return n.includes("[")}function p(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(!a(t)&&a(u))return-1;if(a(t)&&!a(u))return 1;if(!l(t)&&l(u))return-1;if(l(t)&&!l(u))return 1;if(!s(t)&&s(u))return-1;if(s(t)&&!s(u))return 1}}return 0}function h(n){return n.sort(p)}export{o as getLocaleAsPrefix,c as getLocalePrefix,h as getSortedPathnames,r as hasPathnamePrefixed,n as isLocalizableHref,i as matchesPathname,u as normalizeTrailingSlash,e as prefixPathname,f as templateToRegex,t as unprefixPathname};
|
|
@@ -311,7 +311,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
311
311
|
}, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
312
312
|
usePathname: () => [AppPathnames] extends [never] ? string : keyof AppPathnames;
|
|
313
313
|
useRouter: () => {
|
|
314
|
-
/** @see https://next-intl
|
|
314
|
+
/** @see https://next-intl.dev/docs/routing/navigation#userouter */
|
|
315
315
|
push: (href: Parameters<(args: {
|
|
316
316
|
href: [AppPathnames] extends [never] ? string | {
|
|
317
317
|
pathname: string;
|
|
@@ -337,7 +337,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
337
337
|
} : {})) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & {
|
|
338
338
|
locale?: Locale;
|
|
339
339
|
}) | undefined) => void;
|
|
340
|
-
/** @see https://next-intl
|
|
340
|
+
/** @see https://next-intl.dev/docs/routing/navigation#userouter */
|
|
341
341
|
replace: (href: Parameters<(args: {
|
|
342
342
|
href: [AppPathnames] extends [never] ? string | {
|
|
343
343
|
pathname: string;
|
|
@@ -363,7 +363,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
363
363
|
} : {})) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & {
|
|
364
364
|
locale?: Locale;
|
|
365
365
|
}) | undefined) => void;
|
|
366
|
-
/** @see https://next-intl
|
|
366
|
+
/** @see https://next-intl.dev/docs/routing/navigation#userouter */
|
|
367
367
|
prefetch: (href: Parameters<(args: {
|
|
368
368
|
href: [AppPathnames] extends [never] ? string | {
|
|
369
369
|
pathname: string;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { LocalePrefixConfigVerbose, LocalePrefixMode, Locales } from '../../routing/types.tsx';
|
|
2
|
-
export default function useBasePathname<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(
|
|
2
|
+
export default function useBasePathname<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(config: {
|
|
3
|
+
localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>;
|
|
4
|
+
defaultLocale?: AppLocales[number];
|
|
5
|
+
}): string | null;
|
|
@@ -329,7 +329,7 @@ export default function createSharedNavigationFns<const AppLocales extends Local
|
|
|
329
329
|
} & Omit<import("url").UrlObject, "pathname">) : never : never;
|
|
330
330
|
}, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
331
331
|
redirect: (args: Omit<Parameters<(args: {
|
|
332
|
-
/** @see https://next-intl
|
|
332
|
+
/** @see https://next-intl.dev/docs/routing/navigation#getpathname */
|
|
333
333
|
href: [AppPathnames] extends [never] ? string | {
|
|
334
334
|
pathname: string;
|
|
335
335
|
query?: QueryParams;
|
|
@@ -338,18 +338,18 @@ export default function createSharedNavigationFns<const AppLocales extends Local
|
|
|
338
338
|
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : {
|
|
339
339
|
/**
|
|
340
340
|
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned.
|
|
341
|
-
* @see https://next-intl
|
|
341
|
+
* @see https://next-intl.dev/docs/routing/navigation#getpathname
|
|
342
342
|
*/
|
|
343
343
|
domain: AppDomains[number]["domain"];
|
|
344
344
|
} : {}), _forcePrefix?: boolean) => string>[0], "domain"> & Partial<([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : {
|
|
345
345
|
/**
|
|
346
346
|
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned.
|
|
347
|
-
* @see https://next-intl
|
|
347
|
+
* @see https://next-intl.dev/docs/routing/navigation#getpathname
|
|
348
348
|
*/
|
|
349
349
|
domain: AppDomains[number]["domain"];
|
|
350
350
|
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
351
351
|
permanentRedirect: (args: Omit<Parameters<(args: {
|
|
352
|
-
/** @see https://next-intl
|
|
352
|
+
/** @see https://next-intl.dev/docs/routing/navigation#getpathname */
|
|
353
353
|
href: [AppPathnames] extends [never] ? string | {
|
|
354
354
|
pathname: string;
|
|
355
355
|
query?: QueryParams;
|
|
@@ -358,18 +358,18 @@ export default function createSharedNavigationFns<const AppLocales extends Local
|
|
|
358
358
|
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : {
|
|
359
359
|
/**
|
|
360
360
|
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned.
|
|
361
|
-
* @see https://next-intl
|
|
361
|
+
* @see https://next-intl.dev/docs/routing/navigation#getpathname
|
|
362
362
|
*/
|
|
363
363
|
domain: AppDomains[number]["domain"];
|
|
364
364
|
} : {}), _forcePrefix?: boolean) => string>[0], "domain"> & Partial<([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : {
|
|
365
365
|
/**
|
|
366
366
|
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned.
|
|
367
|
-
* @see https://next-intl
|
|
367
|
+
* @see https://next-intl.dev/docs/routing/navigation#getpathname
|
|
368
368
|
*/
|
|
369
369
|
domain: AppDomains[number]["domain"];
|
|
370
370
|
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
371
371
|
getPathname: (args: Parameters<(args: {
|
|
372
|
-
/** @see https://next-intl
|
|
372
|
+
/** @see https://next-intl.dev/docs/routing/navigation#getpathname */
|
|
373
373
|
href: [AppPathnames] extends [never] ? string | {
|
|
374
374
|
pathname: string;
|
|
375
375
|
query?: QueryParams;
|
|
@@ -378,7 +378,7 @@ export default function createSharedNavigationFns<const AppLocales extends Local
|
|
|
378
378
|
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : {
|
|
379
379
|
/**
|
|
380
380
|
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned.
|
|
381
|
-
* @see https://next-intl
|
|
381
|
+
* @see https://next-intl.dev/docs/routing/navigation#getpathname
|
|
382
382
|
*/
|
|
383
383
|
domain: AppDomains[number]["domain"];
|
|
384
384
|
} : {}), _forcePrefix?: boolean) => string>[0]) => string;
|
|
@@ -4,43 +4,43 @@ type CookieAttributes = Pick<NonNullable<Parameters<typeof NextResponse.prototyp
|
|
|
4
4
|
export type RoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined> = {
|
|
5
5
|
/**
|
|
6
6
|
* All available locales.
|
|
7
|
-
* @see https://next-intl
|
|
7
|
+
* @see https://next-intl.dev/docs/routing
|
|
8
8
|
*/
|
|
9
9
|
locales: AppLocales;
|
|
10
10
|
/**
|
|
11
11
|
* Used when no locale matches.
|
|
12
|
-
* @see https://next-intl
|
|
12
|
+
* @see https://next-intl.dev/docs/routing
|
|
13
13
|
*/
|
|
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
|
|
17
|
+
* @see https://next-intl.dev/docs/routing#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
|
|
22
|
+
* @see https://next-intl.dev/docs/routing#domains
|
|
23
23
|
**/
|
|
24
24
|
domains?: AppDomains;
|
|
25
25
|
/**
|
|
26
26
|
* Can be used to disable the locale cookie or to customize it.
|
|
27
|
-
* @see https://next-intl
|
|
27
|
+
* @see https://next-intl.dev/docs/routing/middleware#locale-cookie
|
|
28
28
|
*/
|
|
29
29
|
localeCookie?: boolean | CookieAttributes;
|
|
30
30
|
/**
|
|
31
31
|
* Sets the `Link` response header to notify search engines about content in other languages (defaults to `true`). See https://developers.google.com/search/docs/specialty/international/localized-versions#http
|
|
32
|
-
* @see https://next-intl
|
|
32
|
+
* @see https://next-intl.dev/docs/routing/middleware#alternate-links
|
|
33
33
|
**/
|
|
34
34
|
alternateLinks?: boolean;
|
|
35
35
|
/**
|
|
36
36
|
* By setting this to `false`, the cookie as well as the `accept-language` header will no longer be used for locale detection.
|
|
37
|
-
* @see https://next-intl
|
|
37
|
+
* @see https://next-intl.dev/docs/routing/middleware#locale-detection
|
|
38
38
|
**/
|
|
39
39
|
localeDetection?: boolean;
|
|
40
40
|
} & ([AppPathnames] extends [never] ? {} : {
|
|
41
41
|
/**
|
|
42
42
|
* A map of localized pathnames per locale.
|
|
43
|
-
* @see https://next-intl
|
|
43
|
+
* @see https://next-intl.dev/docs/routing#pathnames
|
|
44
44
|
**/
|
|
45
45
|
pathnames: AppPathnames;
|
|
46
46
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IntlConfig } from 'use-intl/core';
|
|
2
2
|
export type RequestConfig = Omit<IntlConfig, 'locale'> & {
|
|
3
3
|
/**
|
|
4
|
-
* @see https://next-intl
|
|
4
|
+
* @see https://next-intl.dev/docs/usage/configuration#i18n-request
|
|
5
5
|
**/
|
|
6
6
|
locale: IntlConfig['locale'];
|
|
7
7
|
};
|
|
@@ -19,7 +19,7 @@ export type GetRequestConfigParams = {
|
|
|
19
19
|
* catch-all for unknown routes (e.g. `/unknown.txt`), invalid values should
|
|
20
20
|
* be replaced with a valid locale.
|
|
21
21
|
*
|
|
22
|
-
* @see https://next-intl
|
|
22
|
+
* @see https://next-intl.dev/docs/usage/configuration#i18n-request
|
|
23
23
|
*/
|
|
24
24
|
requestLocale: Promise<string | undefined>;
|
|
25
25
|
};
|
|
@@ -12,6 +12,7 @@ template: string,
|
|
|
12
12
|
/** E.g. `/users/23-jane` */
|
|
13
13
|
pathname: string): boolean;
|
|
14
14
|
export declare function getLocalePrefix<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(locale: AppLocales[number], localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>): string;
|
|
15
|
+
export declare function getLocaleAsPrefix(locale: string): string;
|
|
15
16
|
export declare function templateToRegex(template: string): RegExp;
|
|
16
17
|
export declare function getSortedPathnames(pathnames: Array<string>): string[];
|
|
17
18
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "4.0.0-beta-
|
|
3
|
+
"version": "4.0.0-beta-7e7011d",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"description": "Internationalization (i18n) for Next.js",
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"homepage": "https://next-intl
|
|
14
|
+
"homepage": "https://next-intl.dev",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "https://github.com/amannn/next-intl"
|
|
@@ -112,11 +112,11 @@
|
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
114
114
|
"negotiator": "^1.0.0",
|
|
115
|
-
"use-intl": "4.0.0-beta-
|
|
115
|
+
"use-intl": "4.0.0-beta-7e7011d"
|
|
116
116
|
},
|
|
117
117
|
"peerDependencies": {
|
|
118
118
|
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
119
|
-
"react": "^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0",
|
|
119
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0",
|
|
120
120
|
"typescript": "^5.0.0"
|
|
121
121
|
},
|
|
122
122
|
"peerDependenciesMeta": {
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"optional": true
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "8b5006b6a3d8bec471a5e9a4564c31befb5241b0"
|
|
128
128
|
}
|