/** Labels for resource type filter chips (keys match API `type` + `all`). */
export function typeFilterLabel(
  t: (key: string) => string,
  tp: string,
): string {
  if (tp === "all") return t("filterAll");
  return resourceTypeLabel(t, tp);
}

/** Type label without the "all" filter branch (e.g. admin tables). */
export function resourceTypeDisplay(
  t: (key: string) => string,
  type: string,
): string {
  const key = `type_${type}`;
  const label = t(key);
  return label !== key ? label : type;
}

/** Localized label for API resource `type` (image, video, link, …). */
export function resourceTypeLabel(
  t: (key: string) => string,
  type: string,
): string {
  const key = `type_${type}`;
  const label = t(key);
  return label !== key ? label : type;
}

/** Localized label for resource language code (zh, en, ja, ko, vi, id, ms). */
export function resourceLanguageLabel(
  t: (key: string) => string,
  langCode: string,
): string {
  const lc = langCode.trim().toLowerCase();
  const normalized =
    lc === "zh" || lc === "zh-cn" || lc === "zh-tw" || lc === "zh-hans"
      ? "zh-CN"
      : lc;
  const key = `lang_${normalized.replace("-", "_")}`;
  const label = t(key);
  return label !== key ? label : langCode.trim();
}
