// #352 i18n 뼈대 — 로케일 목록/기본값 export const LOCALES = ["ko", "en", "ja", "es"] as const; export type Locale = (typeof LOCALES)[number]; export const DEFAULT_LOCALE: Locale = "ko"; export const LOCALE_STORAGE_KEY = "tasteby_locale"; export const LOCALE_LABELS: Record = { ko: { flag: "🇰🇷", label: "Korean", native: "한국어" }, en: { flag: "🇺🇸", label: "English", native: "English" }, ja: { flag: "🇯🇵", label: "Japanese", native: "日本語" }, es: { flag: "🇪🇸", label: "Spanish", native: "Español" }, }; export function isLocale(value: string | null | undefined): value is Locale { return value != null && (LOCALES as readonly string[]).includes(value); } /** * 브라우저 언어 감지 → 지원 로케일이면 그것, 아니면 기본값. * SSR-safe (typeof window 체크 호출자). */ export function detectBrowserLocale(): Locale { if (typeof navigator === "undefined") return DEFAULT_LOCALE; const code = navigator.language.split("-")[0].toLowerCase(); return isLocale(code) ? code : DEFAULT_LOCALE; }