60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
|
|
import { NextIntlClientProvider } from "next-intl";
|
||
|
|
import { getMessages, setRequestLocale } from "next-intl/server";
|
||
|
|
import { notFound } from "next/navigation";
|
||
|
|
import localFont from "next/font/local";
|
||
|
|
import { routing } from "@/i18n/routing";
|
||
|
|
import { Providers } from "@/components/providers";
|
||
|
|
import "../globals.css";
|
||
|
|
|
||
|
|
const vazirmatn = localFont({
|
||
|
|
src: "../../fonts/Vazirmatn-Variable.woff2",
|
||
|
|
variable: "--font-vazirmatn",
|
||
|
|
display: "swap",
|
||
|
|
weight: "100 900",
|
||
|
|
});
|
||
|
|
|
||
|
|
const inter = localFont({
|
||
|
|
src: "../../fonts/Inter-Variable.woff2",
|
||
|
|
variable: "--font-inter",
|
||
|
|
display: "swap",
|
||
|
|
weight: "100 900",
|
||
|
|
});
|
||
|
|
|
||
|
|
export function generateStaticParams() {
|
||
|
|
return routing.locales.map((locale) => ({ locale }));
|
||
|
|
}
|
||
|
|
|
||
|
|
export default async function LocaleLayout({
|
||
|
|
children,
|
||
|
|
params: { locale },
|
||
|
|
}: {
|
||
|
|
children: React.ReactNode;
|
||
|
|
params: { locale: string };
|
||
|
|
}) {
|
||
|
|
if (!routing.locales.includes(locale as "fa" | "ar" | "en")) {
|
||
|
|
notFound();
|
||
|
|
}
|
||
|
|
|
||
|
|
setRequestLocale(locale);
|
||
|
|
const messages = await getMessages();
|
||
|
|
const dir = locale === "en" ? "ltr" : "rtl";
|
||
|
|
const fontClass =
|
||
|
|
locale === "en"
|
||
|
|
? inter.variable
|
||
|
|
: vazirmatn.variable;
|
||
|
|
|
||
|
|
return (
|
||
|
|
<html lang={locale} dir={dir}>
|
||
|
|
<body
|
||
|
|
className={`${fontClass} font-sans antialiased ${
|
||
|
|
locale === "en" ? "font-[family-name:var(--font-inter)]" : "font-[family-name:var(--font-vazirmatn)]"
|
||
|
|
}`}
|
||
|
|
>
|
||
|
|
<NextIntlClientProvider messages={messages}>
|
||
|
|
<Providers>{children}</Providers>
|
||
|
|
</NextIntlClientProvider>
|
||
|
|
</body>
|
||
|
|
</html>
|
||
|
|
);
|
||
|
|
}
|