Skip to content

Commit

Permalink
UI: fix i18n toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
fuma-nama committed Dec 29, 2024
1 parent 61f0e3a commit e95be52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-points-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'fumadocs-ui': patch
---

Fix i18n toggle
6 changes: 3 additions & 3 deletions packages/ui/src/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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('/')}`);
Expand Down

0 comments on commit e95be52

Please sign in to comment.