Skip to content

Commit 732b96d

Browse files
authored
Merge pull request #19 from objectstack-ai/copilot/add-language-toggle-feature
2 parents 33f80dd + 494855a commit 732b96d

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

apps/docs/app/[lang]/docs/layout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ export default async function Layout({
1414
const { lang } = await params;
1515

1616
return (
17-
<DocsLayout tree={source.pageTree[lang]} {...baseOptions}>
17+
<DocsLayout
18+
tree={source.pageTree[lang]}
19+
{...baseOptions}
20+
i18n
21+
>
1822
{children}
1923
</DocsLayout>
2024
);

apps/docs/app/[lang]/layout.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import type { ReactNode } from 'react';
22
import { RootProvider } from 'fumadocs-ui/provider/next';
33
import { i18n } from '@/lib/i18n';
44

5+
// Language display names mapping
6+
const LANGUAGE_NAMES: Record<string, string> = {
7+
en: 'English',
8+
cn: '中文',
9+
};
10+
511
export default async function LanguageLayout({
612
params,
713
children,
@@ -14,7 +20,17 @@ export default async function LanguageLayout({
1420
return (
1521
<html lang={lang} suppressHydrationWarning>
1622
<body>
17-
<RootProvider>{children}</RootProvider>
23+
<RootProvider
24+
i18n={{
25+
locale: lang,
26+
locales: i18n.languages.map((l) => ({
27+
name: LANGUAGE_NAMES[l] || l,
28+
locale: l,
29+
})),
30+
}}
31+
>
32+
{children}
33+
</RootProvider>
1834
</body>
1935
</html>
2036
);

apps/docs/app/[lang]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { baseOptions } from '@/app/layout.config';
55

66
export default function HomePage() {
77
return (
8-
<HomeLayout {...baseOptions}>
8+
<HomeLayout {...baseOptions} i18n>
99
<main className="flex min-h-screen flex-col items-center justify-center text-center px-4 py-16 sm:py-24 md:py-32 overflow-hidden bg-background text-foreground selection:bg-primary/20">
1010

1111
{/* Hero Section */}

0 commit comments

Comments
 (0)