Django-Polyglot is an integration of Polyglot for Django Web Framework.
It provides a CLI command that, using the DeepL API, automates the translation of your static texts.
Django Polyglot can be easily installed by running:
pip install django-polyglot-translator
Make sure you've configured Django internationalization.
Now you have to register Django-Polyglot in your settings like this:
INSTALLED_APPS = [
...
'djangoPolyglot'
]
Finally, you need to store your DeepL API key in your settings.
POLYGLOT_DEEPL_LICENSE = "your DeepL API key"
Django-Polyglot will run for you the Django "makemessages" command, preparing the .po files with the text to be translated. Then Polyglot will use the DeepL APIs to translate this files. Finally the Django "compilemessages" command will be ran and your static translations will be ready.
./manage.py django-polyglot translate
⚠️ To use the translate command you need to set LANGUAGE_CODE, LANGUAGES and LOCALE_PATHS in your settings, according the Django documentation.
It returns DeepL usage info related to your API key, run with:
./manage.py django-polyglot print_usage_info
It returns the list of languages currently supported by DeepL, run with:
./manage.py django-polyglot print_supported_languages
The only dependency is Polyglot.
Django-Polyglot is provided under the MIT license.