judge4c/src/app/[locale]/layout.tsx
2025-06-18 15:51:03 +08:00

38 lines
890 B
TypeScript

import { NextIntlClientProvider } from 'next-intl';
import { notFound } from 'next/navigation';
import type { Metadata } from 'next';
export const metadata: Metadata = {
title: 'Judge4C',
description: 'Online Judge System',
};
export function generateStaticParams() {
return [{ locale: 'en' }, { locale: 'zh' }];
}
export default async function LocaleLayout({
children,
params
}: {
children: React.ReactNode;
params: { locale: string };
}) {
const { locale } = await params;
let messages;
try {
messages = (await import(`../../../messages/${locale}.json`)).default;
} catch (error) {
notFound();
}
return (
<html lang={locale} suppressHydrationWarning>
<body suppressHydrationWarning>
<NextIntlClientProvider locale={locale} messages={messages}>
{children}
</NextIntlClientProvider>
</body>
</html>
);
}