export const UI_LANGUAGE_OPTIONS = [
  { value: "en", label: "English", nativeName: "English" },
  { value: "am", label: "አማርኛ", nativeName: "Amharic" },
  { value: "fr", label: "Français", nativeName: "French" },
] as const;

export type UiLanguageCode = (typeof UI_LANGUAGE_OPTIONS)[number]["value"];

export function resolveUiLanguage(language?: string | null): UiLanguageCode {
  if (!language) return "en";
  if (language.startsWith("am")) return "am";
  if (language.startsWith("fr")) return "fr";
  return "en";
}

export function getUiLanguageLabel(
  language: UiLanguageCode,
  t: (key: string) => string,
): string {
  switch (language) {
    case "am":
      return t("header.amharic");
    case "fr":
      return t("header.french");
    default:
      return t("header.english");
  }
}

export function getUiLanguageShortLabel(
  language: UiLanguageCode,
  t: (key: string) => string,
): string {
  switch (language) {
    case "am":
      return t("header.amharicShort");
    case "fr":
      return t("header.frenchShort");
    default:
      return t("header.englishShort");
  }
}
