's'
This commit is contained in:
@@ -53,7 +53,10 @@ export function LocaleProvider({
|
||||
const setLocale = useCallback((newLocale: Locale) => {
|
||||
const path = window.location.pathname;
|
||||
const newPath = path.replace(/^\/(zh|en)/, `/${newLocale}`);
|
||||
window.location.href = newPath || `/${newLocale}`;
|
||||
void import("@/app/lib/navigation-loading").then(({ startNavigation }) => {
|
||||
startNavigation();
|
||||
window.location.href = newPath || `/${newLocale}`;
|
||||
});
|
||||
}, []);
|
||||
|
||||
const value: LocaleContextValue = {
|
||||
@@ -89,7 +92,10 @@ function navigate(pathname: string, locale: Locale, opts?: { locale?: Locale })
|
||||
const newLocale = opts?.locale ?? locale;
|
||||
const cleanPath = pathname.replace(/^\/(zh|en)/, "") || "/";
|
||||
const newPath = `/${newLocale}${cleanPath === "/" ? "" : cleanPath}`;
|
||||
window.location.href = newPath;
|
||||
void import("@/app/lib/navigation-loading").then(({ startNavigation }) => {
|
||||
startNavigation();
|
||||
window.location.href = newPath;
|
||||
});
|
||||
}
|
||||
|
||||
export function useLocaleRouter() {
|
||||
|
||||
Reference in New Issue
Block a user