使用
就是这样。
帮助
usage: transpolibre [-h] [-a API_KEY] [-c CUDA_DEVICE] [-d]
[-D {auto,cpu,gpu}] [-e {LibreTranslate,Ollama,Local}]
[-f FILE] [-l] [-m MODEL] [-o] [-s SOURCE_LANG]
[-t TARGET_LANG] [-u URL] [-v] [-V]
Translate PO files
options:
-h, --help show this help message and exit
-a API_KEY, --api-key API_KEY
LibreTranslate API key
-c CUDA_DEVICE, --cuda-device CUDA_DEVICE
Local CUDA device number (Default 0)
-d, --debug Debugging
-D {auto,cpu,gpu}, --device {auto,cpu,gpu}
Device to use for local translation: auto, cpu, gpu
(Default auto)
-e {LibreTranslate,Ollama,Local}, --engine {LibreTranslate,Ollama,Local}
Translation engine (Default: LibreTranslate)
-f FILE, --file FILE PO file to translate
-l, --list List available languages
-m MODEL, --model MODEL
Model for Local or Ollama (Default local:
ModelSpace/GemmaX2-28-9B-v0.1, default Ollama: aya-
expanse:32b)
-o, --overwrite Overwrite existing translations
-s SOURCE_LANG, --source-lang SOURCE_LANG
Source Language ISO 639 code (Default en)
-t TARGET_LANG, --target-lang TARGET_LANG
Target Language ISO 639 code (Default es)
-u URL, --url URL Engine URL (Default LibreTranslate:
http://127.0.0.1:8000, default Ollama:
http://127.0.0.1:11434)
-v, --verbose Increase output verbosity
-V, --version Show version
示例
要翻译单个 PO 文件:
transpolibre -f locale/es/myprogram.po
要翻译的指定语言:
transpolibre -s en -t fr -f locale/fr/myprogram.po
要使用特定的 LibreTranslate 服务器:
transpolibre -u http://192.168.1.100:8000 -s en -t it -f locale/it/myprogram.po
列出 LibreTranslate 服务器上可用的语言:
transpolibre -u http://192.168.1.100:8000 --list
要翻译目录中的所有 PO 文件:
for i in locale/eo/*.po
do transpolibre -u http://192.168.1.100:8000 -s en -t eo -f $i
done
To translate with Ollama:
transpolibre -e ollama -t it -f locale/it/myprogram.po
使用本地模型进行翻译:
transpolibre -e local -m ModelSpace/GemmaX2-28-9B-v0.1 -t de -f locale/it/myprogram.po
Dotenv
LibreTranslate URL 和 API 密钥可以使用 dotenv 存储,因此不需要在命令行上指定。例如,不用这样:
transpolibre --url http://192.168.1.100:8000
您可以将 LT_URL 变量添加到基本目录中的 .env 文件中,以添加 URL:
LT_URL="http://192.168.1.100:8000"
API 密钥也可以这样做,例如:
LT_API_KEY="00000000000000000000000000000"
默认的 Ollama 模型:
OLLAMA_MODEL="aya-expanse:32b"
默认的 Ollama URL:
OLLAMA_URL="http://192.168.1.100:11434"