Files
vibe_coding/.cursor/rules/skill-i18n.mdc
2026-03-05 21:27:11 +08:00

46 lines
1.3 KiB
Plaintext
Raw Permalink 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.
---
description: >
国际化技能。当需要添加多语言支持、翻译内容、管理语言包
或配置 vue-i18n 国际化时激活。含键命名规范和路由国际化。
alwaysApply: false
---
# Internationalization (i18n)
> 本文件是精简执行摘要。完整流程、模板和深度参考见:
> Read `.cursor/skills/i18n/SKILL.md`
## 执行流程
1. 检测现有 i18n 方案(`vue-i18n` 是否已安装)
2. 初始化(如未配置):`npm install vue-i18n@9`,创建 `src/locales/` 目录
3. 配置 i18n 实例(`legacy: false`、fallbackLocale、localStorage 持久化)
4. 翻译键命名:使用扁平 dot notation `{feature}.{context}.{action|status|label}`
5. 组件中使用 `useI18n()` 的 `t()` 函数
6. 管理端同步 Element Plus locale用户端不适用
7. 添加新语言时确保所有 key 一致
## 键命名公式
`{feature}.{context}.{action|status|label}`
```typescript
'order.list.title': '订单列表',
'order.form.submit': '提交订单',
'common.action.save': '保存',
```
## 标准命名空间
common | auth | menu | validation | error | {module}
新增命名空间时必须登记。
## 验证
- [ ] 所有 locale 文件的 key 结构一致
- [ ] 切换语言后页面正确翻译
- [ ] 键命名遵循公式
- [ ] 使用扁平 dot notation
- [ ] 无键冲突