Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/riccardofasan/django-polyglot

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.
https://github.com/riccardofasan/django-polyglot

deepl deepl-api django django-application django-commands django-rest-framework i18n polyglot

Last synced: 8 days ago
JSON representation

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.

Awesome Lists containing this project

README

        

# Django-Polyglot: DeepL integration for Django

Django-Polyglot is an integration of [**Polyglot**](https://github.com/riccardoFasan/polyglot) for [**Django**](https://www.djangoproject.com/) Web Framework.

It provides a CLI command that, using the [**DeepL API**](https://www.deepl.com/it/docs-api/), automates the translation of your static texts.

## Installation

Django Polyglot can be easily installed by running:

```shell
pip install django-polyglot-translator
```

Make sure you've configured Django [internationalization](https://docs.djangoproject.com/en/4.0/topics/i18n/).

Now you have to register Django-Polyglot in your settings like this:

```python
INSTALLED_APPS = [
...
    'djangoPolyglot'
]
```

Finally, you need to store your DeepL API key in your settings.

```python
POLYGLOT_DEEPL_LICENSE = "your DeepL API key"
```

## Usage

### Translate

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.

```shell
./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.

### Usage info

It returns DeepL usage info related to your API key, run with:

```shell
./manage.py django-polyglot print_usage_info
```

### Supported languages

It returns the list of languages currently supported by DeepL, run with:

```shell
./manage.py django-polyglot print_supported_languages
```

## Dependencies

The only dependency is [**Polyglot**](https://github.com/riccardoFasan/polyglot).

## License

Django-Polyglot is provided under the MIT license.