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'
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
File details
Details for the file django-deep-translator-1.5.1.tar.gz
.
File metadata
- Download URL: django-deep-translator-1.5.1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e2fc5517ae6537bbcca4f7c3df30d13acf5ad9f2703e4cefc3b415719f2709f |
|
MD5 | 3e02c317efd191100b4209de86506043 |
|
BLAKE2b-256 | 0fb383ee3db2ebb5e2089d299f7a5cd2240c44d6b2ccedb3cf21b4aa77889d2c |
File details
Details for the file django_deep_translator-1.5.1-py3-none-any.whl
.
File metadata
- Download URL: django_deep_translator-1.5.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1d067cef92302b527eca62aa058bacc0d5ae73fa13bc99f724bc3d01e8e28f4 |
|
MD5 | 04b80331ee2fc772272d02308c33d50e |
|
BLAKE2b-256 | 0e1e666864e33f267a55076e50b5a892ae7d947808a734bded9ad50b550882e8 |