next-intl 3.9.3 → 3.9.4
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.
|
@@ -28,8 +28,8 @@ function BaseLink(_ref, ref) {
|
|
|
28
28
|
// The types aren't entirely correct here. Outside of Next.js
|
|
29
29
|
// `useParams` can be called, but the return type is `null`.
|
|
30
30
|
const pathname = navigation.usePathname();
|
|
31
|
-
const
|
|
32
|
-
const isChangingLocale = locale !==
|
|
31
|
+
const curLocale = useLocale.default();
|
|
32
|
+
const isChangingLocale = locale !== curLocale;
|
|
33
33
|
const [localizedHref, setLocalizedHref] = React.useState(() => utils.isLocalHref(href) && (localePrefix !== 'never' || isChangingLocale) ?
|
|
34
34
|
// For the `localePrefix: 'as-needed' strategy, the href shouldn't
|
|
35
35
|
// be prefixed if the locale is the default locale. To determine this, we
|
|
@@ -43,13 +43,13 @@ function BaseLink(_ref, ref) {
|
|
|
43
43
|
// determined in the effect below.
|
|
44
44
|
utils.prefixHref(href, locale) : href);
|
|
45
45
|
function onLinkClick(event) {
|
|
46
|
-
syncLocaleCookie.default(pathname,
|
|
46
|
+
syncLocaleCookie.default(pathname, curLocale, locale);
|
|
47
47
|
if (onClick) onClick(event);
|
|
48
48
|
}
|
|
49
49
|
React.useEffect(() => {
|
|
50
|
-
if (!pathname
|
|
51
|
-
setLocalizedHref(utils.localizeHref(href, locale,
|
|
52
|
-
}, [
|
|
50
|
+
if (!pathname) return;
|
|
51
|
+
setLocalizedHref(utils.localizeHref(href, locale, curLocale, pathname));
|
|
52
|
+
}, [curLocale, href, locale, pathname]);
|
|
53
53
|
if (isChangingLocale) {
|
|
54
54
|
if (prefetch && "development" !== 'production') {
|
|
55
55
|
console.error('The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"next/link";import{usePathname as o}from"next/navigation";import t,{forwardRef as n,useState as
|
|
2
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"next/link";import{usePathname as o}from"next/navigation";import t,{forwardRef as n,useState as i,useEffect as l}from"react";import c from"../../react-client/useLocale.js";import{isLocalHref as a,prefixHref as p,localizeHref as s}from"../../shared/utils.js";import f from"./syncLocaleCookie.js";function m(n,m){let{href:h,locale:u,localePrefix:d,onClick:k,prefetch:v,...x}=n;const L=o(),g=c(),j=u!==g,[C,y]=i((()=>a(h)&&("never"!==d||j)?p(h,u):h));return l((()=>{L&&y(s(h,u,g,L))}),[g,h,u,L]),j&&(v&&console.error("The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`"),v=!1),t.createElement(r,e({ref:m,href:C,hrefLang:j?u:void 0,onClick:function(e){f(L,g,u),k&&k(e)},prefetch:v},x))}const h=n(m);h.displayName="ClientLink";var u=h;export{u as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("next/link"),t=require("next/navigation"),l=require("react"),a=require("../../react-client/useLocale.js"),i=require("../../shared/utils.js"),u=require("./syncLocaleCookie.js");function n(e){return e&&e.__esModule?e:{default:e}}var f=n(r),o=n(l);function c(r,n){let{href:c,locale:s,localePrefix:d,onClick:
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("next/link"),t=require("next/navigation"),l=require("react"),a=require("../../react-client/useLocale.js"),i=require("../../shared/utils.js"),u=require("./syncLocaleCookie.js");function n(e){return e&&e.__esModule?e:{default:e}}var f=n(r),o=n(l);function c(r,n){let{href:c,locale:s,localePrefix:d,onClick:p,prefetch:v,...h}=r;const q=t.usePathname(),x=a.default(),_=s!==x,[j,k]=l.useState((()=>i.isLocalHref(c)&&("never"!==d||_)?i.prefixHref(c,s):c));return l.useEffect((()=>{q&&k(i.localizeHref(c,s,x,q))}),[x,c,s,q]),_&&(v=!1),o.default.createElement(f.default,e.extends({ref:n,href:j,hrefLang:_?s:void 0,onClick:function(e){u.default(q,x,s),p&&p(e)},prefetch:v},h))}const s=l.forwardRef(c);s.displayName="ClientLink";var d=s;exports.default=d;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.4",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
84
84
|
"negotiator": "^0.6.3",
|
|
85
|
-
"use-intl": "^3.9.
|
|
85
|
+
"use-intl": "^3.9.4"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -141,5 +141,5 @@
|
|
|
141
141
|
"limit": "5.855 KB"
|
|
142
142
|
}
|
|
143
143
|
],
|
|
144
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "18031134e28cbef05ad4477b0639809c739ae457"
|
|
145
145
|
}
|