UI: fix i18n toggle

This commit is contained in:
Fuma Nama
2024-12-29 08:13:56 +08:00
parent 61f0e3ad76
commit e95be5204a
2 changed files with 8 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-ui': patch
---
Fix i18n toggle
+3 -3
View File
@@ -43,14 +43,14 @@ export function I18nProvider({
const router = useRouter();
const pathname = usePathname();
const onChangeCallback = (locale: string) => {
const onChangeCallback = (value: string) => {
const segments = pathname.split('/').filter((v) => v.length > 0);
// If locale prefix hidden
if (segments[0] !== locale) {
segments.unshift(locale);
segments.unshift(value);
} else {
segments[0] = locale;
segments[0] = value;
}
router.push(`/${segments.join('/')}`);