import type { Metadata } from "next"; import localFont from "next/font/local"; import "./globals.css"; import { AdminAuthProvider } from "@/app/lib/AdminAuthContext"; import { ThemeProvider } from "@/app/lib/theme"; import { MessagesProvider } from "@/app/lib/i18n/MessagesProvider"; import { LocalesProvider } from "@/app/lib/i18n/LocalesProvider"; import { requestCatalog, requestLocale, getServerT } from "@/app/lib/server/i18n"; import AppShell from "@/app/components/app/AppShell"; // Self-hosted: the CI Docker build has no network access to Google Fonts // (next/font/google fetches at build time). const inter = localFont({ src: "./fonts/inter-latin-wght-normal.woff2", weight: "100 900", variable: "--font-inter", display: "swap", }); const dmSans = localFont({ src: "./fonts/dm-sans-latin-wght-normal.woff2", weight: "100 1000", variable: "--font-dm-sans", display: "swap", }); export async function generateMetadata(): Promise { const t = await getServerT(); return { title: t("BackOfficeMetaTitle"), description: t("LayoutMetaDescription"), }; } // Locale resolution mirrors solvway-customer-portal's app/layout.tsx: the // bb_locale cookie wins when present (set client-side by LocaleSwitcher), // else Accept-Language resolved against the RUNTIME registry codes, else // DEFAULT_LOCALE. The catalog is loaded server-side (version-aware cache, see // lib/server/messages.ts) and handed to every descendant through // MessagesProvider; the runtime locale list (lib/server/locales.ts -> // /api/admin/locales, FALLBACK_LOCALES on failure) goes through // LocalesProvider for the switcher and the /messages per-locale inputs. export default async function RootLayout({ children }: { children: React.ReactNode }) { // Resolution lives in lib/server/i18n.ts so getServerT (server components) can never disagree with it. const [{ locale, locales }, messages] = await Promise.all([requestLocale(), requestCatalog()]); return ( {children} ); }