|
| 1 | +import type { Metadata } from 'next'; |
| 2 | +import localFont from 'next/font/local'; |
| 3 | +import {NextIntlClientProvider} from 'next-intl'; |
| 4 | + |
| 5 | +import '../globals.css'; |
| 6 | +import {notFound} from "next/navigation"; |
| 7 | +import {hasLocale} from "next-intl"; |
| 8 | +import {routing} from "@/i18n/routing"; |
| 9 | + |
| 10 | +const geistSans = localFont({ |
| 11 | + src: '../fonts/GeistVF.woff', |
| 12 | + variable: '--font-geist-sans', |
| 13 | + weight: '100 900', |
| 14 | +}); |
| 15 | +const geistMono = localFont({ |
| 16 | + src: '../fonts/GeistMonoVF.woff', |
| 17 | + variable: '--font-geist-mono', |
| 18 | + weight: '100 900', |
| 19 | +}); |
| 20 | + |
| 21 | +export const metadata: Metadata = { |
| 22 | + title: 'Pydantic forms example app', |
| 23 | + description: 'Generates forms from Pydantic models', |
| 24 | +}; |
| 25 | + |
| 26 | +export default async function RootLayout({ |
| 27 | + children, |
| 28 | + params |
| 29 | +}: Readonly<{ |
| 30 | + children: React.ReactNode; |
| 31 | + params: { locale: string }; |
| 32 | +}>) { |
| 33 | + const {locale} = await params; |
| 34 | + if (!hasLocale(routing.locales, locale)) { |
| 35 | + notFound(); |
| 36 | + } |
| 37 | + |
| 38 | + const messages = (await import(`../../../messages/${locale}.json`)).default; |
| 39 | + |
| 40 | + console.log('locale', locale); |
| 41 | + console.log("MESSAGE HERE", messages); |
| 42 | + |
| 43 | + |
| 44 | + return ( |
| 45 | + <html lang={locale}> |
| 46 | + <body className={`${geistSans.variable} ${geistMono.variable}`}> |
| 47 | + <NextIntlClientProvider locale={locale} messages={messages}> |
| 48 | + {children} |
| 49 | + </NextIntlClientProvider> |
| 50 | + </body> |
| 51 | + </html> |
| 52 | + ); |
| 53 | +} |
0 commit comments