Files
thebet365/packages/shared/src/locale.ts
Mars cbfa18d1d3 feat(i18n): 管理端与玩家端三语支持(中/英/马来语)
- 管理后台 adminT 文案库、结算与代理端页面、表单校验
- 玩家端 vue-i18n 补全首页/公告/串关与 ms 文案
- Element Plus ms 语言包与共享 locale 工具
2026-06-03 15:05:36 +08:00

29 lines
870 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** 内容翻译 fallback当前语言 → 英文 → 中文 */
export function resolveTranslationFallback(
map: Record<string, string | undefined | null>,
locale: string,
): string {
const chain = [locale, 'en-US', 'zh-CN'];
const seen = new Set<string>();
for (const loc of chain) {
if (seen.has(loc)) continue;
seen.add(loc);
const v = map[loc];
if (v != null && String(v).trim() !== '') return String(v).trim();
}
for (const v of Object.values(map)) {
if (v != null && String(v).trim() !== '') return String(v).trim();
}
return '';
}
/** 前台语言显示名PRD 3.1 */
export const LOCALE_UI_LABELS: Record<string, string> = {
'zh-CN': '中文',
'ms-MY': 'Bahasa Melayu',
'en-US': 'English',
};
/** vue-i18n 缺 key 时en-US → zh-CN */
export const VUE_I18N_FALLBACK_LOCALES = ['en-US', 'zh-CN'] as const;