Genstore i18n 翻译助手
一个功能强大的 VSCode 扩展,用于在代码中实时显示和管理翻译文本。
✨ 核心功能
🎯 多模式翻译支持
- 默认语法:
t:common.hello
- Shopify Liquid:
{{ 'sections.header.title' | t }}
- 自定义模式:支持配置任意正则表达式
🌐 Glob 模式匹配
支持通配符路径,自动查找所有翻译文件:
{
"translationFiles": ["./themes/**/locales/zh-CN.json"]
}
🧠 智能路径匹配
自动选择离源文件最近的翻译文件:
theme1/page.liquid → 使用 theme1/locales/zh-CN.json
theme2/product.liquid → 使用 theme2/locales/zh-CN.json
🎨 实时翻译显示
- 代码中直接显示翻译文本
- 彩色标注(绿色=已有,红色=缺失)
- CodeLens 按钮快速操作
⚡ 快速编辑
- ✏️ 编辑翻译
- ➕ 新增翻译
- 🔍 跳转到翻译文件
- 🔄 刷新翻译
📦 安装
# 从 Marketplace 安装
code --install-extension genstore-i18n-helper
# 或从 VSIX 安装
code --install-extension genstore-i18n-helper-x.x.x.vsix
⚙️ 配置
基础配置
{
"genstoreI18nHelper.patterns": [
{
"name": "Default t: Syntax",
"pattern": "[\\\"']?t:([a-zA-Z_$][a-zA-Z0-9_$\\-]*(?:\\.[a-zA-Z_$][a-zA-Z0-9_$\\-]*)*)[\\\"']?",
"translationFiles": ["./locales/zh-CN.json"],
"fileTypes": ["*"]
}
]
}
多主题配置
{
"genstoreI18nHelper.patterns": [
{
"name": "Multi-theme Liquid",
"pattern": "'([^']+)'\\s*\\|\\s*t",
"translationFiles": ["./themes/**/locales/zh-CN.json"],
"fileTypes": ["liquid"]
}
]
}
🚀 使用示例
- 在代码中写翻译键:
const title = t:common.hello
- 自动显示翻译:
const title = t:common.hello ✏️ 编辑翻译 🔍 跳转 → 你好
- 点击按钮快速编辑或跳转
🎨 颜色配置
{
"genstoreI18nHelper.existingTranslationColor": "#51cf66",
"genstoreI18nHelper.missingTranslationColor": "#ff6b6b"
}
📝 支持的文件类型
- JavaScript/TypeScript
- Vue/React
- Liquid (Shopify)
- 任何文本文件
🤝 贡献
欢迎提交 Issue 和 Pull Request!
📄 License
MIT
🔗 链接