A Python-based tool for managing translations through the Transifex API, with support for automated translation and review processes.
- Fetch untranslated and unreviewed strings from Transifex
- Automated translation processing
- Translation validation and review
- Basic PO file validation
- Django's compilemessages validation
- JSON and YAML validation
- CSV export for translation management
- Support for multiple languages and resources
- Caching mechanism for efficient processing
- Python 3.10 or higher
- Transifex API access token
- OpenAI API key (for automated translations)
- Django (for PO file validation)
- Clone the repository:
git clone <repository-url>
cd transifex-script
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows, use: .venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
- Copy
.env.sample
to.env
- Fill in the required values:
TRANSIFEX_API_TOKEN=your_api_token TRANSIFEX_ORGANIZATION=your_organization TRANSIFEX_PROJECT=your_project TARGET_LANGUAGES=ar,fa # Comma-separated list of language codes OPENAI_API_KEY=your_openai_api_key
- Copy
The project uses a transifex.yml
file to configure resource mappings and translation file patterns. Make sure to update this file according to your project structure.
The script provides several commands for different translation management tasks:
python main.py fetch-strings --mode untranslated
python main.py fetch-strings --mode unreviewed
python main.py translate --mode untranslated
python main.py translate --mode unreviewed
To update translations in Transifex:
python main.py translate --mode untranslated --update-transifex
To bypass cache and force new downloads:
python main.py fetch-strings --mode untranslated --force-download
The script includes comprehensive validation for translation files:
# Validate all translation files
python main.py validate
# Validate only PO files
python main.py validate --format po
# Validate files in a specific directory
python main.py validate --directory path/to/translations
# Skip Django's compilemessages validation for PO files
python main.py validate --skip-django
# Keep generated .mo files after validation (by default they are removed)
python main.py validate --keep-mo
The validation process includes:
- Basic file format validation
- Placeholder consistency checks
- Django's compilemessages validation for PO files
- Automatic cleanup of generated .mo files
output/
: Contains CSV files with downloaded stringstranslations/
: Contains processed translations in JSON format- Logs are printed to the console during execution
The script includes error handling for:
- API connection issues
- Invalid configurations
- File processing errors
- Translation failures
- Django validation errors
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.