auto translation setup
This commit is contained in:
+25
-16
@@ -1,5 +1,7 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import { Playfair_Display, Inter } from "next/font/google";
|
import { Playfair_Display, Inter } from "next/font/google";
|
||||||
|
import { NextIntlClientProvider } from "next-intl";
|
||||||
|
import { getMessages } from 'next-intl/server';
|
||||||
|
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
|
|
||||||
@@ -22,27 +24,34 @@ export const metadata: Metadata = {
|
|||||||
description: "Portfolio de Mathéo Guilbert, développeur web freelance.",
|
description: "Portfolio de Mathéo Guilbert, développeur web freelance.",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({
|
export default async function RootLayout({
|
||||||
children,
|
children,
|
||||||
}: Readonly<{
|
params,
|
||||||
children: React.ReactNode;
|
}: {
|
||||||
}>) {
|
children: React.ReactNode;
|
||||||
|
params: Promise<{ locale: string }>;
|
||||||
|
}) {
|
||||||
|
const { locale } = await params;
|
||||||
|
const messages = await getMessages();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang="fr" className={`${playfairDisplay.variable} ${inter.variable} bg-brand-beige overflow-hidden antialiased`}>
|
<html lang={locale} className={`${playfairDisplay.variable} ${inter.variable} bg-brand-beige overflow-hidden antialiased`}>
|
||||||
|
|
||||||
<body className="h-screen w-screen bg-brand-beige text-brand-brown flex flex-col overflow-hidden">
|
<body className="h-screen w-screen bg-brand-beige text-brand-brown flex flex-col overflow-hidden">
|
||||||
<div className="sticky top-0 z-50 bg-brand-beige w-full px-2.75 pt-2.75">
|
<NextIntlClientProvider messages={messages}>
|
||||||
<Header />
|
<div className="sticky top-0 z-50 bg-brand-beige w-full px-2.75 pt-2.75">
|
||||||
</div>
|
<Header />
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Scrolling bloc */}
|
{/* Scrolling bloc */}
|
||||||
<CustomScrollArea>
|
<CustomScrollArea>
|
||||||
<main className="px-2.75 pb-2.75">
|
<main className="px-2.75 pb-2.75">
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<Footer />
|
<Footer />
|
||||||
</CustomScrollArea>
|
</CustomScrollArea>
|
||||||
|
</NextIntlClientProvider>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { getRequestConfig } from 'next-intl/server';
|
||||||
|
import { notFound } from 'next/navigation';
|
||||||
|
|
||||||
|
const locales = ['fr', 'en'];
|
||||||
|
|
||||||
|
export default getRequestConfig(async ({ requestLocale }) => {
|
||||||
|
const locale = await requestLocale;
|
||||||
|
|
||||||
|
if (!locale || !locales.includes(locale)) notFound();
|
||||||
|
|
||||||
|
return {
|
||||||
|
locale,
|
||||||
|
messages: (await import(`./messages/${locale}.json`)).default
|
||||||
|
};
|
||||||
|
});
|
||||||
+4
-1
@@ -1,7 +1,10 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
import createNextIntlPlugin from 'next-intl/plugin';
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
/* config options here */
|
/* config options here */
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
const withNextIntl = createNextIntlPlugin('./i18n.ts');
|
||||||
|
|
||||||
|
export default withNextIntl(nextConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user