Initial frontend import

This commit is contained in:
TerryM
2026-05-16 00:18:22 +08:00
commit 9c54ffec76
99 changed files with 14992 additions and 0 deletions

49
src/resourceTypeLabels.ts Normal file
View File

@@ -0,0 +1,49 @@
/** 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-TW, en, …). */
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();
}