textfile_translate
is a text file translation program. It uses google translator
service as a backend.
Put the script in the path, install the required python modules and you're good to go:
pip install -r requirements.txt
Run:
textfile_translate.py [-l <LANGUAGE_CODE>] -i <SRC>
Options:
-l Optional. iso639-1 destination language code. Default: pt
-s Optional. Text block size in characters to be translated. This option is due to google api limitations. Default: 5000
-i Mandatory. Path to source file, aka, the file to be translated.
Output:
A new file containing the translated text will be created on the same as the original text file. The destination language code will be appended to the end of the new filename, before the extension.
Example:
- Input file:
article.txt
- Output
article.pt.txt
All Google Translate service limitations are applied. Tested using MacOS Monterey running python 3.9
There's no error catching whatsoever. You are welcome to implement it yourself.
References:
Antonio Alisio de Meneses Cordeiro - [email protected]