next-intl 3.21.1 → 3.21.2-canary.0
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/middleware/middleware.js +19 -17
- package/dist/development/middleware/resolveLocale.js +20 -34
- package/dist/development/middleware/syncCookie.js +8 -7
- package/dist/development/navigation/react-client/ClientLink.js +2 -2
- package/dist/development/navigation/react-client/createLocalizedPathnamesNavigation.js +6 -1
- package/dist/development/navigation/react-client/createNavigation.js +83 -0
- package/dist/development/navigation/react-client/createSharedPathnamesNavigation.js +6 -1
- package/dist/development/navigation/react-client/useBasePathname.js +0 -14
- package/dist/development/navigation/react-client/useBaseRouter.js +3 -3
- package/dist/development/navigation/react-server/ServerLink.js +4 -2
- package/dist/development/navigation/react-server/createLocalizedPathnamesNavigation.js +5 -4
- package/dist/development/navigation/react-server/createNavigation.js +30 -0
- package/dist/development/navigation/react-server/createSharedPathnamesNavigation.js +2 -0
- package/dist/development/navigation/react-server/redirects.js +2 -2
- package/dist/development/navigation/shared/BaseLink.js +30 -26
- package/dist/development/navigation/shared/LegacyBaseLink.js +57 -0
- package/dist/development/navigation/shared/createSharedNavigationFns.js +148 -0
- package/dist/development/navigation/shared/redirects.js +3 -0
- package/dist/development/navigation/shared/syncLocaleCookie.js +26 -5
- package/dist/development/navigation/shared/utils.js +40 -1
- package/dist/development/navigation.react-client.js +2 -0
- package/dist/development/navigation.react-server.js +2 -0
- package/dist/development/react-client/index.js +0 -2
- package/dist/development/routing/config.js +18 -1
- package/dist/development/server/react-server/RequestLocale.js +15 -25
- package/dist/development/server/react-server/RequestLocaleCache.js +23 -0
- package/dist/development/server/react-server/RequestLocaleLegacy.js +43 -0
- package/dist/development/server/react-server/getConfig.js +15 -17
- package/dist/development/server/react-server/getRequestConfig.js +1 -1
- package/dist/development/server.react-server.js +2 -2
- package/dist/development/shared/constants.js +0 -9
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/resolveLocale.js +1 -1
- package/dist/esm/middleware/syncCookie.js +1 -1
- package/dist/esm/navigation/react-client/ClientLink.js +1 -1
- package/dist/esm/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-client/createNavigation.js +1 -0
- package/dist/esm/navigation/react-client/createSharedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-client/useBasePathname.js +0 -1
- package/dist/esm/navigation/react-client/useBaseRouter.js +1 -1
- package/dist/esm/navigation/react-server/ServerLink.js +1 -1
- package/dist/esm/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-server/createNavigation.js +1 -0
- package/dist/esm/navigation/react-server/createSharedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-server/redirects.js +1 -1
- package/dist/esm/navigation/shared/BaseLink.js +1 -1
- package/dist/esm/navigation/shared/LegacyBaseLink.js +2 -0
- package/dist/esm/navigation/shared/createSharedNavigationFns.js +1 -0
- package/dist/esm/navigation/shared/syncLocaleCookie.js +1 -1
- package/dist/esm/navigation/shared/utils.js +1 -1
- package/dist/esm/navigation.react-client.js +1 -1
- package/dist/esm/navigation.react-server.js +1 -1
- package/dist/esm/routing/config.js +1 -1
- package/dist/esm/server/react-server/RequestLocale.js +1 -1
- package/dist/esm/server/react-server/RequestLocaleCache.js +1 -0
- package/dist/esm/server/react-server/RequestLocaleLegacy.js +1 -0
- package/dist/esm/server/react-server/getConfig.js +1 -1
- package/dist/esm/server.react-server.js +1 -1
- package/dist/esm/shared/constants.js +1 -1
- package/dist/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/resolveLocale.js +1 -1
- package/dist/production/middleware/syncCookie.js +1 -1
- package/dist/production/navigation/react-client/ClientLink.js +1 -1
- package/dist/production/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-client/createNavigation.js +1 -0
- package/dist/production/navigation/react-client/createSharedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-client/useBasePathname.js +0 -1
- package/dist/production/navigation/react-client/useBaseRouter.js +1 -1
- package/dist/production/navigation/react-server/ServerLink.js +1 -1
- package/dist/production/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-server/createNavigation.js +1 -0
- package/dist/production/navigation/react-server/createSharedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-server/redirects.js +1 -1
- package/dist/production/navigation/shared/BaseLink.js +1 -1
- package/dist/production/navigation/shared/LegacyBaseLink.js +2 -0
- package/dist/production/navigation/shared/createSharedNavigationFns.js +1 -0
- package/dist/production/navigation/shared/syncLocaleCookie.js +1 -1
- package/dist/production/navigation/shared/utils.js +1 -1
- package/dist/production/navigation.react-client.js +1 -1
- package/dist/production/navigation.react-server.js +1 -1
- package/dist/production/routing/config.js +1 -1
- package/dist/production/server/react-server/RequestLocale.js +1 -1
- package/dist/production/server/react-server/RequestLocaleCache.js +1 -0
- package/dist/production/server/react-server/RequestLocaleLegacy.js +1 -0
- package/dist/production/server/react-server/getConfig.js +1 -1
- package/dist/production/server.react-server.js +1 -1
- package/dist/production/shared/constants.js +1 -1
- package/dist/types/src/middleware/getAlternateLinksHeaderValue.d.ts +3 -3
- package/dist/types/src/middleware/middleware.d.ts +11 -3
- package/dist/types/src/middleware/resolveLocale.d.ts +2 -3
- package/dist/types/src/middleware/syncCookie.d.ts +2 -1
- package/dist/types/src/middleware/utils.d.ts +4 -4
- package/dist/types/src/navigation/createNavigation.test.d.ts +1 -0
- package/dist/types/src/navigation/react-client/ClientLink.d.ts +6 -6
- package/dist/types/src/navigation/react-client/createLocalizedPathnamesNavigation.d.ts +17 -5
- package/dist/types/src/navigation/react-client/createNavigation.d.ts +467 -0
- package/dist/types/src/navigation/react-client/createNavigation.test.d.ts +1 -0
- package/dist/types/src/navigation/react-client/createSharedPathnamesNavigation.d.ts +9 -5
- package/dist/types/src/navigation/react-client/index.d.ts +1 -0
- package/dist/types/src/navigation/react-client/redirects.d.ts +4 -4
- package/dist/types/src/navigation/react-client/useBasePathname.d.ts +2 -15
- package/dist/types/src/navigation/react-client/useBaseRouter.d.ts +3 -2
- package/dist/types/src/navigation/react-server/ServerLink.d.ts +5 -5
- package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +14 -5
- package/dist/types/src/navigation/react-server/createNavigation.d.ts +385 -0
- package/dist/types/src/navigation/react-server/createNavigation.test.d.ts +1 -0
- package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +3 -3
- package/dist/types/src/navigation/react-server/index.d.ts +1 -0
- package/dist/types/src/navigation/react-server/redirects.d.ts +4 -4
- package/dist/types/src/navigation/shared/BaseLink.d.ts +13 -6
- package/dist/types/src/navigation/shared/LegacyBaseLink.d.ts +12 -0
- package/dist/types/src/navigation/shared/createSharedNavigationFns.d.ts +385 -0
- package/dist/types/src/navigation/shared/redirects.d.ts +5 -5
- package/dist/types/src/navigation/shared/syncLocaleCookie.d.ts +2 -1
- package/dist/types/src/navigation/shared/utils.d.ts +10 -3
- package/dist/types/src/routing/config.d.ts +46 -11
- package/dist/types/src/routing/defineRouting.d.ts +2 -2
- package/dist/types/src/routing/types.d.ts +4 -4
- package/dist/types/src/server/react-server/RequestLocale.d.ts +1 -2
- package/dist/types/src/server/react-server/RequestLocaleCache.d.ts +2 -0
- package/dist/types/src/server/react-server/RequestLocaleLegacy.d.ts +1 -0
- package/dist/types/src/server/react-server/createRequestConfig.d.ts +2 -3
- package/dist/types/src/server/react-server/getRequestConfig.d.ts +32 -6
- package/dist/types/src/server/react-server/index.d.ts +1 -1
- package/dist/types/src/shared/constants.d.ts +0 -3
- package/dist/types/src/shared/types.d.ts +3 -0
- package/dist/types/src/shared/utils.d.ts +2 -2
- package/package.json +3 -3
- package/dist/types/src/middleware/config.d.ts +0 -7
|
@@ -1,20 +1,46 @@
|
|
|
1
1
|
import type { IntlConfig } from 'use-intl/core';
|
|
2
|
-
type RequestConfig = Omit<IntlConfig, 'locale'> & {
|
|
2
|
+
export type RequestConfig = Omit<IntlConfig, 'locale'> & {
|
|
3
3
|
/**
|
|
4
|
-
* Instead of reading a `
|
|
4
|
+
* Instead of reading a `requestLocale` from the argument that's passed to the
|
|
5
5
|
* function within `getRequestConfig`, you can include a locale as part of the
|
|
6
6
|
* returned request configuration.
|
|
7
7
|
*
|
|
8
|
-
* This
|
|
9
|
-
*
|
|
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
|
|
10
12
|
**/
|
|
11
13
|
locale?: IntlConfig['locale'];
|
|
12
14
|
};
|
|
13
15
|
export type GetRequestConfigParams = {
|
|
16
|
+
/**
|
|
17
|
+
* Deprecated in favor of `requestLocale` (see https://github.com/amannn/next-intl/pull/1383).
|
|
18
|
+
*
|
|
19
|
+
* The locale that was matched by the `[locale]` path segment. Note however
|
|
20
|
+
* that this can be overridden in async APIs when the `locale` is explicitly
|
|
21
|
+
* passed (e.g. `getTranslations({locale: 'en'})`).
|
|
22
|
+
*
|
|
23
|
+
* @deprecated
|
|
24
|
+
*/
|
|
14
25
|
locale: string;
|
|
26
|
+
/**
|
|
27
|
+
* Typically corresponds to the `[locale]` segment that was matched by the middleware.
|
|
28
|
+
*
|
|
29
|
+
* However, there are three special cases to consider:
|
|
30
|
+
* 1. **Overrides**: When an explicit `locale` is passed to awaitable functions
|
|
31
|
+
* like `getTranslations({locale: 'en'})`, then this value will be used
|
|
32
|
+
* instead of the segment.
|
|
33
|
+
* 2. **`undefined`**: The value can be `undefined` when a page outside of the
|
|
34
|
+
* `[locale]` segment renders (e.g. a language selection page at `app/page.tsx`).
|
|
35
|
+
* 3. **Invalid values**: Since the `[locale]` segment effectively acts like a
|
|
36
|
+
* catch-all for unknown routes (e.g. `/unknown.txt`), invalid values should
|
|
37
|
+
* be replaced with a valid locale.
|
|
38
|
+
*
|
|
39
|
+
* @see https://next-intl-docs.vercel.app/docs/usage/configuration#i18n-request
|
|
40
|
+
*/
|
|
41
|
+
requestLocale: Promise<string | undefined>;
|
|
15
42
|
};
|
|
16
43
|
/**
|
|
17
|
-
* Should be called in `i18n.ts` to create the configuration for the current request.
|
|
44
|
+
* Should be called in `i18n/request.ts` to create the configuration for the current request.
|
|
18
45
|
*/
|
|
19
46
|
export default function getRequestConfig(createRequestConfig: (params: GetRequestConfigParams) => RequestConfig | Promise<RequestConfig>): (params: GetRequestConfigParams) => RequestConfig | Promise<RequestConfig>;
|
|
20
|
-
export {};
|
|
@@ -8,4 +8,4 @@ export { default as getTimeZone } from './getTimeZone';
|
|
|
8
8
|
export { default as getTranslations } from './getTranslations';
|
|
9
9
|
export { default as getMessages } from './getMessages';
|
|
10
10
|
export { default as getLocale } from './getLocale';
|
|
11
|
-
export {
|
|
11
|
+
export { setCachedRequestLocale as unstable_setRequestLocale } from './RequestLocaleCache';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export declare const COOKIE_LOCALE_NAME = "NEXT_LOCALE";
|
|
2
|
-
export declare const COOKIE_MAX_AGE = 31536000;
|
|
3
|
-
export declare const COOKIE_SAME_SITE = "lax";
|
|
4
1
|
export declare const COOKIE_BASE_PATH_NAME = "NEXT_INTL_BASE_PATH";
|
|
5
2
|
export declare const HEADER_LOCALE_NAME = "X-NEXT-INTL-LOCALE";
|
|
6
3
|
export declare const LOCALE_SEGMENT_NAME = "locale";
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export type ParametersExceptFirst<Fn> = Fn extends (arg0: any, ...rest: infer R) => any ? R : never;
|
|
2
2
|
export type ParametersExceptFirstTwo<Fn> = Fn extends (arg0: any, arg1: any, ...rest: infer R) => any ? R : never;
|
|
3
|
+
export type Prettify<Type> = {
|
|
4
|
+
[Key in keyof Type]: Type[Key];
|
|
5
|
+
} & {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UrlObject } from 'url';
|
|
2
2
|
import NextLink from 'next/link';
|
|
3
3
|
import { ComponentProps } from 'react';
|
|
4
|
-
import { Locales, LocalePrefixConfigVerbose } from '../routing/types';
|
|
4
|
+
import { Locales, LocalePrefixConfigVerbose, LocalePrefixMode } from '../routing/types';
|
|
5
5
|
type Href = ComponentProps<typeof NextLink>['href'];
|
|
6
6
|
export declare function isLocalizableHref(href: Href): boolean;
|
|
7
7
|
export declare function localizeHref(href: string, locale: string, curLocale: string, curPathname: string, prefix: string): string;
|
|
@@ -17,7 +17,7 @@ export declare function matchesPathname(
|
|
|
17
17
|
template: string,
|
|
18
18
|
/** E.g. `/users/23-jane` */
|
|
19
19
|
pathname: string): boolean;
|
|
20
|
-
export declare function getLocalePrefix<AppLocales extends Locales>(locale: AppLocales[number], localePrefix: LocalePrefixConfigVerbose<AppLocales>): string;
|
|
20
|
+
export declare function getLocalePrefix<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(locale: AppLocales[number], localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>): string;
|
|
21
21
|
export declare function templateToRegex(template: string): RegExp;
|
|
22
22
|
export declare function getSortedPathnames(pathnames: Array<string>): string[];
|
|
23
23
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.21.
|
|
3
|
+
"version": "3.21.2-canary.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -87,11 +87,11 @@
|
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
89
89
|
"negotiator": "^0.6.3",
|
|
90
|
-
"use-intl": "^3.21.
|
|
90
|
+
"use-intl": "^3.21.2-canary.0"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
94
94
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "55bb437395fc4d6d3886fdd7c058b843022630b8"
|
|
97
97
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type MiddlewareOptions = {
|
|
2
|
-
/** 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 */
|
|
3
|
-
alternateLinks?: boolean;
|
|
4
|
-
/** By setting this to `false`, the cookie as well as the `accept-language` header will no longer be used for locale detection. */
|
|
5
|
-
localeDetection?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export type ResolvedMiddlewareOptions = Required<MiddlewareOptions>;
|