关于 skill-i18n
skill-i18n 是用于翻译技能文档的技能,可将 SKILL.md、README.md 等文件生成多语言版本。它支持按技能配置语言与文件,并可通过命令行参数集成到自动化流程中。
主要功能
- 01翻译 SKILL.md 和 README.md
- 02配置默认及单项技能语言
- 03指定目标语言和文件
- 04支持跳过提示与覆盖译文
- 05仅在源文件更新时增量翻译
适用场景
- 01为技能文档生成中文和日文版本
- 02按不同技能设置语言与文件范围
- 03在 share-skill 文档流程中调用翻译
- 04自动化批量处理技能文档
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ guo-yu/ skills --skill skill-i18n安装后在 Claude Code 中输入/skill-i18n确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
.gitignoreSKILL.ja.mdSKILL.zh-CN.md.claude-plugin/plugin.json详细介绍
Skill i18n
将技能文档文件(SKILL.md、README.md)翻译成多种语言,方便与国际用户分享技能。
用法
| 命令 | 说明 |
|---|---|
/skill-i18n | 翻译当前技能目录中的文件 |
/skill-i18n <skill-name> | 翻译指定技能的文件 |
/skill-i18n config | 配置默认语言和文件类型 |
/skill-i18n --lang zh-CN,ja | 翻译成指定语言(用于集成) |
/skill-i18n --files SKILL.md,README.md | 翻译指定文件 |
支持的语言
| 语言 | 代码 | 输出文件 |
|---|---|---|
| 简体中文 | zh-CN | SKILL.zh-CN.md |
| 日语 | ja | SKILL.ja.md |
| 韩语 | ko | SKILL.ko.md |
| 西班牙语 | es | SKILL.es.md |
| 自定义 | 用户定义 | SKILL.<code>.md |
配置
所有设置都存储在 ~/.claude/skill-i18n-config.json 中:
{
"default_languages": ["zh-CN", "ja"],
"default_files": ["SKILL.md"],
"skills_config": {
"port-allocator": {
"languages": ["zh-CN", "ja", "ko"],
"files": ["SKILL.md", "README.md"]
}
}
}
配置字段:
| 字段 | 说明 | 默认值 |
|---|---|---|
default_languages | 默认翻译语言 | ["zh-CN", "ja"] |
default_files | 默认翻译文件 | ["SKILL.md"] |
skills_config | 各技能的配置 | {} |
执行步骤
命令:/skill-i18n
翻译当前技能目录中的文件:
-
检测当前目录
# Check if current directory contains SKILL.md if [ ! -f SKILL.md ]; then echo "Error: SKILL.md not found in current directory" exit 1 fi -
加载配置
# Read config file CONFIG=$(cat ~/.claude/skill-i18n-config.json 2>/dev/null || echo '{}') # Get skill name from directory SKILL_NAME=$(basename "$(pwd)") # Check for skill-specific config SKILL_CONFIG=$(echo "$CONFIG" | jq -r ".skills_config[\"$SKILL_NAME\"] // null") -
首次运行时选择(如果没有配置)
如果此技能没有配置,显示 TUI 选择界面:
{ "questions": [ { "question": "Which languages should be generated?", "header": "Languages", "multiSelect": true, "options": [ { "label": "简体中文 (zh-CN)", "description": "Simplified Chinese" }, { "label": "日本語 (ja)", "description": "Japanese" }, { "label": "한국어 (ko)", "description": "Korean" }, { "label": "Español (es)", "description": "Spanish" } ] }, { "question": "Which files should be translated?", "header": "Files", "multiSelect": true, "options": [ { "label": "SKILL.md", "description": "Skill documentation (recommended)" }, { "label": "README.md", "description": "Repository readme" } ] } ] } -
保存配置
# Save selection to config for future runs jq --arg skill "$SKILL_NAME" \ --argjson langs '["zh-CN", "ja"]' \ --argjson files '["SKILL.md"]' \ '.skills_config[$skill] = {"languages": $langs, "files": $files}' \ ~/.claude/skill-i18n-config.json > tmp.json && mv tmp.json ~/.claude/skill-i18n-config.json -
执行翻译
- 为每个选定的文件和语言生成译文
- 请参阅下文的“翻译规则”部分
命令:/skill-i18n <skill-name>
翻译指定技能的文件:
-
搜索技能位置
# Search in common locations SKILL_PATH="" # Check ~/.claude/skills/ if [ -d ~/.claude/skills/"$SKILL_NAME" ]; then SKILL_PATH=~/.claude/skills/"$SKILL_NAME" fi # Check code repository (if configured) if [ -z "$SKILL_PATH" ] && [ -d ~/Codes/skills/"$SKILL_NAME" ]; then SKILL_PATH=~/Codes/skills/"$SKILL_NAME" fi if [ -z "$SKILL_PATH" ]; then echo "Error: Skill '$SKILL_NAME' not found" exit 1 fi -
执行翻译(与默认命令相同)
命令:/skill-i18n config
配置默认设置:
-
显示当前配置
echo "Current configuration:" cat ~/.claude/skill-i18n-config.json | jq . -
通过 AskUserQuestion 交互式配置
{ "questions": [ { "question": "Select default languages for new skills:", "header": "Defaults", "multiSelect": true, "options": [ { "label": "简体中文 (zh-CN)", "description": "Simplified Chinese" }, { "label": "日本語 (ja)", "description": "Japanese" }, { "label": "한국어 (ko)", "description": "Korean" }, { "label": "Español (es)", "description": "Spanish" } ] } ] } -
更新配置文件
命令行标志
用于与其他技能(例如 share-skill)集成:
| 标志 | 说明 | 示例 |
|---|---|---|
--lang <codes> | 以逗号分隔的语言代码 | --lang zh-CN,ja,ko |
--files <names> | 以逗号分隔的文件名 | --files SKILL.md,README.md |
--skill <name> | 目标技能名称 | --skill port-allocator |
--no-prompt | 跳过 TUI,直接使用标志或配置 | 用于自动化工作流 |
--overwrite | 覆盖现有译文 | 跳过确认 |
优先级顺序:
- 命令行标志(最高优先级)
skills_config中针对特定技能的配置- 全局
default_languages和default_files - 交互式 TUI 选择(如果没有配置)
集成示例:
# share-skill calls skill-i18n internally
/skill-i18n --lang zh-CN,ja --files SKILL.md --skill port-allocator --no-prompt
翻译规则
保持不变
以下元素不得翻译:
- 代码块(
bash、json 等) - 文件路径(
~/.claude/settings.json、~/Codes/skills/) - 命令名称(
/port-allocator、/skill-i18n、git push) - 技术标识符(变量名、JSON 键)
- URL 和链接
自然翻译
- 根据目标语言调整句式结构
- 使用恰当的正式程度:
- 日语:礼貌体(です/ます)
- 中文:规范书面语
- 韩语:礼貌体(합니다/습니다)
- 西班牙语:正式 usted 语体
- 在适当情况下将示例本地化
Frontmatter 处理
---
name: port-allocator # Keep unchanged (identifier)
description: Translate this # Translate to target language
---
风格调整
不同语言可以采用不同的视觉风格:
| 语言 | Emoji 用法 | 示例 |
|---|---|---|
| 中文(zh-CN) | 常见 | ✅ 正确 / ❌ 错误 |
| 日语(ja) | 尽量少用 | 正しい / 間違い |
| 韩语(ko) | 适度使用 | ✅ 올바름 / ❌ 잘못됨 |
| 西班牙语(es) | 尽量少用 | Correcto / Incorrecto |
如果项目中已有翻译示例,请遵循现有风格。
输出格式
翻译成功
Translation complete
Skill: port-allocator
Source: SKILL.md
Generated:
- SKILL.zh-CN.md (简体中文)
- SKILL.ja.md (日本語)
Config saved for: port-allocator
Next run will auto-translate to: zh-CN, ja
检测到现有文件
Existing translations detected:
- SKILL.zh-CN.md (modified 2 days ago)
- SKILL.ja.md (modified 2 days ago)
Options:
[ ] Overwrite all
[ ] Skip existing
[ ] Select individually
配置已保存
Configuration updated
Default languages: zh-CN, ja
Default files: SKILL.md
Skill-specific config:
port-allocator: zh-CN, ja, ko (SKILL.md, README.md)
share-skill: zh-CN, ja (SKILL.md)
与 share-skill 集成
skill-i18n 与 share-skill 集成,用于生成文档:
# share-skill docs with i18n
/share-skill docs --i18n
# This internally calls:
/skill-i18n --lang <configured-langs> --files SKILL.md --no-prompt
当 share-skill 检测到 --i18n 标志时:
- 检查 skill-i18n 是否可用
- 加载语言配置
- 调用 skill-i18n 生成译文
- 将翻译后的文件纳入文档网站
注意事项
- 源文件安全 - 切勿覆盖源
SKILL.md文件 - 首次运行提示 - 首次翻译需要选择语言
- 按技能配置 - 不同技能可以使用不同的语言设置
- 增量更新 - 仅当源文件比译文更新时才进行翻译
- 便于集成 - 命令行标志允许其他技能调用 skill-i18n
评论
支持 Markdown