Files
ai_academy/frontend/src/i18n/auditActionLabel.ts
T
runny 7ec21f35b0 chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、
Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。
今日开发的培训推送管理改动随后单独提交。
2026-11-16 18:12:23 +08:00

23 lines
717 B
TypeScript

import type { Composer } from 'vue-i18n'
import type { FlatKeyBagPath } from './auditActionRegistry.ts'
/**
* Resolve a dot-namespaced audit action to its localized label.
*
* Uses `tm(root)` + flat key lookup because action strings such as
* `rbac.member_added` must not be passed to `t()` — vue-i18n would split on
* every dot and expect a nested object tree.
*/
export function auditActionLabel(
i18n: Pick<Composer, 'tm'>,
root: FlatKeyBagPath,
action: string,
): string {
const bag = i18n.tm(root) as unknown
if (bag !== null && typeof bag === 'object' && typeof (bag as Record<string, string>)[action] === 'string') {
return (bag as Record<string, string>)[action]
}
return action
}