Management Command¶
The traduire command batch-translates all modeltranslation fields.
Basic usage¶
# Translate all registered models
python manage.py traduire
# Translate a specific model
python manage.py traduire myapp.Article
# Multiple models
python manage.py traduire myapp.Article myapp.Category
Options¶
--source¶
Override the source language:
--targets¶
Translate to specific languages only:
--fields¶
Translate only some fields — useful when only the long body changed:
--limit¶
Cap the number of rows walked per model. A run costs money and time per row:
--overwrite¶
Overwrite existing translations (by default, only empty fields are filled):
--dry-run¶
Preview what would be translated without making changes:
Output:
Would translate 42 myapp.Article instance(s)
Would translate 12 myapp.Category instance(s)
Would translate 54 instance(s) total.
Running it on a large table¶
The command reads the queryset with .iterator(), so memory stays flat, but
every row is a provider request. Two habits pay off:
- filter first, then translate:
--limitbounds the run, and a management command is cheap to run twice; - with the free Google backend, set
rate_limitinBACKEND_OPTIONS(0.5 second is a good start) so a long run is not throttled halfway through.
A provider failure is logged on the django_traduire logger and the run
continues, unless TRADUIRE["FAIL_SILENTLY"] is False.