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