← ClaudeAtlas

i18n-helperlisted

【国际化】设计和实现国际化(i18n)方案,包含翻译文件结构、动态语言切换、复数处理、日期/数字格式化。 触发时机: - 用户要求"国际化"、"多语言支持"、"i18n" - 项目需要支持多种语言 - 需要从代码中提取翻译文本 支持前端(React/Vue)和后端(Python/Node)国际化方案。
afine907/skills · ★ 0 · AI & Automation · score 75
Install: claude install-skill afine907/skills
# i18n Helper — 国际化助手 设计完整的国际化方案,支持多语言、多地区适配。 ## Goal 设计和实现国际化(i18n)方案,包含翻译文件结构、动态语言切换、复数处理、日期/数字格式化 ## Trigger - 用户要求"国际化"、"多语言支持"、"i18n" - 项目需要支持多种语言 - 需要从代码中提取翻译文本 ## 技术选型 | 框架 | 库 | 特点 | |------|-----|------| | React | react-i18next | Hook API、丰富功能 | | Vue | vue-i18n | Vue 3 原生支持 | | Python | babel + gettext | 标准方案 | | Node.js | i18next | 跨平台、插件丰富 | ## 翻译文件结构 ### 目录结构 ``` locales/ ├── zh-CN/ │ ├── common.json # 通用翻译 │ ├── auth.json # 认证模块 │ ├── order.json # 订单模块 │ └── index.ts ├── en-US/ │ ├── common.json │ ├── auth.json │ ├── order.json │ └── index.ts └── index.ts ``` ### 翻译文件格式 ```json { "common": { "ok": "确定", "cancel": "取消", "save": "保存", "delete": "删除", "edit": "编辑", "loading": "加载中...", "noData": "暂无数据", "error": "出错了", "success": "操作成功" }, "auth": { "login": "登录", "logout": "退出登录", "register": "注册", "forgotPassword": "忘记密码", "email": "邮箱", "password": "密码", "loginSuccess": "登录成功", "loginFailed": "登录失败" }, "order": { "create": "创建订单", "list": "订单列表", "detail": "订单详情", "status": { "pending": "待支付", "paid": "已支付", "shipped": "已发货", "completed": "已完成", "cancelled": "已取消" }, "count": "共 {{count}} 个订单", "total": "总计: {{amount, currency}}" } } ``` ## React + react-i18next 实现 ### 配置 ```ty