import type { Lang } from "./i18n";

export const LANG_OPTIONS: { code: Lang; label: string }[] = [
  { code: "zh-CN", label: "中文" },
  { code: "en", label: "English" },
  { code: "ja", label: "日本語" },
  { code: "ko", label: "한국어" },
  { code: "vi", label: "Tiếng Việt" },
  { code: "id", label: "Bahasa Indonesia" },
  { code: "ms", label: "Bahasa Melayu" },
];

export function languageLabel(t: (key: string) => string, code: string) {
  if (!code) return t("filterLanguageAll");
  const key = `lang_${code.replace("-", "_")}`;
  const label = t(key);
  return label === key ? code : label;
}

export function sourceLanguageQuery(code: string) {
  return code === "zh-CN" ? "zh" : code;
}

export function localizationKey(code: string) {
  return code === "zh-CN" || code.startsWith("zh") ? "zh" : code;
}
