Stats
Actions
Tags
How this skill is triggered — by the user, by Claude, or both
Slash command
/i18n-vue:i18n-replaceThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
---
执行此 skill 时,你是一个 i18n 替换执行者,负责运行替换脚本将中文文本包裹为 i18n 标记。
扫描项目文件,自动替换中文文本为 i18n 标记,然后将中文 key 写入语言 JSON(翻译值留空)。
支持两种项目类型:
.vue 文件 → $t() / {{ $t() }}.html/.js/.ts 文件 → window.$t() / data-i18n 属性.wxml/.js 文件 → global.$t() / {{$t['key']}},自动注入 Behavior/i18n-replace [目标路径] [--lang 语言] [--dry-run]
| 参数 | 说明 | 默认值 |
|---|---|---|
| 目标路径 | 要扫描的目录或文件 | vue: ./src,browser: ./ |
| --i18n-dir | i18n 目录路径 | vue: ./src/i18n,browser: ./i18n |
| --lang | 目标语言 | tw |
| --dry-run | 只预览,不修改 | - |
package.json 且依赖包含 vue → Vue 项目Vue 项目:
node <skill-directory>/vue-i18n-replace.js <目标路径> --i18n-dir <i18n-dir> --lang <语言>
静态 HTML/JS 项目:
node <skill-directory>/html-i18n-replace.js <目标路径> --i18n-dir <i18n-dir> --lang <语言>
| 场景 | 处理方式 |
|---|---|
script 字符串 "中文" | → window.$t("中文")(始终使用 window. 前缀) |
template 文本 <div>中文</div> | → <div>{{ $t("中文") }}</div> |
template 属性 placeholder="请输入" | → :placeholder="$t('请输入')" |
动态属性 :title="'标题'" | → :title="$t('标题')" |
模板字符串 `你好${name}` | → window.$t('你好{name}', { 'name': name }) |
| 场景 | 处理方式 |
|---|---|
JS 字符串 "中文" | → window.$t("中文") |
HTML 标签文本 <div>中文</div> | → <div data-i18n="中文">中文</div> |
HTML 属性 placeholder="请输入" | → placeholder="请输入" data-i18n-placeholder="请输入" |
<script> 内的 JS 代码 | 同 JS 字符串处理 |
| 场景 | 替换前 | 替换后 |
|---|---|---|
| WXML 文本 | <text>中文</text> | <text>{{$t['中文']}}</text> |
| WXML 属性 | placeholder="中文" | placeholder="{{$t['中文']}}" |
| JS 代码 | '中文' | global.$t('中文') |
使用方式:
node skills/i18n-replace/wx-i18n-replace.js ./pages --i18n-dir ./i18n --lang tw
通用:
$t() / data-i18n 标记的文本=== !== 等)Vue 特有:v-if、v-show 中的字符串,class/id/name/key/ref/style 属性
HTML 特有:class/id/name/style/type/href/src/action 属性,on* 事件属性,void 元素
替换完成后,运行验证脚本检查高危模式和翻译质量:
# 全量扫描(代码 + 翻译质量)
node skills/i18n-replace/i18n-validate.js <directory> --type <vue|html> --i18n-dir <path> --lang <lang>
# 仅翻译质量
node skills/i18n-replace/i18n-validate.js <directory> --check-translation --i18n-dir <path> --lang <lang>
# 检查 JSON 可疑条目
node skills/i18n-replace/i18n-validate.js <directory> --check-json --i18n-dir <path> --lang <lang>
# 自动修复裸 $t()
node skills/i18n-replace/i18n-validate.js <directory> --fix
退出码:0 = 全部通过,1 = 存在严重/高危问题。
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub chyelong/i18n-vue-plugin --plugin i18n-vue