next-intl 3.21.0-canary.0 → 3.21.1
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 +6 -6
- package/dist/development/middleware/resolveLocale.js +7 -2
- package/dist/development/navigation/react-client/ClientLink.js +2 -2
- package/dist/development/navigation/react-client/useBasePathname.js +14 -0
- package/dist/development/navigation/react-server/ServerLink.js +2 -4
- package/dist/development/navigation/react-server/createLocalizedPathnamesNavigation.js +4 -4
- package/dist/development/navigation/react-server/redirects.js +2 -2
- package/dist/development/navigation/shared/BaseLink.js +25 -28
- package/dist/development/navigation/shared/redirects.js +0 -3
- package/dist/development/navigation/shared/utils.js +1 -40
- package/dist/development/navigation.react-client.js +0 -2
- package/dist/development/navigation.react-server.js +0 -2
- package/dist/development/react-client/index.js +2 -0
- package/dist/development/routing/config.js +1 -1
- package/dist/development/server/react-server/RequestLocale.js +25 -15
- package/dist/development/server/react-server/getConfig.js +17 -15
- package/dist/development/server/react-server/getRequestConfig.js +1 -1
- package/dist/development/server.react-server.js +2 -2
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/resolveLocale.js +1 -1
- package/dist/esm/navigation/react-client/ClientLink.js +1 -1
- package/dist/esm/navigation/react-client/useBasePathname.js +1 -0
- 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/redirects.js +1 -1
- package/dist/esm/navigation/shared/BaseLink.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/getConfig.js +1 -1
- package/dist/esm/server.react-server.js +1 -1
- package/dist/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/resolveLocale.js +1 -1
- package/dist/production/navigation/react-client/ClientLink.js +1 -1
- package/dist/production/navigation/react-client/useBasePathname.js +1 -0
- 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/redirects.js +1 -1
- package/dist/production/navigation/shared/BaseLink.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/getConfig.js +1 -1
- package/dist/production/server.react-server.js +1 -1
- package/dist/types/src/middleware/getAlternateLinksHeaderValue.d.ts +3 -3
- package/dist/types/src/middleware/middleware.d.ts +2 -2
- package/dist/types/src/middleware/resolveLocale.d.ts +2 -2
- package/dist/types/src/middleware/utils.d.ts +4 -4
- package/dist/types/src/navigation/react-client/ClientLink.d.ts +6 -6
- package/dist/types/src/navigation/react-client/createLocalizedPathnamesNavigation.d.ts +4 -12
- package/dist/types/src/navigation/react-client/createSharedPathnamesNavigation.d.ts +4 -4
- package/dist/types/src/navigation/react-client/index.d.ts +0 -1
- package/dist/types/src/navigation/react-client/redirects.d.ts +4 -4
- package/dist/types/src/navigation/react-client/useBasePathname.d.ts +15 -2
- package/dist/types/src/navigation/react-client/useBaseRouter.d.ts +2 -2
- package/dist/types/src/navigation/react-server/ServerLink.d.ts +5 -5
- package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +4 -12
- package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +3 -3
- package/dist/types/src/navigation/react-server/index.d.ts +0 -1
- package/dist/types/src/navigation/react-server/redirects.d.ts +4 -4
- package/dist/types/src/navigation/shared/BaseLink.d.ts +6 -11
- package/dist/types/src/navigation/shared/redirects.d.ts +5 -5
- package/dist/types/src/navigation/shared/utils.d.ts +3 -10
- package/dist/types/src/react-server/getTranslator.d.ts +9 -0
- package/dist/types/src/routing/config.d.ts +11 -19
- 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 +2 -1
- package/dist/types/src/server/react-server/createRequestConfig.d.ts +3 -2
- package/dist/types/src/server/react-server/getRequestConfig.d.ts +6 -32
- package/dist/types/src/server/react-server/getTranslations.d.ts +9 -0
- package/dist/types/src/server/react-server/index.d.ts +1 -1
- package/dist/types/src/shared/types.d.ts +0 -3
- package/dist/types/src/shared/utils.d.ts +2 -2
- package/package.json +3 -3
- package/dist/development/navigation/react-client/createNavigation.js +0 -83
- package/dist/development/navigation/react-server/createNavigation.js +0 -30
- package/dist/development/navigation/shared/LegacyBaseLink.js +0 -55
- package/dist/development/navigation/shared/createSharedNavigationFns.js +0 -147
- package/dist/development/server/react-server/RequestLocaleCache.js +0 -23
- package/dist/development/server/react-server/RequestLocaleLegacy.js +0 -43
- package/dist/esm/navigation/react-client/createNavigation.js +0 -1
- package/dist/esm/navigation/react-server/createNavigation.js +0 -1
- package/dist/esm/navigation/shared/LegacyBaseLink.js +0 -2
- package/dist/esm/navigation/shared/createSharedNavigationFns.js +0 -1
- package/dist/esm/server/react-server/RequestLocaleCache.js +0 -1
- package/dist/esm/server/react-server/RequestLocaleLegacy.js +0 -1
- package/dist/production/navigation/react-client/createNavigation.js +0 -1
- package/dist/production/navigation/react-server/createNavigation.js +0 -1
- package/dist/production/navigation/shared/LegacyBaseLink.js +0 -2
- package/dist/production/navigation/shared/createSharedNavigationFns.js +0 -1
- package/dist/production/server/react-server/RequestLocaleCache.js +0 -1
- package/dist/production/server/react-server/RequestLocaleLegacy.js +0 -1
- package/dist/types/src/navigation/createNavigation.test.d.ts +0 -1
- package/dist/types/src/navigation/react-client/createNavigation.d.ts +0 -467
- package/dist/types/src/navigation/react-client/createNavigation.test.d.ts +0 -1
- package/dist/types/src/navigation/react-server/createNavigation.d.ts +0 -385
- package/dist/types/src/navigation/react-server/createNavigation.test.d.ts +0 -1
- package/dist/types/src/navigation/shared/LegacyBaseLink.d.ts +0 -10
- package/dist/types/src/navigation/shared/createSharedNavigationFns.d.ts +0 -382
- package/dist/types/src/server/react-server/RequestLocaleCache.d.ts +0 -2
- package/dist/types/src/server/react-server/RequestLocaleLegacy.d.ts +0 -1
|
@@ -55,7 +55,7 @@ function createMiddleware(routing, options) {
|
|
|
55
55
|
}
|
|
56
56
|
function redirect(url, redirectDomain) {
|
|
57
57
|
const urlObj = new URL(utils$1.normalizeTrailingSlash(url), request.url);
|
|
58
|
-
if (domainsConfig.length > 0 && !redirectDomain
|
|
58
|
+
if (domainsConfig.length > 0 && !redirectDomain) {
|
|
59
59
|
const bestMatchingDomain = utils.getBestMatchingDomain(domain, locale, domainsConfig);
|
|
60
60
|
if (bestMatchingDomain) {
|
|
61
61
|
redirectDomain = bestMatchingDomain.domain;
|
|
@@ -84,12 +84,11 @@ function createMiddleware(routing, options) {
|
|
|
84
84
|
let response;
|
|
85
85
|
let internalTemplateName;
|
|
86
86
|
let unprefixedInternalPathname = unprefixedExternalPathname;
|
|
87
|
-
|
|
88
|
-
if (pathnames) {
|
|
87
|
+
if ('pathnames' in resolvedRouting) {
|
|
89
88
|
let resolvedTemplateLocale;
|
|
90
|
-
[resolvedTemplateLocale, internalTemplateName] = utils.getInternalTemplate(pathnames, unprefixedExternalPathname, locale);
|
|
89
|
+
[resolvedTemplateLocale, internalTemplateName] = utils.getInternalTemplate(resolvedRouting.pathnames, unprefixedExternalPathname, locale);
|
|
91
90
|
if (internalTemplateName) {
|
|
92
|
-
const pathnameConfig = pathnames[internalTemplateName];
|
|
91
|
+
const pathnameConfig = resolvedRouting.pathnames[internalTemplateName];
|
|
93
92
|
const localeTemplate = typeof pathnameConfig === 'string' ? pathnameConfig :
|
|
94
93
|
// @ts-expect-error -- This is fine
|
|
95
94
|
pathnameConfig[locale];
|
|
@@ -157,9 +156,10 @@ function createMiddleware(routing, options) {
|
|
|
157
156
|
syncCookie.default(request, response, locale);
|
|
158
157
|
}
|
|
159
158
|
if (resolvedRouting.localePrefix.mode !== 'never' && resolvedOptions.alternateLinks && resolvedRouting.locales.length > 1) {
|
|
159
|
+
var _resolvedRouting$path;
|
|
160
160
|
response.headers.set('Link', getAlternateLinksHeaderValue.default({
|
|
161
161
|
routing: resolvedRouting,
|
|
162
|
-
localizedPathnames: internalTemplateName != null && pathnames ? pathnames === null ||
|
|
162
|
+
localizedPathnames: internalTemplateName != null && 'pathnames' in resolvedRouting ? (_resolvedRouting$path = resolvedRouting.pathnames) === null || _resolvedRouting$path === void 0 ? void 0 : _resolvedRouting$path[internalTemplateName] : undefined,
|
|
163
163
|
request,
|
|
164
164
|
resolvedLocale: locale
|
|
165
165
|
}));
|
|
@@ -12,7 +12,11 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
12
12
|
var Negotiator__default = /*#__PURE__*/_interopDefault(Negotiator);
|
|
13
13
|
|
|
14
14
|
function findDomainFromHost(requestHeaders, domains) {
|
|
15
|
-
|
|
15
|
+
var _host;
|
|
16
|
+
let host = utils.getHost(requestHeaders);
|
|
17
|
+
|
|
18
|
+
// Remove port (easier for local development)
|
|
19
|
+
host = (_host = host) === null || _host === void 0 ? void 0 : _host.replace(/:\d+$/, '');
|
|
16
20
|
if (host && domains) {
|
|
17
21
|
return domains.find(cur => cur.domain === host);
|
|
18
22
|
}
|
|
@@ -135,7 +139,8 @@ function resolveLocaleFromDomain(routing, options, requestHeaders, requestCookie
|
|
|
135
139
|
}
|
|
136
140
|
function resolveLocale(routing, options, requestHeaders, requestCookies, pathname) {
|
|
137
141
|
if (routing.domains) {
|
|
138
|
-
|
|
142
|
+
const routingWithDomains = routing;
|
|
143
|
+
return resolveLocaleFromDomain(routingWithDomains, options, requestHeaders, requestCookies, pathname);
|
|
139
144
|
} else {
|
|
140
145
|
return {
|
|
141
146
|
locale: resolveLocaleFromPrefix(routing, options, requestHeaders, requestCookies, pathname)
|
|
@@ -6,7 +6,7 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var useLocale = require('../../react-client/useLocale.js');
|
|
8
8
|
var utils = require('../../shared/utils.js');
|
|
9
|
-
var
|
|
9
|
+
var BaseLink = require('../shared/BaseLink.js');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
@@ -21,7 +21,7 @@ function ClientLink(_ref, ref) {
|
|
|
21
21
|
const defaultLocale = useLocale.default();
|
|
22
22
|
const finalLocale = locale || defaultLocale;
|
|
23
23
|
const prefix = utils.getLocalePrefix(finalLocale, localePrefix);
|
|
24
|
-
return /*#__PURE__*/React__default.default.createElement(
|
|
24
|
+
return /*#__PURE__*/React__default.default.createElement(BaseLink.default, _rollupPluginBabelHelpers.extends({
|
|
25
25
|
ref: ref,
|
|
26
26
|
locale: finalLocale,
|
|
27
27
|
localePrefixMode: localePrefix.mode,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -7,6 +8,19 @@ var React = require('react');
|
|
|
7
8
|
var useLocale = require('../../react-client/useLocale.js');
|
|
8
9
|
var utils = require('../../shared/utils.js');
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Returns the pathname without a potential locale prefix.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* 'use client';
|
|
17
|
+
*
|
|
18
|
+
* import {usePathname} from 'next-intl/client';
|
|
19
|
+
*
|
|
20
|
+
* // When the user is on `/en`, this will be `/`
|
|
21
|
+
* const pathname = usePathname();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
10
24
|
function useBasePathname(localePrefix) {
|
|
11
25
|
// The types aren't entirely correct here. Outside of Next.js
|
|
12
26
|
// `useParams` can be called, but the return type is `null`.
|
|
@@ -5,15 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var utils = require('../../shared/utils.js');
|
|
8
|
-
var
|
|
8
|
+
var BaseLink = require('../shared/BaseLink.js');
|
|
9
9
|
var getLocale = require('../../server/react-server/getLocale.js');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
13
13
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
14
14
|
|
|
15
|
-
// Only used by legacy navigation APIs, can be removed when they are removed
|
|
16
|
-
|
|
17
15
|
async function ServerLink(_ref) {
|
|
18
16
|
let {
|
|
19
17
|
locale,
|
|
@@ -22,7 +20,7 @@ async function ServerLink(_ref) {
|
|
|
22
20
|
} = _ref;
|
|
23
21
|
const finalLocale = locale || (await getLocale.default());
|
|
24
22
|
const prefix = utils.getLocalePrefix(finalLocale, localePrefix);
|
|
25
|
-
return /*#__PURE__*/React__default.default.createElement(
|
|
23
|
+
return /*#__PURE__*/React__default.default.createElement(BaseLink.default, _rollupPluginBabelHelpers.extends({
|
|
26
24
|
locale: finalLocale,
|
|
27
25
|
localePrefixMode: localePrefix.mode,
|
|
28
26
|
prefix: prefix
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var config = require('../../routing/config.js');
|
|
8
|
-
var
|
|
8
|
+
var RequestLocale = require('../../server/react-server/RequestLocale.js');
|
|
9
9
|
var utils = require('../shared/utils.js');
|
|
10
10
|
var ServerLink = require('./ServerLink.js');
|
|
11
11
|
var redirects = require('./redirects.js');
|
|
@@ -22,7 +22,7 @@ function createLocalizedPathnamesNavigation(routing) {
|
|
|
22
22
|
locale,
|
|
23
23
|
...rest
|
|
24
24
|
} = _ref;
|
|
25
|
-
const defaultLocale =
|
|
25
|
+
const defaultLocale = RequestLocale.getRequestLocale();
|
|
26
26
|
const finalLocale = locale || defaultLocale;
|
|
27
27
|
return /*#__PURE__*/React__default.default.createElement(ServerLink.default, _rollupPluginBabelHelpers.extends({
|
|
28
28
|
href: utils.compileLocalizedPathname({
|
|
@@ -38,7 +38,7 @@ function createLocalizedPathnamesNavigation(routing) {
|
|
|
38
38
|
}, rest));
|
|
39
39
|
}
|
|
40
40
|
function redirect(href) {
|
|
41
|
-
const locale =
|
|
41
|
+
const locale = RequestLocale.getRequestLocale();
|
|
42
42
|
const pathname = getPathname({
|
|
43
43
|
href,
|
|
44
44
|
locale
|
|
@@ -52,7 +52,7 @@ function createLocalizedPathnamesNavigation(routing) {
|
|
|
52
52
|
}, ...args);
|
|
53
53
|
}
|
|
54
54
|
function permanentRedirect(href) {
|
|
55
|
-
const locale =
|
|
55
|
+
const locale = RequestLocale.getRequestLocale();
|
|
56
56
|
const pathname = getPathname({
|
|
57
57
|
href,
|
|
58
58
|
locale
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var RequestLocale = require('../../server/react-server/RequestLocale.js');
|
|
6
6
|
var redirects = require('../shared/redirects.js');
|
|
7
7
|
|
|
8
8
|
function createRedirectFn(redirectFn) {
|
|
9
9
|
return function serverRedirect(params) {
|
|
10
|
-
const locale =
|
|
10
|
+
const locale = RequestLocale.getRequestLocale();
|
|
11
11
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
12
12
|
args[_key - 1] = arguments[_key];
|
|
13
13
|
}
|
|
@@ -8,6 +8,7 @@ var NextLink = require('next/link');
|
|
|
8
8
|
var navigation = require('next/navigation');
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var useLocale = require('../../react-client/useLocale.js');
|
|
11
|
+
var utils = require('../../shared/utils.js');
|
|
11
12
|
var syncLocaleCookie = require('./syncLocaleCookie.js');
|
|
12
13
|
|
|
13
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -17,37 +18,39 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
17
18
|
|
|
18
19
|
function BaseLink(_ref, ref) {
|
|
19
20
|
let {
|
|
20
|
-
defaultLocale,
|
|
21
21
|
href,
|
|
22
22
|
locale,
|
|
23
|
+
localePrefixMode,
|
|
23
24
|
onClick,
|
|
24
25
|
prefetch,
|
|
25
|
-
|
|
26
|
+
prefix,
|
|
26
27
|
...rest
|
|
27
28
|
} = _ref;
|
|
28
|
-
const curLocale = useLocale.default();
|
|
29
|
-
const isChangingLocale = locale !== curLocale;
|
|
30
|
-
const linkLocale = locale || curLocale;
|
|
31
|
-
const host = useHost();
|
|
32
|
-
const finalHref =
|
|
33
|
-
// Only after hydration (to avoid mismatches)
|
|
34
|
-
host &&
|
|
35
|
-
// If there is an `unprefixed` prop, the
|
|
36
|
-
// `defaultLocale` might differ by domain
|
|
37
|
-
unprefixed && (
|
|
38
|
-
// Unprefix the pathname if a domain matches
|
|
39
|
-
unprefixed.domains[host] === linkLocale ||
|
|
40
|
-
// … and handle unknown domains by applying the
|
|
41
|
-
// global `defaultLocale` (e.g. on localhost)
|
|
42
|
-
!Object.keys(unprefixed.domains).includes(host) && curLocale === defaultLocale && !locale) ? unprefixed.pathname : href;
|
|
43
|
-
|
|
44
29
|
// The types aren't entirely correct here. Outside of Next.js
|
|
45
30
|
// `useParams` can be called, but the return type is `null`.
|
|
46
31
|
const pathname = navigation.usePathname();
|
|
32
|
+
const curLocale = useLocale.default();
|
|
33
|
+
const isChangingLocale = locale !== curLocale;
|
|
34
|
+
const [localizedHref, setLocalizedHref] = React.useState(() => utils.isLocalizableHref(href) && (localePrefixMode !== 'never' || isChangingLocale) ?
|
|
35
|
+
// For the `localePrefix: 'as-needed' strategy, the href shouldn't
|
|
36
|
+
// be prefixed if the locale is the default locale. To determine this, we
|
|
37
|
+
// need a) the default locale and b) the information if we use prefixed
|
|
38
|
+
// routing. The default locale can vary by domain, therefore during the
|
|
39
|
+
// RSC as well as the SSR render, we can't determine the default locale
|
|
40
|
+
// statically. Therefore we always prefix the href since this will
|
|
41
|
+
// always result in a valid URL, even if it might cause a redirect. This
|
|
42
|
+
// is better than pointing to a non-localized href during the server
|
|
43
|
+
// render, which would potentially be wrong. The final href is
|
|
44
|
+
// determined in the effect below.
|
|
45
|
+
utils.prefixHref(href, prefix) : href);
|
|
47
46
|
function onLinkClick(event) {
|
|
48
47
|
syncLocaleCookie.default(pathname, curLocale, locale);
|
|
49
48
|
if (onClick) onClick(event);
|
|
50
49
|
}
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
if (!pathname) return;
|
|
52
|
+
setLocalizedHref(utils.localizeHref(href, locale, curLocale, pathname, prefix));
|
|
53
|
+
}, [curLocale, href, locale, pathname, prefix]);
|
|
51
54
|
if (isChangingLocale) {
|
|
52
55
|
if (prefetch && "development" !== 'production') {
|
|
53
56
|
console.error('The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`');
|
|
@@ -56,19 +59,13 @@ function BaseLink(_ref, ref) {
|
|
|
56
59
|
}
|
|
57
60
|
return /*#__PURE__*/React__default.default.createElement(NextLink__default.default, _rollupPluginBabelHelpers.extends({
|
|
58
61
|
ref: ref,
|
|
59
|
-
href:
|
|
62
|
+
href: localizedHref,
|
|
60
63
|
hrefLang: isChangingLocale ? locale : undefined,
|
|
61
64
|
onClick: onLinkClick,
|
|
62
65
|
prefetch: prefetch
|
|
63
66
|
}, rest));
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
React.useEffect(() => {
|
|
68
|
-
setHost(window.location.host);
|
|
69
|
-
}, []);
|
|
70
|
-
return host;
|
|
71
|
-
}
|
|
72
|
-
var BaseLink$1 = /*#__PURE__*/React.forwardRef(BaseLink);
|
|
68
|
+
const BaseLinkWithRef = /*#__PURE__*/React.forwardRef(BaseLink);
|
|
69
|
+
BaseLinkWithRef.displayName = 'ClientLink';
|
|
73
70
|
|
|
74
|
-
exports.default =
|
|
71
|
+
exports.default = BaseLinkWithRef;
|
|
@@ -8,9 +8,6 @@ var utils = require('../../shared/utils.js');
|
|
|
8
8
|
function createRedirectFn(redirectFn) {
|
|
9
9
|
return function baseRedirect(params) {
|
|
10
10
|
const prefix = utils.getLocalePrefix(params.locale, params.localePrefix);
|
|
11
|
-
|
|
12
|
-
// This logic is considered legacy and is replaced by `applyPathnamePrefix`.
|
|
13
|
-
// We keep it this way for now for backwards compatibility.
|
|
14
11
|
const localizedPathname = params.localePrefix.mode === 'never' || !utils.isLocalizableHref(params.pathname) ? params.pathname : utils.prefixPathname(prefix, params.pathname);
|
|
15
12
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
16
13
|
args[_key - 1] = arguments[_key];
|
|
@@ -7,11 +7,8 @@ var utils = require('../../shared/utils.js');
|
|
|
7
7
|
// Minor false positive: A route that has both optional and
|
|
8
8
|
// required params will allow optional params.
|
|
9
9
|
|
|
10
|
-
// For `Link`
|
|
11
|
-
|
|
12
|
-
// For `getPathname` (hence also its consumers: `redirect`, `useRouter`, …)
|
|
13
|
-
|
|
14
10
|
function normalizeNameOrNameWithParams(href) {
|
|
11
|
+
// @ts-expect-error -- `extends string` in the generic unfortunately weakens the type
|
|
15
12
|
return typeof href === 'string' ? {
|
|
16
13
|
pathname: href
|
|
17
14
|
} : href;
|
|
@@ -43,7 +40,6 @@ function compileLocalizedPathname(_ref) {
|
|
|
43
40
|
function getNamedPath(value) {
|
|
44
41
|
let namedPath = pathnames[value];
|
|
45
42
|
if (!namedPath) {
|
|
46
|
-
// Unknown pathnames
|
|
47
43
|
namedPath = value;
|
|
48
44
|
}
|
|
49
45
|
return namedPath;
|
|
@@ -122,44 +118,9 @@ function getBasePath(pathname) {
|
|
|
122
118
|
return windowPathname.replace(pathname, '');
|
|
123
119
|
}
|
|
124
120
|
}
|
|
125
|
-
function applyPathnamePrefix(pathname, locale, routing, domain, force) {
|
|
126
|
-
const {
|
|
127
|
-
mode
|
|
128
|
-
} = routing.localePrefix;
|
|
129
|
-
let shouldPrefix;
|
|
130
|
-
if (force !== undefined) {
|
|
131
|
-
shouldPrefix = force;
|
|
132
|
-
} else if (utils.isLocalizableHref(pathname)) {
|
|
133
|
-
if (mode === 'always') {
|
|
134
|
-
shouldPrefix = true;
|
|
135
|
-
} else if (mode === 'as-needed') {
|
|
136
|
-
let defaultLocale = routing.defaultLocale;
|
|
137
|
-
if (routing.domains) {
|
|
138
|
-
const domainConfig = routing.domains.find(cur => cur.domain === domain);
|
|
139
|
-
if (domainConfig) {
|
|
140
|
-
defaultLocale = domainConfig.defaultLocale;
|
|
141
|
-
} else {
|
|
142
|
-
if (!domain) {
|
|
143
|
-
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-docs.vercel.app/docs/routing#domains-localeprefix-asneeded");
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
shouldPrefix = defaultLocale !== locale;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return shouldPrefix ? utils.prefixPathname(utils.getLocalePrefix(locale, routing.localePrefix), pathname) : pathname;
|
|
151
|
-
}
|
|
152
|
-
function validateReceivedConfig(config) {
|
|
153
|
-
var _config$localePrefix;
|
|
154
|
-
if (((_config$localePrefix = config.localePrefix) === null || _config$localePrefix === void 0 ? void 0 : _config$localePrefix.mode) === 'as-needed' && !('defaultLocale' in config)) {
|
|
155
|
-
throw new Error("`localePrefix: 'as-needed' requires a `defaultLocale`.");
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
121
|
|
|
159
|
-
exports.applyPathnamePrefix = applyPathnamePrefix;
|
|
160
122
|
exports.compileLocalizedPathname = compileLocalizedPathname;
|
|
161
123
|
exports.getBasePath = getBasePath;
|
|
162
124
|
exports.getRoute = getRoute;
|
|
163
125
|
exports.normalizeNameOrNameWithParams = normalizeNameOrNameWithParams;
|
|
164
126
|
exports.serializeSearchParams = serializeSearchParams;
|
|
165
|
-
exports.validateReceivedConfig = validateReceivedConfig;
|
|
@@ -4,10 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var createSharedPathnamesNavigation = require('./navigation/react-client/createSharedPathnamesNavigation.js');
|
|
6
6
|
var createLocalizedPathnamesNavigation = require('./navigation/react-client/createLocalizedPathnamesNavigation.js');
|
|
7
|
-
var createNavigation = require('./navigation/react-client/createNavigation.js');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
exports.createSharedPathnamesNavigation = createSharedPathnamesNavigation.default;
|
|
12
11
|
exports.createLocalizedPathnamesNavigation = createLocalizedPathnamesNavigation.default;
|
|
13
|
-
exports.createNavigation = createNavigation.default;
|
|
@@ -4,10 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var createSharedPathnamesNavigation = require('./navigation/react-server/createSharedPathnamesNavigation.js');
|
|
6
6
|
var createLocalizedPathnamesNavigation = require('./navigation/react-server/createLocalizedPathnamesNavigation.js');
|
|
7
|
-
var createNavigation = require('./navigation/react-server/createNavigation.js');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
exports.createSharedPathnamesNavigation = createSharedPathnamesNavigation.default;
|
|
12
11
|
exports.createLocalizedPathnamesNavigation = createLocalizedPathnamesNavigation.default;
|
|
13
|
-
exports.createNavigation = createNavigation.default;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function receiveRoutingConfig(input) {
|
|
6
6
|
return {
|
|
7
7
|
...input,
|
|
8
|
-
localePrefix: receiveLocalePrefixConfig(input
|
|
8
|
+
localePrefix: receiveLocalePrefixConfig(input.localePrefix)
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
function receiveLocalePrefixConfig(localePrefix) {
|
|
@@ -3,37 +3,47 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var headers = require('next/headers');
|
|
6
|
+
var navigation = require('next/navigation');
|
|
6
7
|
var React = require('react');
|
|
7
8
|
var constants = require('../../shared/constants.js');
|
|
8
|
-
var RequestLocaleCache = require('./RequestLocaleCache.js');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const promiseOrValue = headers.headers();
|
|
12
|
-
|
|
13
|
-
// Compatibility with Next.js <15
|
|
14
|
-
return promiseOrValue instanceof Promise ? await promiseOrValue : promiseOrValue;
|
|
15
|
-
}
|
|
16
|
-
const getHeaders = React.cache(getHeadersImpl);
|
|
17
|
-
async function getLocaleFromHeaderImpl() {
|
|
10
|
+
function getLocaleFromHeaderImpl() {
|
|
18
11
|
let locale;
|
|
19
12
|
try {
|
|
20
|
-
locale = (
|
|
13
|
+
locale = headers.headers().get(constants.HEADER_LOCALE_NAME);
|
|
21
14
|
} catch (error) {
|
|
22
15
|
if (error instanceof Error && error.digest === 'DYNAMIC_SERVER_USAGE') {
|
|
23
|
-
|
|
16
|
+
throw 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 `unstable_setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering', {
|
|
24
17
|
cause: error
|
|
25
18
|
});
|
|
26
|
-
wrappedError.digest = error.digest;
|
|
27
|
-
throw wrappedError;
|
|
28
19
|
} else {
|
|
29
20
|
throw error;
|
|
30
21
|
}
|
|
31
22
|
}
|
|
23
|
+
if (!locale) {
|
|
24
|
+
{
|
|
25
|
+
console.error("\nUnable to find `next-intl` locale because the middleware didn't run on this request. See https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.\n");
|
|
26
|
+
}
|
|
27
|
+
navigation.notFound();
|
|
28
|
+
}
|
|
32
29
|
return locale;
|
|
33
30
|
}
|
|
34
31
|
const getLocaleFromHeader = React.cache(getLocaleFromHeaderImpl);
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
|
|
33
|
+
// Workaround until `createServerContext` is available
|
|
34
|
+
function getCacheImpl() {
|
|
35
|
+
const value = {
|
|
36
|
+
locale: undefined
|
|
37
|
+
};
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
const getCache = React.cache(getCacheImpl);
|
|
41
|
+
function setRequestLocale(locale) {
|
|
42
|
+
getCache().locale = locale;
|
|
43
|
+
}
|
|
44
|
+
function getRequestLocale() {
|
|
45
|
+
return getCache().locale || getLocaleFromHeader();
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
exports.getRequestLocale = getRequestLocale;
|
|
49
|
+
exports.setRequestLocale = setRequestLocale;
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var navigation = require('next/navigation');
|
|
6
5
|
var React = require('react');
|
|
7
6
|
var core = require('use-intl/core');
|
|
8
7
|
var RequestLocale = require('./RequestLocale.js');
|
|
9
|
-
var RequestLocaleLegacy = require('./RequestLocaleLegacy.js');
|
|
10
8
|
var getRuntimeConfig = require('next-intl/config');
|
|
11
9
|
|
|
12
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -29,31 +27,35 @@ async function receiveRuntimeConfigImpl(getConfig, localeOverride) {
|
|
|
29
27
|
if (typeof getConfig !== 'function') {
|
|
30
28
|
throw new Error("Invalid i18n request configuration detected.\n\nPlease verify that:\n1. In case you've specified a custom location in your Next.js config, make sure that the path is correct.\n2. You have a default export in your i18n request configuration file.\n\nSee also: https://next-intl-docs.vercel.app/docs/usage/configuration#i18n-request\n");
|
|
31
29
|
}
|
|
30
|
+
let hasReadLocale = false;
|
|
31
|
+
|
|
32
|
+
// In case the consumer doesn't read `params.locale` and instead provides the
|
|
33
|
+
// `locale` (either in a single-language workflow or because the locale is
|
|
34
|
+
// read from the user settings), don't attempt to read the request locale.
|
|
32
35
|
const params = {
|
|
33
|
-
// In case the consumer doesn't read `params.locale` and instead provides the
|
|
34
|
-
// `locale` (either in a single-language workflow or because the locale is
|
|
35
|
-
// read from the user settings), don't attempt to read the request locale.
|
|
36
36
|
get locale() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
get requestLocale() {
|
|
40
|
-
return localeOverride ? Promise.resolve(localeOverride) : RequestLocale.getRequestLocale();
|
|
37
|
+
hasReadLocale = true;
|
|
38
|
+
return localeOverride || RequestLocale.getRequestLocale();
|
|
41
39
|
}
|
|
42
40
|
};
|
|
43
41
|
let result = getConfig(params);
|
|
44
42
|
if (result instanceof Promise) {
|
|
45
43
|
result = await result;
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
{
|
|
46
|
+
if (hasReadLocale) {
|
|
47
|
+
if (result.locale) {
|
|
48
|
+
console.error("\nYou've read the `locale` param that was passed to `getRequestConfig` but have also returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n");
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
if (!result.locale) {
|
|
52
|
+
console.error("\nYou haven't read the `locale` param that was passed to `getRequestConfig` and also haven't returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n");
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
|
-
navigation.notFound();
|
|
53
55
|
}
|
|
54
56
|
return {
|
|
55
57
|
...result,
|
|
56
|
-
locale,
|
|
58
|
+
locale: result.locale || params.locale,
|
|
57
59
|
now: result.now || getDefaultNow(),
|
|
58
60
|
timeZone: result.timeZone || getDefaultTimeZone()
|
|
59
61
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Should be called in `i18n
|
|
6
|
+
* Should be called in `i18n.ts` to create the configuration for the current request.
|
|
7
7
|
*/
|
|
8
8
|
function getRequestConfig(createRequestConfig) {
|
|
9
9
|
return createRequestConfig;
|
|
@@ -9,7 +9,7 @@ var getNow = require('./server/react-server/getNow.js');
|
|
|
9
9
|
var getTimeZone = require('./server/react-server/getTimeZone.js');
|
|
10
10
|
var getTranslations = require('./server/react-server/getTranslations.js');
|
|
11
11
|
var getLocale = require('./server/react-server/getLocale.js');
|
|
12
|
-
var
|
|
12
|
+
var RequestLocale = require('./server/react-server/RequestLocale.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
@@ -20,4 +20,4 @@ exports.getNow = getNow.default;
|
|
|
20
20
|
exports.getTimeZone = getTimeZone.default;
|
|
21
21
|
exports.getTranslations = getTranslations.default;
|
|
22
22
|
exports.getLocale = getLocale.default;
|
|
23
|
-
exports.unstable_setRequestLocale =
|
|
23
|
+
exports.unstable_setRequestLocale = RequestLocale.setRequestLocale;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as e}from"next/server";import{receiveRoutingConfig as l}from"../routing/config.js";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as t,normalizeTrailingSlash as
|
|
1
|
+
import{NextResponse as e}from"next/server";import{receiveRoutingConfig as l}from"../routing/config.js";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as t,normalizeTrailingSlash as a,getLocalePrefix as n}from"../shared/utils.js";import r from"./getAlternateLinksHeaderValue.js";import i from"./resolveLocale.js";import s from"./syncCookie.js";import{sanitizePathname as c,isLocaleSupportedOnDomain as d,getNormalizedPathname as f,getPathnameMatch as m,getInternalTemplate as h,formatTemplatePathname as u,formatPathname as x,getBestMatchingDomain as v,applyBasePath as p,getLocaleAsPrefix as U}from"./utils.js";function P(P,L){var g,k,j,w;const b=l(P),y={alternateLinks:null===(g=null!==(k=null==L?void 0:L.alternateLinks)&&void 0!==k?k:P.alternateLinks)||void 0===g||g,localeDetection:null===(j=null!==(w=null==L?void 0:L.localeDetection)&&void 0!==w?w:null==P?void 0:P.localeDetection)||void 0===j||j};return function(l){var P;let L;try{L=decodeURI(l.nextUrl.pathname)}catch(l){return e.next()}const g=c(L),{domain:k,locale:j}=i(b,y,l.headers,l.cookies,g),w=k?k.defaultLocale===j:j===b.defaultLocale,D=(null===(P=b.domains)||void 0===P?void 0:P.filter((e=>d(j,e))))||[],R=null!=b.domains&&!k;function q(t){const a=new URL(t,l.url);l.nextUrl.basePath&&(a.pathname=p(a.pathname,l.nextUrl.basePath));const n=new Headers(l.headers);return n.set(o,j),e.rewrite(a,{request:{headers:n}})}function H(o,t){const n=new URL(a(o),l.url);if(D.length>0&&!t){const e=v(k,j,D);e&&(t=e.domain,e.defaultLocale===j&&"as-needed"===b.localePrefix.mode&&(n.pathname=f(n.pathname,b.locales,b.localePrefix)))}var r,i;t&&(n.host=t,l.headers.get("x-forwarded-host")&&(n.protocol=null!==(r=l.headers.get("x-forwarded-proto"))&&void 0!==r?r:l.nextUrl.protocol,n.port=null!==(i=l.headers.get("x-forwarded-port"))&&void 0!==i?i:""));return l.nextUrl.basePath&&(n.pathname=p(n.pathname,l.nextUrl.basePath)),e.redirect(n.toString())}const z=f(g,b.locales,b.localePrefix),A=m(g,b.locales,b.localePrefix),C=null!=A,I="never"===b.localePrefix.mode||w&&"as-needed"===b.localePrefix.mode;let S,V,B=z;if("pathnames"in b){let e;if([e,V]=h(b.pathnames,z,j),V){const o=b.pathnames[V],a="string"==typeof o?o:o[j];if(t(a,z))B=u(z,a,V);else{let t;t=e?"string"==typeof o?o:o[e]:V;const r=I?void 0:n(j,b.localePrefix),i=u(z,t,a);S=H(x(i,r,l.nextUrl.search))}}}if(!S)if("/"!==B||C){const e=x(B,U(j),l.nextUrl.search);if(C){const o=x(z,A.prefix,l.nextUrl.search);if("never"===b.localePrefix.mode)S=H(x(z,void 0,l.nextUrl.search));else if(A.exact)if(w&&I)S=H(x(z,void 0,l.nextUrl.search));else if(b.domains){const l=v(k,A.locale,D);S=(null==k?void 0:k.domain)===(null==l?void 0:l.domain)||R?q(e):H(o,null==l?void 0:l.domain)}else S=q(e);else S=H(o)}else S=I?q(e):H(x(z,n(j,b.localePrefix),l.nextUrl.search))}else S=I?q(x(B,U(j),l.nextUrl.search)):H(x(z,n(j,b.localePrefix),l.nextUrl.search));var E;(y.localeDetection&&s(l,S,j),"never"!==b.localePrefix.mode&&y.alternateLinks&&b.locales.length>1)&&S.headers.set("Link",r({routing:b,localizedPathnames:null!=V&&"pathnames"in b?null===(E=b.pathnames)||void 0===E?void 0:E[V]:void 0,request:l,resolvedLocale:j}));return S}}export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{match as
|
|
1
|
+
import{match as e}from"@formatjs/intl-localematcher";import o from"negotiator";import{COOKIE_LOCALE_NAME as l}from"../shared/constants.js";import{getPathnameMatch as t,isLocaleSupportedOnDomain as n,getHost as a}from"./utils.js";function c(l,t,n){let a;const c=new o({headers:{"accept-language":l.get("accept-language")||void 0}}).languages();try{const o=function(e){return e.slice().sort(((e,o)=>o.length-e.length))}(t);a=e(c,o,n)}catch(e){}return a}function i(e,o){if(e.has(l)){var t;const n=null===(t=e.get(l))||void 0===t?void 0:t.value;if(n&&o.includes(n))return n}}function r(e,o,l,n,a){let r,{defaultLocale:u,localePrefix:f,locales:s}=e,{localeDetection:d}=o;var m;a&&(r=null===(m=t(a,s,f))||void 0===m?void 0:m.locale);return!r&&d&&n&&(r=i(n,s)),!r&&d&&l&&(r=c(l,s,u)),r||(r=u),r}function u(e,o,l,u,f){const s=function(e,o){var l;let t=a(e);if(t=null===(l=t)||void 0===l?void 0:l.replace(/:\d+$/,""),t&&o)return o.find((e=>e.domain===t))}(l,e.domains);if(!s)return{locale:r(e,o,l,u,f)};let d;if(f){var m;const o=null===(m=t(f,e.locales,e.localePrefix))||void 0===m?void 0:m.locale;if(o){if(!n(o,s))return{locale:o,domain:s};d=o}}if(!d&&o.localeDetection&&u){const o=i(u,e.locales);o&&n(o,s)&&(d=o)}if(!d&&o.localeDetection&&l){const o=c(l,s.locales||e.locales,s.defaultLocale);o&&(d=o)}return d||(d=s.defaultLocale),{locale:d,domain:s}}function f(e,o,l,t,n){if(e.domains){return u(e,o,l,t,n)}return{locale:r(e,o,l,t,n)}}export{f as default,c as getAcceptLanguageLocale};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as l}from"react";import o from"../../react-client/useLocale.js";import{getLocalePrefix as t}from"../../shared/utils.js";import a from"../shared/
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as l}from"react";import o from"../../react-client/useLocale.js";import{getLocalePrefix as t}from"../../shared/utils.js";import a from"../shared/BaseLink.js";function i(l,i){let{locale:s,localePrefix:m,...c}=l;const n=o(),f=s||n,p=t(f,m);return r.createElement(a,e({ref:i,locale:f,localePrefixMode:m.mode,prefix:p},c))}const s=l(i);s.displayName="ClientLink";export{s as default};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{usePathname as r}from"next/navigation";import{useMemo as t}from"react";import o from"../../react-client/useLocale.js";import{hasPathnamePrefixed as e,unprefixPathname as n,getLocalePrefix as i}from"../../shared/utils.js";function a(a){const m=r(),s=o();return t((()=>{if(!m)return m;const r=i(s,a);return e(r,m)?n(m,r):m}),[s,a,m])}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{getLocalePrefix as o}from"../../shared/utils.js";import
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{getLocalePrefix as o}from"../../shared/utils.js";import t from"../shared/BaseLink.js";import a from"../../server/react-server/getLocale.js";async function l(l){let{locale:s,localePrefix:i,...m}=l;const c=s||await a(),f=o(c,i);return r.createElement(t,e({locale:c,localePrefixMode:i.mode,prefix:f},m))}export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{receiveRoutingConfig as t}from"../../routing/config.js";import{getRequestLocale as o}from"../../server/react-server/
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{receiveRoutingConfig as t}from"../../routing/config.js";import{getRequestLocale as o}from"../../server/react-server/RequestLocale.js";import{compileLocalizedPathname as n,normalizeNameOrNameWithParams as a}from"../shared/utils.js";import l from"./ServerLink.js";import{serverRedirect as c,serverPermanentRedirect as i}from"./redirects.js";function s(s){const m=t(s);function f(e){let{href:r,locale:t}=e;return n({...a(r),locale:t,pathnames:m.pathnames})}function u(e){return()=>{throw new Error("`".concat(e,"` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."))}}return{Link:function(t){let{href:a,locale:c,...i}=t;const s=o(),f=c||s;return r.createElement(l,e({href:n({locale:f,pathname:a,params:"object"==typeof a?a.params:void 0,pathnames:m.pathnames}),locale:c,localePrefix:m.localePrefix},i))},redirect:function(e){const r=f({href:e,locale:o()});for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return c({localePrefix:m.localePrefix,pathname:r},...n)},permanentRedirect:function(e){const r=f({href:e,locale:o()});for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return i({localePrefix:m.localePrefix,pathname:r},...n)},getPathname:f,usePathname:u("usePathname"),useRouter:u("useRouter")}}export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getRequestLocale as r}from"../../server/react-server/
|
|
1
|
+
import{getRequestLocale as r}from"../../server/react-server/RequestLocale.js";import{baseRedirect as e,basePermanentRedirect as t}from"../shared/redirects.js";function o(e){return function(t){const o=r();for(var n=arguments.length,s=new Array(n>1?n-1:0),c=1;c<n;c++)s[c-1]=arguments[c];return e({...t,locale:o},...s)}}const n=o(e),s=o(t);export{s as serverPermanentRedirect,n as serverRedirect};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import o from"next/link";import{usePathname as
|
|
2
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import o from"next/link";import{usePathname as r}from"next/navigation";import t,{forwardRef as n,useState as i,useEffect as l}from"react";import c from"../../react-client/useLocale.js";import{isLocalizableHref as p,prefixHref as a,localizeHref as s}from"../../shared/utils.js";import f from"./syncLocaleCookie.js";function m(n,m){let{href:h,locale:u,localePrefixMode:d,onClick:k,prefetch:x,prefix:L,...g}=n;const j=r(),v=c(),C=u!==v,[y,w]=i((()=>p(h)&&("never"!==d||C)?a(h,L):h));return l((()=>{j&&w(s(h,u,v,j,L))}),[v,h,u,j,L]),C&&(x&&console.error("The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`"),x=!1),t.createElement(o,e({ref:m,href:y,hrefLang:C?u:void 0,onClick:function(e){f(j,v,u),k&&k(e)},prefetch:x},g))}const h=n(m);h.displayName="ClientLink";export{h as default};
|