/* Locale definitions. Single source for locale codes, html lang, and labels. */

export const LOCALES = ['en', 'no'] as const;
export type Locale = (typeof LOCALES)[number];

export const DEFAULT_LOCALE: Locale = 'en';

/** `<html lang>` value per locale (I18N_SPEC §5). */
export const HTML_LANG: Record<Locale, string> = {
  en: 'en-GB',
  no: 'nb-NO',
};

/** hreflang code per locale (used in alternates + sitemap). */
export const HREFLANG: Record<Locale, string> = {
  en: 'en',
  no: 'nb',
};

/** OpenGraph locale (SEO_SPEC §4). */
export const OG_LOCALE: Record<Locale, string> = {
  en: 'en_GB',
  no: 'nb_NO',
};

/** Human label for the switch control, written in the *target* language. */
export const LOCALE_LABEL: Record<Locale, string> = {
  en: 'EN',
  no: 'NO',
};

export function isLocale(value: string): value is Locale {
  return (LOCALES as readonly string[]).includes(value);
}

export function otherLocale(locale: Locale): Locale {
  return locale === 'en' ? 'no' : 'en';
}
