- Implement runtime i18n using MutationObserver for automatic DOM translation
- Add language switcher dropdown in dashboard header (EN/VI/ZH)
- Support 3 languages: English (default), Tiếng Việt, 简体中文
- Add translation files: vi.json (197 entries), zh-CN.json (513 entries, cleaned)
- Translate dashboard UI: sidebar menu, header, settings, MITM page
- Use cookie-based locale persistence with /api/locale endpoint
- Zero component changes required - translations applied at runtime
- Fix Header flicker on route change with key={pathname}
Co-authored-by: eachann <each1024@qq.com>
Based on PR #247 from decolua/9router with runtime approach
Made-with: Cursor
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
import { Inter } from "next/font/google";
|
|
import "./globals.css";
|
|
import { ThemeProvider } from "@/shared/components/ThemeProvider";
|
|
import "@/lib/initCloudSync"; // Auto-initialize cloud sync
|
|
import "@/lib/network/initOutboundProxy"; // Auto-initialize outbound proxy env
|
|
import { initConsoleLogCapture } from "@/lib/consoleLogBuffer";
|
|
import { RuntimeI18nProvider } from "@/i18n/RuntimeI18nProvider";
|
|
|
|
// Hook console immediately at module load time (server-side only, runs once)
|
|
initConsoleLogCapture();
|
|
|
|
const inter = Inter({
|
|
subsets: ["latin"],
|
|
variable: "--font-inter",
|
|
});
|
|
|
|
export const metadata = {
|
|
title: "9Router - AI Infrastructure Management",
|
|
description: "One endpoint for all your AI providers. Manage keys, monitor usage, and scale effortlessly.",
|
|
icons: {
|
|
icon: "/favicon.svg",
|
|
},
|
|
};
|
|
|
|
export const viewport = {
|
|
themeColor: "#0a0a0a",
|
|
};
|
|
|
|
export default function RootLayout({ children }) {
|
|
return (
|
|
<html lang="en" suppressHydrationWarning>
|
|
<head>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
|
|
{/* eslint-disable-next-line @next/next/no-page-custom-font */}
|
|
<link
|
|
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap"
|
|
rel="stylesheet"
|
|
/>
|
|
</head>
|
|
<body className={`${inter.variable} font-sans antialiased`}>
|
|
<ThemeProvider>
|
|
<RuntimeI18nProvider>
|
|
{children}
|
|
</RuntimeI18nProvider>
|
|
</ThemeProvider>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|