Resolve the language setting persistence issue
- Move i18n initialization to async function - Sync i18n with settings store language - Add Root component for i18n loading state - Convert i18n.js to TypeScript
This commit is contained in:
24
lightrag_webui/src/components/Root.tsx
Normal file
24
lightrag_webui/src/components/Root.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { StrictMode, useEffect, useState } from 'react'
|
||||
import { initializeI18n } from '@/i18n'
|
||||
import App from '@/App'
|
||||
|
||||
export const Root = () => {
|
||||
const [isI18nInitialized, setIsI18nInitialized] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
// Initialize i18n immediately with persisted language
|
||||
initializeI18n().then(() => {
|
||||
setIsI18nInitialized(true)
|
||||
})
|
||||
}, [])
|
||||
|
||||
if (!isI18nInitialized) {
|
||||
return null // or a loading spinner
|
||||
}
|
||||
|
||||
return (
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user