@@ -2,8 +2,9 @@ import { createRootRoute, HeadContent, Outlet, Scripts, useParams } from '@tanst
22import * as React from 'react' ;
33import appCss from '@/styles/app.css?url' ;
44import { RootProvider } from 'fumadocs-ui/provider/tanstack' ;
5- import { i18nProvider } from 'fumadocs-ui/i18n' ;
5+ import { i18nProvider , uiTranslations } from 'fumadocs-ui/i18n' ;
66import { i18n } from '@/lib/i18n' ;
7+ import { zhTW } from '@fumadocs/language/zh-tw' ;
78
89export const Route = createRootRoute ( {
910 head : ( ) => ( {
@@ -32,24 +33,15 @@ function RootComponent() {
3233 ) ;
3334}
3435
35- function i18nProps ( locale : string ) {
36- const locales = i18n . languages . map ( ( code ) => ( {
37- locale : code ,
38- name : code === 'cn' ? 'Chinese' : 'English' ,
39- } ) ) ;
40-
41- if ( locale === 'cn' ) {
42- return {
43- locale,
44- locales,
45- translations : {
46- 'Search(search dialog input placeholder)' : 'Translated Content' ,
47- } ,
48- } ;
49- }
50-
51- return { locale, locales } ;
52- }
36+ const translations = i18n
37+ . translations ( )
38+ . extend ( uiTranslations ( ) )
39+ . preset ( 'cn' , zhTW ( ) )
40+ . add ( {
41+ cn : {
42+ 'Search(search trigger)' : 'Translated Content' ,
43+ } ,
44+ } ) ;
5345
5446function RootDocument ( { children } : { children : React . ReactNode } ) {
5547 const { lang = i18n . defaultLanguage } = useParams ( { strict : false } ) ;
@@ -60,7 +52,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
6052 < HeadContent />
6153 </ head >
6254 < body className = "flex flex-col min-h-screen" >
63- < RootProvider i18n = { i18nProvider ( i18nProps ( lang ) ) } > { children } </ RootProvider >
55+ < RootProvider i18n = { i18nProvider ( translations , lang ) } > { children } </ RootProvider >
6456 < Scripts />
6557 </ body >
6658 </ html >
0 commit comments