Uso
Así.
Ayuda
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
Ejemplos
Para traducir un único archivo PO:
transpolibre -f locale/es/myprogram.po
Para traducir especificando el idioma de origen y de destino:
transpolibre -s en -t fr -f locale/fr/myprogram.po
Para usar un servidor LibreTranslate en particular:
transpolibre -u http://192.168.1.100:8000 -s en -t it -f locale/it/myprogram.po
Para listar los idiomas disponibles en un servidor LibreTranslate:
transpolibre -u http://192.168.1.100:8000 --list
Para traducir todos los archivos PO de un directorio:
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
Para traducir con un modelo local:
transpolibre -e local -m ModelSpace/GemmaX2-28-9B-v0.1 -t de -f locale/it/myprogram.po
Dotenv
La URL y la clave de API de LibreTranslate se pueden almacenar con dotenv, por lo que no es necesario especificarlos en la línea de comandos. Por ejemplo, en lugar de hacer esto:
transpolibre --url http://192.168.1.100:8000
Puede agregar la URL agregando la variable LT_URL a un archivo .env en el directorio base:
LT_URL="http://192.168.1.100:8000"
Lo mismo se puede hacer con la clave API, por ejemplo:
LT_API_KEY="00000000000000000000000000000"
Un modelo Ollama por defecto:
OLLAMA_MODEL="aya-expanse:32b"
Una URL de Ollama predeterminada:
OLLAMA_URL="http://192.168.1.100:11434"