feat(i18n): 增强管理端多语言支持,优化语言初始化与恢复逻辑
This commit is contained in:
@@ -22,6 +22,9 @@ export const metadata: Metadata = {
|
||||
description: "Lottery administration console",
|
||||
};
|
||||
|
||||
/** 在 React 水合前恢复 `<html lang>`,避免刷新后先闪中文再切换 */
|
||||
const ADMIN_LOCALE_BOOTSTRAP = `(function(){try{var s=localStorage.getItem("lottery_admin_ui_locale");var m={zh:"zh-Hans",en:"en",ne:"ne"};if(s&&m[s])document.documentElement.lang=m[s];}catch(e){}})();`;
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
@@ -33,6 +36,9 @@ export default function RootLayout({
|
||||
suppressHydrationWarning
|
||||
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
|
||||
>
|
||||
<head>
|
||||
<script dangerouslySetInnerHTML={{ __html: ADMIN_LOCALE_BOOTSTRAP }} />
|
||||
</head>
|
||||
<body className="flex min-h-full flex-col">
|
||||
<Providers>{children}</Providers>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user