next-intl 4.3.8 → 4.3.9
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.
|
@@ -39,7 +39,14 @@ function createNavigation(routing) {
|
|
|
39
39
|
} = options || {};
|
|
40
40
|
const pathname = getPathname({
|
|
41
41
|
href,
|
|
42
|
-
locale: nextLocale || curLocale
|
|
42
|
+
locale: nextLocale || curLocale,
|
|
43
|
+
// Always include a prefix when changing locales. Theoretically,
|
|
44
|
+
// this is only necessary for the case described in #2020. However,
|
|
45
|
+
// the full detection is rather expensive, and this behavior is
|
|
46
|
+
// consistent with the `Link` component. The downside is an
|
|
47
|
+
// additional redirect for users in other situations. Locale
|
|
48
|
+
// changes should be rare though, so this might be fine.
|
|
49
|
+
forcePrefix: nextLocale != null || undefined
|
|
43
50
|
});
|
|
44
51
|
const args = [pathname];
|
|
45
52
|
if (Object.keys(rest).length > 0) {
|
|
@@ -21,6 +21,9 @@ function BaseLink({
|
|
|
21
21
|
// `useParams` can be called, but the return type is `null`.
|
|
22
22
|
const pathname = usePathname();
|
|
23
23
|
function onLinkClick(event) {
|
|
24
|
+
// Even though we force a prefix when changing locales,
|
|
25
|
+
// this could be a cache hit of the client-side router,
|
|
26
|
+
// therefore we sync the cookie to ensure it's up to date.
|
|
24
27
|
syncLocaleCookie(localeCookie, pathname, curLocale, locale);
|
|
25
28
|
if (onClick) onClick(event);
|
|
26
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRouter as e,usePathname as t}from"next/navigation";import{useMemo as r}from"react";import{useLocale as
|
|
1
|
+
import{useRouter as e,usePathname as t}from"next/navigation";import{useMemo as r}from"react";import{useLocale as o}from"use-intl";import n 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:u,config:m,getPathname:f,...h}=n(o,c);return{...h,Link:u,usePathname:function(){const e=i(m),t=o();return r((()=>e&&m.pathnames?s(t,e,m.pathnames):e),[t,e])},useRouter:function(){const n=e(),s=o(),i=t();return r((()=>{function e(e){return function(t,r){const{locale:o,...n}=r||{},c=[f({href:t,locale:o||s,forcePrefix:null!=o||void 0})];Object.keys(n).length>0&&c.push(n),a(m.localeCookie,i,s,o),e(...c)}}return{...n,push:e(n.push),replace:e(n.replace),prefetch:e(n.prefetch)}}),[s,i,n])},getPathname:f}}export{c as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.9",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
114
114
|
"negotiator": "^1.0.0",
|
|
115
|
-
"use-intl": "^4.3.
|
|
115
|
+
"use-intl": "^4.3.9"
|
|
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": "b927ead9d8c48da4ec01c1c6a32fc30c5c19353b"
|
|
128
128
|
}
|