Metadata-Version: 2.4
Name: django-traduire
Version: 0.1.0
Summary: Auto-translate django-modeltranslation fields using DeepL, Google, or OpenAI
Project-URL: Homepage, https://github.com/Altius-Academy-SNC/django-traduire
Project-URL: Documentation, https://altius-academy-snc.github.io/django-traduire
Project-URL: Repository, https://github.com/Altius-Academy-SNC/django-traduire
Author-email: Paul Guindo <paulguindo@altius-group.ch>
License-Expression: MIT
License-File: LICENSE
Keywords: deepl,django,i18n,modeltranslation,multilingual,translation
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Framework :: Django :: 6.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Internationalization
Requires-Python: >=3.10
Requires-Dist: django-modeltranslation>=0.18
Requires-Dist: django>=4.2
Provides-Extra: all
Requires-Dist: deepl>=1.16; extra == 'all'
Requires-Dist: google-cloud-translate>=3.12; extra == 'all'
Requires-Dist: openai>=1.0; extra == 'all'
Provides-Extra: deepl
Requires-Dist: deepl>=1.16; extra == 'deepl'
Provides-Extra: dev
Requires-Dist: deepl>=1.16; extra == 'dev'
Requires-Dist: google-cloud-translate>=3.12; extra == 'dev'
Requires-Dist: openai>=1.0; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest-django; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material; extra == 'docs'
Requires-Dist: mkdocstrings[python]; extra == 'docs'
Provides-Extra: google
Requires-Dist: google-cloud-translate>=3.12; extra == 'google'
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == 'openai'
Description-Content-Type: text/markdown

# django-traduire

**[Documentation](https://altius-academy-snc.github.io/django-traduire/)** | **[PyPI](https://pypi.org/project/django-traduire/)** | **[GitHub](https://github.com/Altius-Academy-SNC/django-traduire)**

Auto-translate [django-modeltranslation](https://github.com/deschler/django-modeltranslation) fields using DeepL, Google Cloud Translation, or OpenAI.

Fill in content in **one language**, and `django-traduire` populates all the other language columns automatically.

## Install

```bash
pip install django-traduire[deepl]    # DeepL backend
pip install django-traduire[google]   # Google Cloud Translation
pip install django-traduire[openai]   # OpenAI / LLM backend
pip install django-traduire[all]      # All backends
```

## Quick start

```python
# settings.py
INSTALLED_APPS = [
    ...
    "modeltranslation",
    "django_traduire",
]

LANGUAGES = [
    ("fr", "Francais"),
    ("de", "Deutsch"),
    ("en", "English"),
    ("it", "Italiano"),
]

TRADUIRE = {
    "BACKEND": "django_traduire.backends.deepl.DeepLBackend",
    "SOURCE_LANGUAGE": "fr",
    "BACKEND_OPTIONS": {
        "auth_key": "your-deepl-api-key",
    },
}
```

## Translate in Python

```python
from django_traduire import translate_instance

article = Article.objects.get(pk=1)
# article.title_fr = "Bonjour le monde"

translate_instance(article)
# article.title_de = "Hallo Welt"
# article.title_en = "Hello world"
# article.title_it = "Ciao mondo"
```

## Management command

```bash
# Translate all registered models
python manage.py traduire

# Translate a specific model
python manage.py traduire myapp.Article

# Overwrite existing translations
python manage.py traduire --overwrite

# Dry run
python manage.py traduire --dry-run
```

## Admin integration

```python
from django.contrib import admin
from modeltranslation.admin import TranslationAdmin
from django_traduire.admin import TraduireMixin

@admin.register(Article)
class ArticleAdmin(TraduireMixin, TranslationAdmin):
    pass
```

This adds "Translate empty fields" and "Translate all fields (overwrite)" actions to the admin.

## Auto-translate on save

```python
TRADUIRE = {
    ...
    "AUTO_TRANSLATE": True,
}
```

Every time a model is saved, empty translation fields are filled automatically.

## Backends

| Backend | Install | Best for |
|---------|---------|----------|
| DeepL | `pip install django-traduire[deepl]` | European languages, highest quality |
| Google Cloud | `pip install django-traduire[google]` | Broadest language coverage |
| OpenAI | `pip install django-traduire[openai]` | Creative / contextual translations |

## License

MIT - Paul Guindo / Altius Academy SNC.
