2026-05-16 00:18:22 +08:00
|
|
|
/** 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;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-26 07:36:53 +08:00
|
|
|
/** Localized label for resource language code (zh, en, ja, ko, vi, id, ms). */
|
2026-05-16 00:18:22 +08:00
|
|
|
export function resourceLanguageLabel(
|
|
|
|
|
t: (key: string) => string,
|
|
|
|
|
langCode: string,
|
|
|
|
|
): string {
|
|
|
|
|
const lc = langCode.trim().toLowerCase();
|
2026-05-26 07:36:53 +08:00
|
|
|
const normalized =
|
|
|
|
|
lc === "zh-cn" || lc === "zh-tw" || lc === "zh-hans" ? "zh" : lc;
|
|
|
|
|
const key = `lang_${normalized}`;
|
|
|
|
|
const label = t(key);
|
|
|
|
|
return label !== key ? label : langCode.trim();
|
2026-05-16 00:18:22 +08:00
|
|
|
}
|