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 ( - + - {children} + + {children} + diff --git a/app/not-found.tsx b/app/not-found.tsx new file mode 100644 index 0000000..7b6d767 --- /dev/null +++ b/app/not-found.tsx @@ -0,0 +1,42 @@ +import { useTranslations } from "next-intl"; +import { Button } from "@/components/ui/button"; +import Link from "next/link"; +import { Header } from "@/components/header"; +import { Footer } from "@/components/footer"; +import Image from "next/image"; + +export const runtime = "edge"; + +export default function NotFound() { + const t = useTranslations("notFound"); + + return ( +
+
+
+
+
+ Redotchan +
+

+ {t("title")} +

+

+ {t("description")} +

+
+ +
+
+
+
+
+ ); +} diff --git a/bun.lockb b/bun.lockb index 4f93f3d..8a615cf 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/footer.tsx b/components/footer.tsx index 4634be7..247b506 100644 --- a/components/footer.tsx +++ b/components/footer.tsx @@ -7,29 +7,13 @@ import Link from "next/link"; import { Button } from "@/components/ui/button"; import { Separator } from "@/components/ui/separator"; import { socials } from "@/constants/socials"; -import { language } from "@/constants/language"; -import { Check } from "lucide-react"; -import { cn } from "@/lib/utils"; -import { - Command, - CommandEmpty, - CommandGroup, - CommandInput, - CommandItem, - CommandList, -} from "@/components/ui/command"; -import { - Popover, - PopoverContent, - PopoverTrigger, -} from "@/components/ui/popover"; -import { IconChevronDown } from "@tabler/icons-react"; import { links } from "@/constants/links"; import { footer } from "@/constants/footer"; +import { useTranslations } from "next-intl"; +import LanguageSwitcher from "@/components/language-switcher"; export const Footer = () => { - const [open, setOpen] = React.useState(false); - const [value, setValue] = React.useState("en"); + const t = useTranslations("footer"); return (