next-intl 4.0.2 → 4.1.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/cjs/development/plugin.cjs +47 -18
- package/dist/esm/development/navigation/shared/createSharedNavigationFns.js +8 -7
- package/dist/esm/development/plugin/getNextConfig.js +30 -18
- package/dist/esm/development/plugin/hasStableTurboConfig.js +19 -0
- package/dist/esm/production/navigation/shared/createSharedNavigationFns.js +1 -1
- package/dist/esm/production/plugin/getNextConfig.js +1 -1
- package/dist/esm/production/plugin/hasStableTurboConfig.js +1 -0
- package/dist/types/navigation/react-client/createNavigation.d.ts +13 -4
- package/dist/types/navigation/react-server/createNavigation.d.ts +10 -4
- package/dist/types/navigation/shared/createSharedNavigationFns.d.ts +18 -6
- package/dist/types/plugin/hasStableTurboConfig.d.ts +2 -0
- package/package.json +3 -3
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('fs');
|
|
4
4
|
var path = require('path');
|
|
5
|
+
var module$1 = require('module');
|
|
5
6
|
|
|
7
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
6
8
|
function formatMessage(message) {
|
|
7
9
|
return `\n[next-intl] ${message}\n`;
|
|
8
10
|
}
|
|
@@ -84,6 +86,22 @@ export default messages;`;
|
|
|
84
86
|
fs.writeFileSync(declarationPath, createDeclaration(content));
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
// eslint-disable-next-line import/order
|
|
90
|
+
const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin.cjs', document.baseURI).href)));
|
|
91
|
+
const pkg = require$1('next/package.json');
|
|
92
|
+
function compareVersions(version1, version2) {
|
|
93
|
+
const v1Parts = version1.split('.').map(Number);
|
|
94
|
+
const v2Parts = version2.split('.').map(Number);
|
|
95
|
+
for (let i = 0; i < 3; i++) {
|
|
96
|
+
const v1 = v1Parts[i] || 0;
|
|
97
|
+
const v2 = v2Parts[i] || 0;
|
|
98
|
+
if (v1 > v2) return 1;
|
|
99
|
+
if (v1 < v2) return -1;
|
|
100
|
+
}
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
const hasStableTurboConfig = compareVersions(pkg.version, '15.3.0') >= 0;
|
|
104
|
+
|
|
87
105
|
function withExtensions(localPath) {
|
|
88
106
|
return [`${localPath}.ts`, `${localPath}.tsx`, `${localPath}.js`, `${localPath}.jsx`];
|
|
89
107
|
}
|
|
@@ -126,22 +144,31 @@ function getNextConfig(pluginConfig, nextConfig) {
|
|
|
126
144
|
if (pluginConfig.requestConfig?.startsWith('/')) {
|
|
127
145
|
throwError("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: " + pluginConfig.requestConfig);
|
|
128
146
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
...nextConfig?.
|
|
147
|
+
const resolveAlias = {
|
|
148
|
+
// Turbo aliases don't work with absolute
|
|
149
|
+
// paths (see error handling above)
|
|
150
|
+
'next-intl/config': resolveI18nPath(pluginConfig.requestConfig)
|
|
151
|
+
};
|
|
152
|
+
if (hasStableTurboConfig && !nextConfig?.experimental?.turbo) {
|
|
153
|
+
nextIntlConfig.turbopack = {
|
|
154
|
+
...nextConfig?.turbopack,
|
|
137
155
|
resolveAlias: {
|
|
138
|
-
...nextConfig?.
|
|
139
|
-
|
|
140
|
-
// paths (see error handling above)
|
|
141
|
-
'next-intl/config': resolveI18nPath(pluginConfig.requestConfig)
|
|
156
|
+
...nextConfig?.turbopack?.resolveAlias,
|
|
157
|
+
...resolveAlias
|
|
142
158
|
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
159
|
+
};
|
|
160
|
+
} else {
|
|
161
|
+
nextIntlConfig.experimental = {
|
|
162
|
+
...nextConfig?.experimental,
|
|
163
|
+
turbo: {
|
|
164
|
+
...nextConfig?.experimental?.turbo,
|
|
165
|
+
resolveAlias: {
|
|
166
|
+
...nextConfig?.experimental?.turbo?.resolveAlias,
|
|
167
|
+
...resolveAlias
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
145
172
|
} else {
|
|
146
173
|
nextIntlConfig.webpack = function webpack(...[config, options]) {
|
|
147
174
|
// Webpack requires absolute paths
|
|
@@ -154,10 +181,12 @@ function getNextConfig(pluginConfig, nextConfig) {
|
|
|
154
181
|
}
|
|
155
182
|
|
|
156
183
|
// Forward config
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
184
|
+
if (nextConfig?.trailingSlash) {
|
|
185
|
+
nextIntlConfig.env = {
|
|
186
|
+
...nextConfig.env,
|
|
187
|
+
_next_intl_trailing_slash: 'true'
|
|
188
|
+
};
|
|
189
|
+
}
|
|
161
190
|
return Object.assign({}, nextConfig, nextIntlConfig);
|
|
162
191
|
}
|
|
163
192
|
|
|
@@ -40,8 +40,10 @@ function createSharedNavigationFns(getLocale, routing) {
|
|
|
40
40
|
href: pathnames == null ? pathname : {
|
|
41
41
|
pathname,
|
|
42
42
|
params
|
|
43
|
-
}
|
|
44
|
-
|
|
43
|
+
},
|
|
44
|
+
// Always include a prefix when changing locales
|
|
45
|
+
forcePrefix: locale != null || undefined
|
|
46
|
+
}) : pathname;
|
|
45
47
|
return /*#__PURE__*/jsx(BaseLink, {
|
|
46
48
|
ref: ref
|
|
47
49
|
// @ts-expect-error -- This is ok
|
|
@@ -56,9 +58,9 @@ function createSharedNavigationFns(getLocale, routing) {
|
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
const LinkWithRef = /*#__PURE__*/forwardRef(Link);
|
|
59
|
-
function getPathname(args
|
|
60
|
-
_forcePrefix) {
|
|
61
|
+
function getPathname(args) {
|
|
61
62
|
const {
|
|
63
|
+
forcePrefix,
|
|
62
64
|
href,
|
|
63
65
|
locale
|
|
64
66
|
} = args;
|
|
@@ -81,7 +83,7 @@ function createSharedNavigationFns(getLocale, routing) {
|
|
|
81
83
|
pathnames: config.pathnames
|
|
82
84
|
});
|
|
83
85
|
}
|
|
84
|
-
return applyPathnamePrefix(pathname, locale, config,
|
|
86
|
+
return applyPathnamePrefix(pathname, locale, config, forcePrefix);
|
|
85
87
|
}
|
|
86
88
|
function getRedirectFn(fn) {
|
|
87
89
|
/** @see https://next-intl.dev/docs/routing/navigation#redirect */
|
|
@@ -96,8 +98,7 @@ function createSharedNavigationFns(getLocale, routing) {
|
|
|
96
98
|
Link: LinkWithRef,
|
|
97
99
|
redirect: redirect$1,
|
|
98
100
|
permanentRedirect: permanentRedirect$1,
|
|
99
|
-
|
|
100
|
-
getPathname: getPathname
|
|
101
|
+
getPathname
|
|
101
102
|
};
|
|
102
103
|
}
|
|
103
104
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import hasStableTurboConfig from './hasStableTurboConfig.js';
|
|
3
4
|
import { throwError } from './utils.js';
|
|
4
5
|
|
|
5
6
|
function withExtensions(localPath) {
|
|
@@ -44,22 +45,31 @@ function getNextConfig(pluginConfig, nextConfig) {
|
|
|
44
45
|
if (pluginConfig.requestConfig?.startsWith('/')) {
|
|
45
46
|
throwError("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: " + pluginConfig.requestConfig);
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
...nextConfig?.
|
|
48
|
+
const resolveAlias = {
|
|
49
|
+
// Turbo aliases don't work with absolute
|
|
50
|
+
// paths (see error handling above)
|
|
51
|
+
'next-intl/config': resolveI18nPath(pluginConfig.requestConfig)
|
|
52
|
+
};
|
|
53
|
+
if (hasStableTurboConfig && !nextConfig?.experimental?.turbo) {
|
|
54
|
+
nextIntlConfig.turbopack = {
|
|
55
|
+
...nextConfig?.turbopack,
|
|
55
56
|
resolveAlias: {
|
|
56
|
-
...nextConfig?.
|
|
57
|
-
|
|
58
|
-
// paths (see error handling above)
|
|
59
|
-
'next-intl/config': resolveI18nPath(pluginConfig.requestConfig)
|
|
57
|
+
...nextConfig?.turbopack?.resolveAlias,
|
|
58
|
+
...resolveAlias
|
|
60
59
|
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
60
|
+
};
|
|
61
|
+
} else {
|
|
62
|
+
nextIntlConfig.experimental = {
|
|
63
|
+
...nextConfig?.experimental,
|
|
64
|
+
turbo: {
|
|
65
|
+
...nextConfig?.experimental?.turbo,
|
|
66
|
+
resolveAlias: {
|
|
67
|
+
...nextConfig?.experimental?.turbo?.resolveAlias,
|
|
68
|
+
...resolveAlias
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
63
73
|
} else {
|
|
64
74
|
nextIntlConfig.webpack = function webpack(...[config, options]) {
|
|
65
75
|
// Webpack requires absolute paths
|
|
@@ -72,10 +82,12 @@ function getNextConfig(pluginConfig, nextConfig) {
|
|
|
72
82
|
}
|
|
73
83
|
|
|
74
84
|
// Forward config
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
if (nextConfig?.trailingSlash) {
|
|
86
|
+
nextIntlConfig.env = {
|
|
87
|
+
...nextConfig.env,
|
|
88
|
+
_next_intl_trailing_slash: 'true'
|
|
89
|
+
};
|
|
90
|
+
}
|
|
79
91
|
return Object.assign({}, nextConfig, nextIntlConfig);
|
|
80
92
|
}
|
|
81
93
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line import/order
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const pkg = require('next/package.json');
|
|
6
|
+
function compareVersions(version1, version2) {
|
|
7
|
+
const v1Parts = version1.split('.').map(Number);
|
|
8
|
+
const v2Parts = version2.split('.').map(Number);
|
|
9
|
+
for (let i = 0; i < 3; i++) {
|
|
10
|
+
const v1 = v1Parts[i] || 0;
|
|
11
|
+
const v2 = v2Parts[i] || 0;
|
|
12
|
+
if (v1 > v2) return 1;
|
|
13
|
+
if (v1 < v2) return -1;
|
|
14
|
+
}
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
const hasStableTurboConfig = compareVersions(pkg.version, '15.3.0') >= 0;
|
|
18
|
+
|
|
19
|
+
export { hasStableTurboConfig as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{redirect as e,permanentRedirect as t}from"next/navigation";import{forwardRef as o}from"react";import{receiveRoutingConfig as r}from"../../routing/config.js";import n from"../../shared/use.js";import{isLocalizableHref as a,isPromise as i}from"../../shared/utils.js";import
|
|
1
|
+
import{redirect as e,permanentRedirect as t}from"next/navigation";import{forwardRef as o}from"react";import{receiveRoutingConfig as r}from"../../routing/config.js";import n from"../../shared/use.js";import{isLocalizableHref as a,isPromise as i}from"../../shared/utils.js";import c from"./BaseLink.js";import{serializeSearchParams as f,compileLocalizedPathname as m,applyPathnamePrefix as l,normalizeNameOrNameWithParams as s}from"./utils.js";import{jsx as p}from"react/jsx-runtime";function u(u,h){const j=r(h||{}),d=j.pathnames;function g({href:e,locale:t,...o},r){let f,m;"object"==typeof e?(f=e.pathname,m=e.params):f=e;const l=a(e),s=u(),h=i(s)?n(s):s,g=l?y({locale:t||h,href:null==d?f:{pathname:f,params:m},forcePrefix:null!=t||void 0}):f;return p(c,{ref:r,href:"object"==typeof e?{...e,pathname:g}:g,locale:t,localeCookie:j.localeCookie,...o})}const x=o(g);function y(e){const{forcePrefix:t,href:o,locale:r}=e;let n;return null==d?"object"==typeof o?(n=o.pathname,o.query&&(n+=f(o.query))):n=o:n=m({locale:r,...s(o),pathnames:j.pathnames}),l(n,r,j,t)}function k(e){return function(t,...o){return e(y(t),...o)}}const b=k(e),P=k(t);return{config:j,Link:x,redirect:b,permanentRedirect:P,getPathname:y}}export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"fs";import
|
|
1
|
+
import t from"fs";import e from"path";import n from"./hasStableTurboConfig.js";import{throwError as o}from"./utils.js";function r(t){return[`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.jsx`]}function s(n,s){function i(n){return t.existsSync(function(t){const n=[];return s&&n.push(s),n.push(t),e.resolve(...n)}(n))}if(n)return i(n)||o(`Could not find i18n config at ${n}, please provide a valid path.`),n;for(const t of[...r("./i18n/request"),...r("./src/i18n/request")])if(i(t))return t;o("Could not locate request configuration module.\n\nThis path is supported by default: ./(src/)i18n/request.{js,jsx,ts,tsx}\n\nAlternatively, you can specify a custom location in your Next.js config:\n\nconst withNextIntl = createNextIntlPlugin(\n\nAlternatively, you can specify a custom location in your Next.js config:\n\nconst withNextIntl = createNextIntlPlugin(\n './path/to/i18n/request.tsx'\n);")}function i(t,r){const i={};if(null!=process.env.TURBOPACK){t.requestConfig?.startsWith("/")&&o("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+t.requestConfig);const e={"next-intl/config":s(t.requestConfig)};n&&!r?.experimental?.turbo?i.turbopack={...r?.turbopack,resolveAlias:{...r?.turbopack?.resolveAlias,...e}}:i.experimental={...r?.experimental,turbo:{...r?.experimental?.turbo,resolveAlias:{...r?.experimental?.turbo?.resolveAlias,...e}}}}else i.webpack=function(...[n,o]){return n.resolve.alias["next-intl/config"]=e.resolve(n.context,s(t.requestConfig,n.context)),"function"==typeof r?.webpack?r.webpack(n,o):n};return r?.trailingSlash&&(i.env={...r.env,_next_intl_trailing_slash:"true"}),Object.assign({},r,i)}export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as t}from"module";const r=function(t,r){const e=t.split(".").map(Number),o=r.split(".").map(Number);for(let t=0;t<3;t++){const r=e[t]||0,n=o[t]||0;if(r>n)return 1;if(r<n)return-1}return 0}(t(import.meta.url)("next/package.json").version,"15.3.0")>=0;export{r as default};
|
|
@@ -22,6 +22,9 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
22
22
|
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
23
23
|
onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
24
24
|
onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
25
|
+
onNavigate?: ((event: {
|
|
26
|
+
preventDefault: () => void;
|
|
27
|
+
}) => void) | undefined;
|
|
25
28
|
download?: any;
|
|
26
29
|
hrefLang?: string | undefined | undefined;
|
|
27
30
|
media?: string | undefined | undefined;
|
|
@@ -332,6 +335,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
332
335
|
query?: import("../shared/utils.js").QueryParams;
|
|
333
336
|
}) : never : never;
|
|
334
337
|
locale: Locale;
|
|
338
|
+
forcePrefix?: boolean;
|
|
335
339
|
}) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & {
|
|
336
340
|
locale?: Locale;
|
|
337
341
|
}) | undefined) => void;
|
|
@@ -356,6 +360,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
356
360
|
query?: import("../shared/utils.js").QueryParams;
|
|
357
361
|
}) : never : never;
|
|
358
362
|
locale: Locale;
|
|
363
|
+
forcePrefix?: boolean;
|
|
359
364
|
}) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & {
|
|
360
365
|
locale?: Locale;
|
|
361
366
|
}) | undefined) => void;
|
|
@@ -380,6 +385,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
380
385
|
query?: import("../shared/utils.js").QueryParams;
|
|
381
386
|
}) : never : never;
|
|
382
387
|
locale: Locale;
|
|
388
|
+
forcePrefix?: boolean;
|
|
383
389
|
}) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").PrefetchOptions> & {
|
|
384
390
|
locale?: Locale;
|
|
385
391
|
}) | undefined) => void;
|
|
@@ -407,8 +413,9 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
407
413
|
query?: import("../shared/utils.js").QueryParams;
|
|
408
414
|
}) : never : never;
|
|
409
415
|
locale: Locale;
|
|
416
|
+
forcePrefix?: boolean;
|
|
410
417
|
}) => string;
|
|
411
|
-
redirect: (args:
|
|
418
|
+
redirect: (args: {
|
|
412
419
|
href: [AppPathnames] extends [never] ? string | {
|
|
413
420
|
pathname: string;
|
|
414
421
|
query?: import("../shared/utils.js").QueryParams;
|
|
@@ -428,8 +435,9 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
428
435
|
query?: import("../shared/utils.js").QueryParams;
|
|
429
436
|
}) : never : never;
|
|
430
437
|
locale: Locale;
|
|
431
|
-
|
|
432
|
-
|
|
438
|
+
forcePrefix?: boolean;
|
|
439
|
+
}, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
440
|
+
permanentRedirect: (args: {
|
|
433
441
|
href: [AppPathnames] extends [never] ? string | {
|
|
434
442
|
pathname: string;
|
|
435
443
|
query?: import("../shared/utils.js").QueryParams;
|
|
@@ -449,5 +457,6 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
449
457
|
query?: import("../shared/utils.js").QueryParams;
|
|
450
458
|
}) : never : never;
|
|
451
459
|
locale: Locale;
|
|
452
|
-
|
|
460
|
+
forcePrefix?: boolean;
|
|
461
|
+
}, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
453
462
|
};
|
|
@@ -23,6 +23,9 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
23
23
|
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
24
24
|
onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
25
25
|
onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
26
|
+
onNavigate?: ((event: {
|
|
27
|
+
preventDefault: () => void;
|
|
28
|
+
}) => void) | undefined;
|
|
26
29
|
download?: any;
|
|
27
30
|
hrefLang?: string | undefined | undefined;
|
|
28
31
|
media?: string | undefined | undefined;
|
|
@@ -310,7 +313,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
310
313
|
pathname: T;
|
|
311
314
|
} & Omit<import("url").UrlObject, "pathname">) : never : never;
|
|
312
315
|
}, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
313
|
-
redirect: (args:
|
|
316
|
+
redirect: (args: {
|
|
314
317
|
href: [AppPathnames] extends [never] ? string | {
|
|
315
318
|
pathname: string;
|
|
316
319
|
query?: import("../shared/utils.js").QueryParams;
|
|
@@ -330,8 +333,9 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
330
333
|
query?: import("../shared/utils.js").QueryParams;
|
|
331
334
|
}) : never : never;
|
|
332
335
|
locale: import("use-intl").Locale;
|
|
333
|
-
|
|
334
|
-
|
|
336
|
+
forcePrefix?: boolean;
|
|
337
|
+
}, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
338
|
+
permanentRedirect: (args: {
|
|
335
339
|
href: [AppPathnames] extends [never] ? string | {
|
|
336
340
|
pathname: string;
|
|
337
341
|
query?: import("../shared/utils.js").QueryParams;
|
|
@@ -351,7 +355,8 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
351
355
|
query?: import("../shared/utils.js").QueryParams;
|
|
352
356
|
}) : never : never;
|
|
353
357
|
locale: import("use-intl").Locale;
|
|
354
|
-
|
|
358
|
+
forcePrefix?: boolean;
|
|
359
|
+
}, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
355
360
|
getPathname: (args: {
|
|
356
361
|
href: [AppPathnames] extends [never] ? string | {
|
|
357
362
|
pathname: string;
|
|
@@ -372,5 +377,6 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
372
377
|
query?: import("../shared/utils.js").QueryParams;
|
|
373
378
|
}) : never : never;
|
|
374
379
|
locale: import("use-intl").Locale;
|
|
380
|
+
forcePrefix?: boolean;
|
|
375
381
|
}) => string;
|
|
376
382
|
};
|
|
@@ -41,6 +41,9 @@ export default function createSharedNavigationFns<const AppLocales extends Local
|
|
|
41
41
|
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
42
42
|
onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
43
43
|
onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
44
|
+
onNavigate?: ((event: {
|
|
45
|
+
preventDefault: () => void;
|
|
46
|
+
}) => void) | undefined;
|
|
44
47
|
download?: any;
|
|
45
48
|
hrefLang?: string | undefined | undefined;
|
|
46
49
|
media?: string | undefined | undefined;
|
|
@@ -328,29 +331,38 @@ export default function createSharedNavigationFns<const AppLocales extends Local
|
|
|
328
331
|
pathname: T;
|
|
329
332
|
} & Omit<import("url").UrlObject, "pathname">) : never : never;
|
|
330
333
|
}, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
331
|
-
redirect: (args:
|
|
334
|
+
redirect: (args: Parameters<(args: {
|
|
332
335
|
/** @see https://next-intl.dev/docs/routing/navigation#getpathname */
|
|
333
336
|
href: [AppPathnames] extends [never] ? string | {
|
|
334
337
|
pathname: string;
|
|
335
338
|
query?: QueryParams;
|
|
336
339
|
} : HrefOrHrefWithParams<keyof AppPathnames>;
|
|
340
|
+
/** The locale to compute the pathname for. */
|
|
337
341
|
locale: Locale;
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
/** Will prepend the pathname with the locale prefix, regardless of your `localePrefix` setting. This can be helpful to update a locale cookie when changing locales. */
|
|
343
|
+
forcePrefix?: boolean;
|
|
344
|
+
}) => string>[0], type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
345
|
+
permanentRedirect: (args: Parameters<(args: {
|
|
340
346
|
/** @see https://next-intl.dev/docs/routing/navigation#getpathname */
|
|
341
347
|
href: [AppPathnames] extends [never] ? string | {
|
|
342
348
|
pathname: string;
|
|
343
349
|
query?: QueryParams;
|
|
344
350
|
} : HrefOrHrefWithParams<keyof AppPathnames>;
|
|
351
|
+
/** The locale to compute the pathname for. */
|
|
345
352
|
locale: Locale;
|
|
346
|
-
|
|
347
|
-
|
|
353
|
+
/** Will prepend the pathname with the locale prefix, regardless of your `localePrefix` setting. This can be helpful to update a locale cookie when changing locales. */
|
|
354
|
+
forcePrefix?: boolean;
|
|
355
|
+
}) => string>[0], type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
356
|
+
getPathname: (args: {
|
|
348
357
|
/** @see https://next-intl.dev/docs/routing/navigation#getpathname */
|
|
349
358
|
href: [AppPathnames] extends [never] ? string | {
|
|
350
359
|
pathname: string;
|
|
351
360
|
query?: QueryParams;
|
|
352
361
|
} : HrefOrHrefWithParams<keyof AppPathnames>;
|
|
362
|
+
/** The locale to compute the pathname for. */
|
|
353
363
|
locale: Locale;
|
|
354
|
-
|
|
364
|
+
/** Will prepend the pathname with the locale prefix, regardless of your `localePrefix` setting. This can be helpful to update a locale cookie when changing locales. */
|
|
365
|
+
forcePrefix?: boolean;
|
|
366
|
+
}) => string;
|
|
355
367
|
};
|
|
356
368
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
114
114
|
"negotiator": "^1.0.0",
|
|
115
|
-
"use-intl": "^4.0
|
|
115
|
+
"use-intl": "^4.1.0"
|
|
116
116
|
},
|
|
117
117
|
"peerDependencies": {
|
|
118
118
|
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"optional": true
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "9a70cef9f7d36cde5e8a69fd380f0747a050be56"
|
|
128
128
|
}
|