Skip to content
i18n-helper logo

🌍 i18n-helper — 国际化/本地化助手

i18n-helper

国际化/本地化助手 — 扫描代码中的硬编码文本、生成 i18n 配置、批量翻译

SKILL.md

Full skill instructions

🌍 i18n-helper — 国际化/本地化助手

触发条件

当用户要求以下操作时激活此技能:

  • 扫描代码中的硬编码中文/英文文本
  • 为项目添加国际化支持(i18n)
  • 批量提取和翻译语言文件
  • 检查翻译完整性(缺失 key 检测)

工作流程

1. 项目分析

  • 检测项目类型(React/​Vue/​Angular/​Node.js/​Python/​Java 等)
  • 识别已使用的 i18n 框架(react-intl, vue-i18n, i18next, gettext 等)
  • 扫描源代码目录结构

2. 硬编码文本扫描

  • 在 .js/​.jsx/​.ts/​.tsx/​.vue/​.py/​.java/​.go 等文件中搜索硬编码字符串
  • 排除:变量名、URL、正则表达式、import 路径、日志调试信息
  • 标记:用户可见的 UI 文本、错误提示、通知消息

3. 语言文件生成

根据项目框架生成对应格式:

  • JSON (i18next/​react-intl): { "key": "value" }
  • YAML (vue-i18n): key: value
  • PO/​POT (gettext): 标准格式
  • Properties (Java): key=value

4. 代码替换

  • 将硬编码文本替换为 i18n 函数调用
  • 保持原有格式和变量插值
  • 示例:
    // 替换前
    alert('保存成功');
    // 替换后
    alert(t('alert.saveSuccess'));
    

5. 完整性检查

  • 对比主语言文件与翻译文件的 key 差异
  • 输出缺失翻译的 key 列表
  • 统计翻译完成度百分比

输出格式

## 📊 i18n 扫描报告

### 硬编码文本
| 文件 | 行号 | 内容 | 建议 key |
|------|------|------|----------|
| src/​App.tsx | 42 | '欢迎使用' | page.welcome |

### 语言文件
已生成 `locales/​zh-CN.json` 和 `locales/​en-US.json`

### 翻译完整性
- zh-CN: 45/​45 (100%) ✅
- en-US: 42/​45 (93.3%) ⚠️ 缺少 3 个 key

支持的 i18n 框架

  • react-intl / FormatJS
  • vue-i18n
  • i18next / react-i18next / next-i18next
  • Angular @ngx-translate
  • Python gettext / Flask-Babel
  • Java ResourceBundle / Spring MessageSource
  • Go go-i18n

注意事项

  • 不要翻译技术术语(API、SDK、HTTP 等)
  • 保留变量占位符 {name} {{count}} %s 等格式
  • 复数形式和性别变体需要特殊处理
  • 日期、数字、货币格式需使用 locale 感知的格式化函数

More skills from laolaoshiren

test-generator logo
laolaoshiren/claude-code-skills-zh

test-generator

自动生成单元测试:识别函数逻辑、覆盖边界条件、生成可运行测试代码

876 0
View
git-workflow logo
laolaoshiren/claude-code-skills-zh

git-workflow

Git 工作流自动化 - 智能分支管理、提交信息生成、PR 创建

876 0
View
db-migrator logo
laolaoshiren/claude-code-skills-zh

db-migrator

数据库迁移助手 - Schema 对比、迁移脚本生成

876 0
View
zh-code-reviewer logo
laolaoshiren/claude-code-skills-zh

zh-code-reviewer

中文代码审查专家 - 生成详细的中文代码审查报告

876 0
View
log-analyzer logo
laolaoshiren/claude-code-skills-zh

log-analyzer

日志分析助手 — 智能解析日志文件,识别异常模式,定位问题根因

876 0
View
github-actions-gen logo
laolaoshiren/claude-code-skills-zh

github-actions-gen

GitHub Actions CI/CD 流水线生成器:根据项目技术栈自动创建 workflows

876 0
View
error-translator logo
laolaoshiren/claude-code-skills-zh

error-translator

编程错误消息翻译专家 — 将英文错误消息翻译成中文,解释原因并提供修复方案

876 0
View
zh-docgen logo
laolaoshiren/claude-code-skills-zh

zh-docgen

中文文档生成器 - 从代码库自动生成中文技术文档

876 0
View
api-tester logo
laolaoshiren/claude-code-skills-zh

api-tester

API 自动化测试 - OpenAPI 解析、测试用例生成、集成测试

876 0
View
security-audit logo
laolaoshiren/claude-code-skills-zh

security-audit

代码安全审计 - 漏洞扫描、依赖检查、安全最佳实践

876 0
View
eslint-fix logo
laolaoshiren/claude-code-skills-zh

eslint-fix

ESLint 自动修复专家 — 识别 ESLint 报错,批量修复,支持常见规则和自定义配置

876 0
View
env-manager logo
laolaoshiren/claude-code-skills-zh

env-manager

环境变量管理器:扫描、校验、同步 .env 文件,生成安全配置模板

876 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View