雨果标记符文件翻译自动化脚本 - Glotta
Table of Contents
Glotta
将雨果标记文件内容翻译成其他语言的脚本。
示例命令:
node src/index.js --source=__fixtures__ --recursive --force
# --source is the root dir to search for ".en.md" files. You may replace __fixtures__ with any other dir name.
# --recursive will include any nested directories in the root dir (default is false)
# --force will cause existing language files to be overwritten (default is to ignore existing language file)
# --targetLanguageIds is another option that can be specified (default target ids are: ar, bn, ca, zh, fr, de, hi, it, ja, pt, pa, ro, ru, es
输出示例:
========== glotta ============
dir: __fixtures__/simeon-usecase-dir/content/articles/a-beginners-guide-to-setting-up-a-secure-and-resilient-vpn-for-remote-workers
Input file(s): [
'__fixtures__/simeon-usecase-dir/content/articles/a-beginners-guide-to-setting-up-a-secure-and-resilient-vpn-for-remote-workers/index.en.md'
]
targetLanguageIds: ar, bn, ca, zh, fr, de, hi, it, ja, pt, pa, ro, ru, es
force overwrite if file exists?: true
==============================
parsing input file...
translating text into... es
writing new file...
translating text into... ru
writing new file...
translating text into... ro
writing new file...
translating text into... pa
如何更改翻译 API 提供商
设置 TRANSLATE_PROVIDER
环境变量为 GOOGLE
或 DEEPL
并确保设置您的 DEEPL_AUTH_KEY
也是如此。
测试套件将依赖于这些环境变量,因此您可以通过运行 npm test
例如
GOOGLE_APPLICATION_CREDENTIALS=./gcloud-keys/dev-service-account-keys.json
DEEPL_AUTH_KEY= **********
TRANSLATE_PROVIDER=DEEPL