feat: align frontend languages with posts api
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user