A Python tool to batch-translate Excel files using either Google Translate API or LibreTranslate API. It reads all sheets from an input Excel file, translates the content, and writes the translated sheets to a new Excel file.
- Supports both Google Translate and LibreTranslate APIs
- Translates all sheets in an Excel file
- Output file is auto-named based on input and target language
- Logging of errors and exceptions to a timestamped log file in the
log/
directory
- Python 3.8+
- API key for Google Translate (required for Google)
- (Optional) API key for LibreTranslate (recommended for production use)
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Configure the project:
- Edit
config.py
:- Set
INPUT_FILE
to your Excel file path (e.g.,input/YourFile.xlsx
) - Set
TARGET_LANGUAGE
(e.g.,'en'
for English) - Set
SOURCE_LANGUAGE
(e.g.,'id'
for Indonesian) - Set
TRANSLATOR
to'google'
or'libre'
- Set
API_KEY
for the selected API (see below)
- Set
- Edit
- Google Translate: Get an API key from Google Cloud Console. Enable the Cloud Translation API.
- LibreTranslate: Get a free API key from LibreTranslate Portal. Some public endpoints may not require a key, but it's recommended.
Run the main script:
python main.py
- The script will print the selected translator and progress.
- The translated file will be saved in the
output/
directory astranslated_<TARGET_LANGUAGE>_<INPUT_FILE>
. - Logs are saved in the
log/
directory with a timestamped filename.
- In
config.py
, setTRANSLATOR = 'google'
to use Google Translate, orTRANSLATOR = 'libre'
to use LibreTranslate. - Provide the correct
API_KEY
for the selected service.
- For large files, be aware of API rate limits (especially for LibreTranslate public endpoints).
- All logs and errors are saved in the
log/
directory for troubleshooting.
- At some point this would use the Translation API that I'm working on. so that smaller translation requests could be served without any token from 3rd party API. I'll be using 'https://github.com/argosopentech/argos-translate' as a base model for translation support.
MIT License