Automatically translate the pot (`.po`) files generated by django's makemessages command built on top of python deep-translator package
Project description
django-deep-translator
Autotranslate django .po
translation files package built on top of deep-translator
Installation
pip install django-deep-translator
Add 'django_deep_translator'
to your INSTALLED_APPS
setting:
INSTALLED_APPS = (
...
'django_deep_translator',
)
Quickstart
python manage.py translate_messages
The command finds all the generated pot (.po) files under the locale paths (LOCALE_PATHS) specified in django project settings, and translates them automatically with default source language as english.
Options
-f, --set-fuzzy
: Set the 'fuzzy' flag on autotranslated entries-l, --locale 'locale'
: Only translate the specified locales-u, --untranslated
: Only translate the untranslated messages-s, --source-language
: Override the default source language (en) used for translation
python manage.py translate_messages -l 'de' -l 'es'
Settings
In your settings, list the relative path to locale folders, example:
LOCALE_PATHS = (
'locale',
'home/locale',
'products/locale',
'services/locale',
)
Using a different Translation Service:
# default: 'django_deep_translator.services.GoogleTranslatorService'
PO_TRANSLATOR_SERVICE = 'django_deep_translator.services.GoogleAPITranslatorService'
GOOGLE_TRANSLATE_KEY = '<google-api-key>'
PO_TRANSLATOR_SERVICE
accepts the following services with respective additional variables:
Service | Additional variables | Description |
---|---|---|
GoogleAPITranslatorService | - | - |
MicrosoftTranslatorService | MICROSOFT_TRANSLATE_KEY |
You need to require an api key if you want to use the microsoft translator. Visit the official website for more information about how to get one. Microsoft offers a free tier 0 subscription (2 million characters per month). |
PonsTranslatorService | - | - |
MyMemoryTranslatorService | - | - |
YandexTranslatorService | YANDEX_TRANSLATE_KEY |
You need to require a private api key if you want to use the yandex translator. Visit the official website for more information about how to get one |
PapagoTranslatorService | PAPAGO_CLIENT_ID , PAPAGO_SECRET_KEY |
You need to require a client id if you want to use the papago translator. Visit the official website for more information about how to get one. |
DeeplTranslatorService | DEEPL_TRANSLATE_KEY |
Visit https://www.deepl.com/en/docs-api/ for more information on how to generate your Deepl api key |
QcriTranslatorService | QCRI_TRANSLATE_KEY |
Visit https://mt.qcri.org/api/ for more information |
LibreTranslatorservice | LIBRE_TRANSLATE_MIRROR_URL |
Libre translate has multiple mirrors which can be used for the API endpoint. Some require an API key to be used. By default the base url is set to libretranslate.de . |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-deep-translator-1.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5532bf5af93a6fa519c1da9fa421f9af68f052a8a5212fcd199635b1ae20e6cf |
|
MD5 | 39c65ae5f243ae4b15b01320348519d7 |
|
BLAKE2b-256 | f26137cc41f5601d53dc74b89f16fa51ed772b6a4e918a04622707be555755fc |
Hashes for django_deep_translator-1.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 061afff2cedcdd27f3a3bed4e5b04706aad1ce1b9d67df559aa635f7c34517b2 |
|
MD5 | 99b828a13d764ee7a123b9b159206a3d |
|
BLAKE2b-256 | badf04946b02b7d97a578f9917891722e29f0e97c6f0b2caaf81e4eb4232be2f |