Skip to content

Commit 5e74299

Browse files
committed
Refactor i18n layout and update i18n config
Replaced the root page redirect logic with a new layout component that handles i18n using fumadocs-ui. Updated i18n configuration to include 'hideLocale' option for improved locale handling.
1 parent 24a82b9 commit 5e74299

3 files changed

Lines changed: 36 additions & 36 deletions

File tree

packages/site/app/layout.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import 'fumadocs-ui/style.css';
2+
import { RootProvider } from 'fumadocs-ui/provider/next';
3+
import { defineI18nUI } from 'fumadocs-ui/i18n';
4+
import { i18n } from '@/lib/i18n';
5+
6+
7+
const { provider } = defineI18nUI(i18n, {
8+
translations: {
9+
en: {
10+
displayName: 'English',
11+
},
12+
cn: {
13+
displayName: 'Chinese', 
14+
},
15+
},
16+
});
17+
18+
export default async function Layout({ params, children }: LayoutProps<'/[lang]'>) {
19+
const { lang } = await params;
20+
return (
21+
<html lang={lang} suppressHydrationWarning>
22+
<body
23+
style={{
24+
display: 'flex',
25+
flexDirection: 'column',
26+
minHeight: '100vh',
27+
}}
28+
>
29+
<RootProvider i18n={provider(lang)}>{children}</RootProvider>
30+
</body>
31+
</html>
32+
);
33+
}

packages/site/app/page.tsx

Lines changed: 0 additions & 35 deletions
This file was deleted.

packages/site/lib/i18n.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ import { defineI18n } from 'fumadocs-core/i18n';
44
export const i18n = defineI18n({
55
defaultLanguage: siteConfig.i18n.defaultLanguage,
66
languages: siteConfig.i18n.languages,
7-
parser: 'dir',
7+
parser: 'dir',
8+
hideLocale: 'default-locale',
9+
810
});

0 commit comments

Comments
 (0)