django-autotranslate
Automatically translate the pot (.po) files generated by Django's makemessages command using machine translation services.
Installation
pip install django-autotranslate
To show a progress bar while translating, install the progress extra:
pip install "django-autotranslate[progress]"
Add 'autotranslate' to your INSTALLED_APPS setting.
INSTALLED_APPS = (
...
'autotranslate',
)
Quick Start
django-admin autotranslate
The command finds all the generated pot (.po) files under the locale paths (LOCALE_PATHS) specified in django project settings, and translates them automatically.
Options
-p, --path: A locale directory to translate (can be given more than once)-a, --app: An app whose messages to translate (can be given more than once)-l, --locale: Only translate this locale, e.g.pt_BRorpt-br(can be given more than once). By default every locale found is translated-r, --retranslate: Translate all messages again, including translated messages and messages awaiting review-f, --set-fuzzy: Mark machine translations as fuzzy so they can be reviewed before use (fuzzy entries are not compiled)-s, --source-language: The language the messages are written in (defaulten)--service: The translation service to use instead ofsettings.AUTOTRANSLATE_SERVICE--no-progress: Do not show a progress bar. A progress bar is shown when theprogressextra is installed and the output is a terminal
django-admin autotranslate -l 'de' -l 'es'
Settings
The translation service is set with AUTOTRANSLATE_SERVICE. It defaults to the free Google Translate service, "autotranslate.services.GoogleTranslatorService". To use a different service give its import path, or a dictionary with the import path as BACKEND and OPTIONS to configure it. The --service option overrides the setting for a single run, the OPTIONS are only used with the configured BACKEND.
- Paid Google Cloud Translation (
pip install "django-autotranslate[google]"):
AUTOTRANSLATE_SERVICE = {
"BACKEND": "autotranslate.services.GoogleAPITranslatorService",
"OPTIONS": {
"api_key": "<google-api-key>", # required
"max_segments": 128, # strings per request
},
}
- Amazon Translate (
pip install "django-autotranslate[amazon]"). TheOPTIONSare passed toboto3.client(), anything not given is found by boto3 as usual (environment variables,~/.awsconfig files, instance roles):
AUTOTRANSLATE_SERVICE = {
"BACKEND": "autotranslate.services.AmazonTranslateTranslatorService",
"OPTIONS": {"region_name": "us-east-1"},
}
- Free Google Translate (default). The
OPTIONStune how requests are retried:
AUTOTRANSLATE_SERVICE = {
"BACKEND": "autotranslate.services.GoogleTranslatorService",
"OPTIONS": {
"retries": 3, # retries for network errors and rejected requests
"retry_delay": 1.0, # seconds before retrying a network error (doubles)
"rate_limit_delay": 30.0, # seconds before retrying a rejected request (doubles)
},
}
Language codes
Django identifies languages with lower case BCP 47 language tags (e.g. pt-br, zh-hans), which the services spell differently. Each Django language is matched to the service's languages by:
- The service's built in exceptions, e.g.
zh-hansiszh-CNfor Google,zhfor Amazon, and Django'spt(European Portuguese) ispt-PTfor the paid services, whoseptis Brazilian. - A case insensitive match against the languages the service supports.
- Dropping region subtags, e.g.
pt-brbecomespt. Script subtags are never dropped, sosr-latn(Latin script Serbian) is not translated as Cyrillic Serbian.
Languages that do not match are skipped. Every service accepts a language_map option to add or override exceptions, map a language to None to skip it:
AUTOTRANSLATE_SERVICE = {
"BACKEND": "autotranslate.services.GoogleAPITranslatorService",
"OPTIONS": {
"api_key": "<google-api-key>",
# use Brazilian Portuguese for pt and skip Argentinian Spanish
"language_map": {"pt": "pt", "es-ar": None},
},
}
Placeholders and markup
Placeholders and markup in messages are protected from translation:
python-formatplaceholders (%(name)s,%d,%.2f,%%) andpython-brace-formatplaceholders ({name},{0:>10},{{), chosen by the flagsmakemessageswrites for each message.- HTML: tags, character references (ending in
;, soAT&Tis ordinary text) and comments are kept and the text inside elements is translated, except incode,kbd,pre,samp,script,styleandvarelements. Attribute values are not translated. - Newlines.
The paid Google and Amazon services are told not to translate them (translate="no"). The free Google service only translates plain text, so they are replaced with numbered tokens (__x0__). Translations that lose or change a placeholder or tag, or add placeholders or markup that were not in the source message, are discarded with a warning and the message is left untranslated.
Compatibility Matrix
| autotranslate | django |
|---|---|
| v1.0.x | Django 1.5+ |
| v1.1.x | Django 1.8+ |
| v2.0.x | Django 5.2+ |
Documentation
Full documentation is available at django-autotranslate.readthedocs.io.
Development
git clone https://github.com/ankitpopli1891/django-autotranslate.git
cd django-autotranslate
just setup
just install
just test
Contributing
Contributions are welcome! Please see CONTRIBUTING.md.
Metadata
Release files for django-autotranslate 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_autotranslate-2.0.0.tar.gz | 368.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_autotranslate-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 908.7 kB
Release files / django_autotranslate-2.0.0.tar.gz
| Download URL | django_autotranslate-2.0.0.tar.gz |
|---|---|
| Size | 368.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ab7f5086a6451727f9ad10ab01dff84d2fb013d3114865265f2f173adb72dc6
|
|
BLAKE2b-256 checksum How to use checksums |
6a9b5e4dbba07114baebb476f3501c04e00ab235af4646e14ec062ff643999c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logRelease files / django_autotranslate-2.0.0-py3-none-any.whl
| Download URL | django_autotranslate-2.0.0-py3-none-any.whl |
|---|---|
| Size | 540.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a622e02daf4492b3317857987d195f100373dcb73191a532ec69974b086b1ad2
|
|
BLAKE2b-256 checksum How to use checksums |
717f210f1fd785850c1cbfa20bb0d45a89c9dcdb377c5f8fe5fb8d5ae9159d5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency log