diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index 105907983..e8999055b 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -1,10 +1,9 @@ import Footer from 'components/layout/footer/footer'; import Header from 'components/layout/header/header'; -import { NextIntlClientProvider } from 'next-intl'; +import { useLocale } from 'next-intl'; import { Inter } from 'next/font/google'; import { notFound } from 'next/navigation'; import { ReactNode } from 'react'; -import { supportedLanguages } from '../../i18n-config'; import './globals.css'; export const metadata = { @@ -33,34 +32,30 @@ const inter = Inter({ variable: '--font-inter' }); -export function generateStaticParams() { - return supportedLanguages.locales.map((locale) => ({ locale: locale.id })); -} +// export function generateStaticParams() { +// return supportedLanguages.locales.map((locale) => ({ locale: locale.id })); +// } -interface LocaleLayoutProps { +export default function LocaleLayout({ + children, + params +}: { children: ReactNode; - params: { - locale: string; - }; -} + params: { locale: string }; +}) { + const locale = useLocale(); -export default async function LocaleLayout({ children, params: { locale } }: LocaleLayoutProps) { - let messages; - - try { - messages = (await import(`../../messages/${locale}.json`)).default; - } catch (error) { + // Show a 404 error if the user requests an unknown locale + if (params.locale !== locale) { notFound(); } return ( - -
-
{children}
-