1.0.1 • Published 4 months ago
next-translate-excel v1.0.1
next-translate-excel
一个用于管理国际化翻译的命令行工具,支持 JSON 与 Excel 之间的相互转换,并集成了 DeepL 翻译功能。
安装
npm install -g next-translate-excel
功能特点
- 将 JSON 格式的翻译文件导出为 Excel 表格
- 自动使用 DeepL API 进行中英文翻译
- 从 Excel 表格导入翻译并生成对应的 JSON 文件
- 支持嵌套的 JSON 结构
- 使用 TypeScript 编写,提供完整的类型支持
- 支持的语言:zh, en, ko, id
使用方式
导出翻译到 Excel
next-translate-execel export -k your-deepl-api-key -s ./zh -o translations.xlsx
选项说明:
-k, --api-key
: DeepL API Key(必需)-s, --source
: 源 JSON 文件目录,默认为 "./zh"-o, --output
: 输出的 Excel 文件路径,默认为 "translations.xlsx"
导入
next-translate-execel import -s translations.xlsx -o ./messages
更新翻译
next-translate-excel update -k your-deepl-api-key -s ./messages/zh -e translations.xlsx -o translations_updated.xlsx
收集翻译
next-translate-excel collect -s ./messages -o translations_collected.xlsx
选项说明:
-s, --source
: 源 Excel 文件路径,默认为 "translations.xlsx"-o, --output
: 输出目录,默认为 "./messages"
贡献指南
安装依赖
npm install
构建
npm run build
运行
npm run start
测试
npm run test
本地调试
npm run build
npm link
然后在项目中使用 next-translate-excel
命令:
npm link next-translate-excel
next-translate-excel export -k your-deepl-api-key -s ./zh -o translations.xlsx