feat: align frontend languages with posts api

This commit is contained in:
TerryM
2026-05-26 07:36:53 +08:00
parent 453abfcec7
commit e7a5952d58
19 changed files with 565 additions and 544 deletions

View File

@@ -27,23 +27,15 @@ export function resourceTypeLabel(
return label !== key ? label : type;
}
/** Localized label for resource `language` code (zh-TW, en, ). */
/** 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 key =
lc === "zh-tw"
? "lang_zh_TW"
: lc === "zh-cn" || lc === "zh-hans"
? "lang_zh_CN"
: lc === "en"
? "lang_en"
: "";
if (key) {
const label = t(key);
if (label !== key) return label;
}
return langCode.trim();
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();
}