import type { Locale } from "@/i18n/routes";
import { isLocale, defaultLocale } from "@/i18n/routes";
import { headers } from "next/headers";

export async function localeFromHeaders(): Promise<Locale> {
  const h = await headers();
  const v = h.get("x-locale");
  return v && isLocale(v) ? v : defaultLocale;
}
