Skip to content

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:

python manage.py traduire --source en

--targets

Translate to specific languages only:

python manage.py traduire --targets de,it

--fields

Translate only some fields — useful when only the long body changed:

python manage.py traduire myapp.Article --fields body,chapo

--limit

Cap the number of rows walked per model. A run costs money and time per row:

python manage.py traduire myapp.Article --limit 100

--overwrite

Overwrite existing translations (by default, only empty fields are filled):

python manage.py traduire --overwrite

--dry-run

Preview what would be translated without making changes:

python manage.py traduire --dry-run

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: --limit bounds the run, and a management command is cheap to run twice;
  • with the free Google backend, set rate_limit in BACKEND_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.