Repository Public
1import { cookies, headers } from "next/headers";2import type { Locale } from "@/schema";34export const LOCALE_COOKIE = "sheet_locale";56/** Interface language: the visitor's explicit choice, otherwise French unless the browser asks for English first. */7export async function getLocale(): Promise<Locale> {8 const chosen = (await cookies()).get(LOCALE_COOKIE)?.value;9 if (chosen === "fr" || chosen === "en") return chosen;10 const first = ((await headers()).get("accept-language") ?? "").split(",")[0]?.trim().toLowerCase() ?? "";11 return first.startsWith("en") ? "en" : "fr";12}13