From b27777b625fb348f35e435276842668e16456967 Mon Sep 17 00:00:00 2001 From: NtskwK Date: Tue, 3 Feb 2026 11:19:09 +0800 Subject: feat(i18n): add multi-language support for docs --- packages/docs/app/root.tsx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'packages/docs/app/root.tsx') diff --git a/packages/docs/app/root.tsx b/packages/docs/app/root.tsx index a6c807e..9032c80 100644 --- a/packages/docs/app/root.tsx +++ b/packages/docs/app/root.tsx @@ -6,11 +6,25 @@ import { Outlet, Scripts, ScrollRestoration, + useParams, } from 'react-router'; import { RootProvider } from 'fumadocs-ui/provider/react-router'; import type { Route } from './+types/root'; import './app.css'; +import { defineI18nUI } from 'fumadocs-ui/i18n'; +import { i18n } from './lib/i18n'; +const { provider } = defineI18nUI(i18n, { + translations: { + en: { + displayName: 'English', + }, + zh: { + displayName: '中文', + search: '查找文档', + }, + }, +}); export const links: Route.LinksFunction = () => [ { rel: 'preconnect', href: 'https://fonts.googleapis.com' }, { @@ -25,8 +39,10 @@ export const links: Route.LinksFunction = () => [ ]; export function Layout({ children }: { children: React.ReactNode }) { + const { lang = i18n.defaultLanguage } = useParams(); + return ( - + @@ -34,7 +50,7 @@ export function Layout({ children }: { children: React.ReactNode }) { - {children} + {children} -- cgit v1.2.3-70-g09d2