Skip to content

Command Reference

Complete reference for the translate management command.

Synopsis

python manage.py translate [options]

Options

--target-lang

Target language code for translation.

python manage.py translate --target-lang nl
python manage.py translate --target-lang de

Note

Required unless LANGUAGES is defined in Django settings. When LANGUAGES is set, omitting this option translates to all configured languages.

--dry-run

Preview translations without saving changes.

python manage.py translate --target-lang nl --dry-run

Shows what would be translated and the resulting translations, but doesn't modify any files or database records.

--overwrite

Re-translate entries that already have translations.

python manage.py translate --target-lang nl --overwrite

By default, only empty entries are translated. Use this flag to replace existing translations.

Warning

Existing translations will be lost. Consider using --dry-run first.

--models

Translate database model fields instead of (or in addition to) PO files.

# Translate all registered models
python manage.py translate --target-lang nl --models

# Translate specific models
python manage.py translate --target-lang nl --models Article Product

Note

Only available when django-modeltranslation is installed and configured.

Usage Examples

Basic Translation

# Translate to Dutch
python manage.py translate --target-lang nl

# Translate to all configured languages
python manage.py translate

Preview Mode

# Preview PO file translations
python manage.py translate --target-lang fr --dry-run

# Preview model translations
python manage.py translate --target-lang fr --models --dry-run

Force Re-translation

# Re-translate all PO entries
python manage.py translate --target-lang de --overwrite

# Re-translate all model fields
python manage.py translate --target-lang de --models --overwrite

Model-Specific Translation

# Translate only Article and Product models
python manage.py translate --target-lang nl --models Article Product

# Preview before applying
python manage.py translate --target-lang nl --models Article --dry-run

Complete Workflow

# Generate message files
python manage.py makemessages -l de -l fr -l nl

# Preview translations
python manage.py translate --dry-run

# Apply translations
python manage.py translate

# Compile for use
python manage.py compilemessages

Exit Codes

Code Meaning
0 Success
1 Error (invalid options, API error, etc.)

Environment Variables

Variable Description
TRANSLATEBOT_API_KEY API key (fallback if not in settings)
Command Description
makemessages Extract translatable strings to .po files
compilemessages Compile .po files to .mo files