Metadata-Version: 2.4
Name: django-ai-translate
Version: 0.1.2
Summary: Django AI Translate
Author-email: Aimé DEGBEY <aime.degbey@kodesio.com>
License: MIT License
        
        Copyright (c) 2025 Aimé DEGBEY
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
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 :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: anthropic>=0.53.0
Requires-Dist: cappa>=0.27.2
Requires-Dist: django>=1.11
Requires-Dist: groq>=0.25.0
Requires-Dist: openai>=1.79.0
Requires-Dist: polib>=1.2.0
Requires-Dist: six>=1.17.0
Requires-Dist: together>=1.5.8
Requires-Dist: tqdm>=4.67.1
Requires-Dist: yaspin>=3.1.0
Dynamic: license-file

# 🌍 django-ai-translate

**AI-powered translation for Django `.po` files — effortless, fast, and customizable.**

`django-ai-translate` is a Django package that automates the translation of gettext `.po` files using AI. Ideal for multilingual web applications, it helps you manage and update translations with minimal manual effort.

---

## ✨ Features

* 🔁 **Batch Translation** with customizable batch size
* ⚡️ **Async Support** for fast and efficient translation
* 🧠 **Powered by AI** (OpenAI, Groq, etc.)
* 📁 Works with standard `.po` files
* 🛠️ CLI integration via Django management command
* 📦 Easy to install and integrate in Django projects

---

## 🚀 Installation

Using [`uv`](https://github.com/astral-sh/uv):

```bash
uv pip install django-ai-translate
```

Or with pip:

```bash
pip install django-ai-translate
```

---

## 🛠️ Usage

### Django Management Command

```bash
python manage.py translate_po -f <path-to-file.po> -l <target-language> -bs [--batch-size 100]
```

**Example:**

```bash
python manage.py translate_po -f locale/fr/LC_MESSAGES/django.po -l en -bs 100
```

This command will:

* Load the `.po` file
* Translate all untranslated entries using AI
* Save the translations in-place


---


## ⚙️ Django Configuration

In your Django `settings.py`, add the following to configure the translator:

```python
AI_TRANSLATOR =  {
    'ENGINE': '',  # e.g. 'groq', 'openai', 'anthropic', or 'together'. The package only support these four api for now.
    'API_KEY': '',  # Your API key
    'MODEL': '',  # e.g. 'gpt-4', 'llama-3-70b'
    'PROMPT_TEXT': "You are a web application translator. Don't ouput thinking. Don't add anything else than result. Translate the following text to "
}
```

---

## 📁 Project Structure

```bash
django_ai_translate/
├── __init__.py
├── translator.py
├── po_handler.py
├── settings.py
├── management/
│   └── commands/
│       └── translate_po.py
tests/
pyproject.toml
```

---

## 🙌 Contributing

Pull requests are welcome! If you’d like to contribute:

```bash
git clone https://github.com/aimedey19/django-ai-translate.git
cd django-ai-translate
uv sync
```

---

## Contributors
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

## 📄 License

MIT License © Aime & Contributors

