/**
 * RRYM / 002 — SULSYS
 * Locales. Four parallel trees: /sq, /mk, /tr, /en.
 *
 * Albanian and Macedonian are the two languages the business is actually
 * conducted in — they come first, and Albanian remains the default because it
 * is the language of the company's own town. Turkish is the third language of
 * the region Sulsys serves. English is for everyone else who arrives.
 *
 * The order of this array is the order of the language switch, so it is the
 * order a reader sees. It is not alphabetical on purpose.
 */

export const LOCALES = ["sq", "mk", "tr", "en"] as const;

export type Locale = (typeof LOCALES)[number];

export const DEFAULT_LOCALE: Locale = "sq";

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

/**
 * `lang` / `hreflang` attribute values.
 *
 * Plain subtags rather than region-qualified ones. "sq-AL" would be a claim
 * about Albania and "en-GB" a claim about Britain; this site is written in
 * North Macedonia for a regional audience, and the bare language tag is the
 * honest answer for all four.
 */
export const HTML_LANG: Record<Locale, string> = {
  sq: "sq",
  mk: "mk",
  tr: "tr",
  en: "en",
};

/**
 * OpenGraph wants a region, and unlike `hreflang` it has no neutral form. The
 * country chosen is the one the language is being spoken *from* where that is
 * meaningful — Macedonian and Turkish-in-Macedonia are both MK — and the
 * conventional default otherwise.
 */
export const OG_LOCALE: Record<Locale, string> = {
  sq: "sq_AL",
  mk: "mk_MK",
  tr: "tr_TR",
  en: "en_US",
};

/** Label shown in the language switch. Each locale names itself. */
export const LOCALE_LABEL: Record<Locale, string> = {
  sq: "SQ",
  mk: "MK",
  tr: "TR",
  en: "EN",
};

/** The language's own name for itself, for the switch's accessible names. */
export const LOCALE_NAME: Record<Locale, string> = {
  sq: "Shqip",
  mk: "Македонски",
  tr: "Türkçe",
  en: "English",
};

/**
 * Accept-Language subtags that should land on each locale.
 *
 * "al" is not a language code — it is the country code for Albania — but it
 * turns up in the wild often enough in hand-rolled Accept-Language headers to
 * be worth accepting. "sh", "hr", "sr", "bs" are not mapped: a Serbo-Croatian
 * speaker is better served by the Macedonian tree than by a guess, and the
 * fallthrough already sends them somewhere readable.
 */
export const LOCALE_ALIASES: Record<string, Locale> = {
  sq: "sq",
  al: "sq",
  mk: "mk",
  tr: "tr",
  en: "en",
};
