Completes full internationalization coverage for the webmail application with enhanced language support: - Replace all remaining hardcoded English strings with translation keys - Add timezone auto-detection to prevent hydration mismatches - Enable instant client-side language switching without page reload - Add 60+ new translation keys in English and French locales - Improve language switcher component with proper state management - Add health check endpoint for container orchestration All user-facing text now supports English and French with no hardcoded fallbacks, providing a fully localized experience.
78 lines
2.3 KiB
TypeScript
78 lines
2.3 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { Geist, Geist_Mono } from "next/font/google";
|
|
import { notFound } from "next/navigation";
|
|
import { IntlProvider } from "@/components/providers/intl-provider";
|
|
import { ThemeProvider } from "@/components/providers/theme-provider";
|
|
import { locales } from "@/i18n/routing";
|
|
import "../globals.css";
|
|
|
|
const geistSans = Geist({
|
|
variable: "--font-geist-sans",
|
|
subsets: ["latin"],
|
|
});
|
|
|
|
const geistMono = Geist_Mono({
|
|
variable: "--font-geist-mono",
|
|
subsets: ["latin"],
|
|
});
|
|
|
|
export const metadata: Metadata = {
|
|
title: "JMAP Webmail",
|
|
description: "Minimalist webmail client using JMAP protocol",
|
|
};
|
|
|
|
export default async function LocaleLayout({
|
|
children,
|
|
params
|
|
}: {
|
|
children: React.ReactNode;
|
|
params: Promise<{ locale: string }>;
|
|
}) {
|
|
const { locale } = await params;
|
|
|
|
// Validate that the incoming `locale` parameter is valid
|
|
if (!(locales as readonly string[]).includes(locale)) notFound();
|
|
|
|
// Load messages for the current locale
|
|
let messages;
|
|
try {
|
|
messages = (await import(`@/locales/${locale}/common.json`)).default;
|
|
} catch {
|
|
notFound();
|
|
}
|
|
|
|
return (
|
|
<html lang={locale} suppressHydrationWarning>
|
|
<head>
|
|
<script
|
|
dangerouslySetInnerHTML={{
|
|
__html: `
|
|
(function() {
|
|
try {
|
|
const stored = localStorage.getItem('theme-storage');
|
|
const theme = stored ? JSON.parse(stored).state.theme : 'system';
|
|
const systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
const resolved = theme === 'system' ? systemTheme : theme;
|
|
document.documentElement.classList.remove('light', 'dark');
|
|
document.documentElement.classList.add(resolved);
|
|
} catch (e) {
|
|
document.documentElement.classList.add('light');
|
|
}
|
|
})();
|
|
`,
|
|
}}
|
|
/>
|
|
</head>
|
|
<body
|
|
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
|
>
|
|
<IntlProvider locale={locale} messages={messages}>
|
|
<ThemeProvider>
|
|
{children}
|
|
</ThemeProvider>
|
|
</IntlProvider>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|