diff --git a/.prettierignore b/.prettierignore index d33ba99..92dc1d9 100644 --- a/.prettierignore +++ b/.prettierignore @@ -14,4 +14,3 @@ junit.xml docs public bun.lockb -locales diff --git a/actions/language.ts b/actions/language.ts new file mode 100644 index 0000000..d02b57b --- /dev/null +++ b/actions/language.ts @@ -0,0 +1,13 @@ +"use server"; + +import { cookies } from "next/headers"; + +export async function setLanguage(value: string) { + const cookieStore = await cookies(); + cookieStore.set("locale", value); +} + +export async function getLanguage() { + const cookieStore = await cookies(); + return cookieStore.get("locale")?.value || "en"; +} diff --git a/app/layout.tsx b/app/layout.tsx index 8e755a8..2fd7a80 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -3,6 +3,8 @@ import { Inter } from "next/font/google"; import "./globals.css"; import { ThemeProvider } from "next-themes"; import { GoogleTagManager } from "@next/third-parties/google"; +import { NextIntlClientProvider } from "next-intl"; +import { getLocale, getMessages } from "next-intl/server"; const inter = Inter({ subsets: ["latin"], @@ -14,20 +16,26 @@ export const metadata: Metadata = { description: "Redot Engine: Open source game engine for everyone.", }; -export default function RootLayout({ +export default async function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { + const locale = await getLocale(); + + const messages = await getMessages(); + return ( - +
+ {t("description")} +
+