feat(i18n): 管理端与玩家端三语支持(中/英/马来语)
- 管理后台 adminT 文案库、结算与代理端页面、表单校验 - 玩家端 vue-i18n 补全首页/公告/串关与 ms 文案 - Element Plus ms 语言包与共享 locale 工具
This commit is contained in:
16
apps/admin/src/i18n/form-validation.ts
Normal file
16
apps/admin/src/i18n/form-validation.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/** 表单校验错误(key 对应 admin-messages / admin-pages) */
|
||||
export class FormValidationError extends Error {
|
||||
readonly key: string;
|
||||
|
||||
constructor(key: string) {
|
||||
super(key);
|
||||
this.name = 'FormValidationError';
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveFormError(e: unknown, t: (key: string) => string): string {
|
||||
if (e instanceof FormValidationError) return t(e.key);
|
||||
if (e instanceof Error && e.message.startsWith('err.')) return t(e.message);
|
||||
return t('msg.form_invalid');
|
||||
}
|
||||
Reference in New Issue
Block a user