feat(i18n): integrate next-intl and dynamic locale support in RootLayout

This commit is contained in:
cfngc4594 2025-04-14 22:43:27 +08:00
parent 8673e4615a
commit 30922a25bb

View File

@ -1,6 +1,8 @@
import "@/app/globals.css";
import { Toaster } from "sonner";
import type { Metadata } from "next";
import { getLocale } from "next-intl/server";
import { NextIntlClientProvider } from "next-intl";
import { ThemeProvider } from "@/components/theme-provider";
import { SettingsDialog } from "@/components/settings-dialog";
@ -14,20 +16,24 @@ interface RootLayoutProps {
children: React.ReactNode;
}
export default function RootLayout({ children }: RootLayoutProps) {
export default async function RootLayout({ children }: RootLayoutProps) {
const locale = await getLocale();
return (
<html lang="en" className="h-full" suppressHydrationWarning>
<html lang={locale} className="h-full" suppressHydrationWarning>
<body className="flex min-h-full antialiased">
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
<div className="w-full">{children}</div>
<SettingsDialog />
<Toaster position="top-right" />
</ThemeProvider>
<NextIntlClientProvider>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
<div className="w-full">{children}</div>
<SettingsDialog />
<Toaster position="top-right" />
</ThemeProvider>
</NextIntlClientProvider>
</body>
</html>
);