59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import { ReactNode } from 'react';
|
|
import { Inter } from 'next/font/google';
|
|
import { notFound } from "next/navigation";
|
|
import { getTranslations } from "next-intl/server";
|
|
import { Locale, locales } from "@/i18n/locales";
|
|
import { routing } from "@/i18n/routing";
|
|
import { NextIntlClientProvider } from 'next-intl';
|
|
import '../globals.css';
|
|
|
|
const inter = Inter({ subsets: ["latin"] });
|
|
|
|
type Props = {
|
|
children: ReactNode;
|
|
params: Promise<{ locale: Locale }>;
|
|
};
|
|
|
|
export function generateStaticParams() {
|
|
return locales.map((locale) => ({ locale }));
|
|
}
|
|
|
|
export async function generateMetadata({ params }: Omit<Props, 'children'>) {
|
|
// Properly await params before accessing properties
|
|
const { locale } = await params;
|
|
const t = await getTranslations({ locale, namespace: 'LocaleLayout' });
|
|
|
|
return {
|
|
title: t('title')
|
|
};
|
|
}
|
|
|
|
export default async function LocaleLayout({ children, params }: Props) {
|
|
// Properly await params before accessing properties
|
|
const { locale } = await params;
|
|
|
|
// Validate that the incoming locale is valid
|
|
if (!locales.includes(locale as Locale)) {
|
|
notFound();
|
|
}
|
|
|
|
// Load messages for all child components
|
|
const messages = (await import(`@/i18n/${locale}.json`)).default;
|
|
|
|
// Enable static rendering
|
|
// Note: unstable_setRequestLocale is removed as it's causing TypeScript errors
|
|
|
|
return (
|
|
<html lang={locale}>
|
|
<body className={inter.className}>
|
|
<NextIntlClientProvider
|
|
locale={locale}
|
|
messages={messages}
|
|
timeZone="Europe/Istanbul" // Configure a default timezone for Turkey
|
|
>
|
|
{children}
|
|
</NextIntlClientProvider>
|
|
</body>
|
|
</html>
|
|
);
|
|
} |