Skip to main content

Django AI Translate

Project description

🌍 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:

uv pip install django-ai-translate

Or with pip:

pip install django-ai-translate

🛠️ Usage

Django Management Command

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

Example:

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:

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

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:

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

Contributors

All Contributors

📄 License

MIT License © Aime & Contributors

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

django_ai_translate-0.1.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_ai_translate-0.1.2-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file django_ai_translate-0.1.2.tar.gz.

File metadata

  • Download URL: django_ai_translate-0.1.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for django_ai_translate-0.1.2.tar.gz
Algorithm Hash digest
SHA256 503df4277717bc81129d09991e914ce85ca8c86ec0e8abb302b452156dff7fc9
MD5 58c83fd2c6e4add4f879c23925c45f5b
BLAKE2b-256 d769aadee0fbfeb38c0cc2f6665eb94d1e4a455868919b02ad3b78e2ba3ecfad

See more details on using hashes here.

File details

Details for the file django_ai_translate-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ai_translate-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9d76fa47ade01b50873b20fa864c66ae53d57e9c49e90fac2995ec81e8b15091
MD5 25a9e5fe72faf96685847171e4147ed7
BLAKE2b-256 49130872fc450fdb83903821da823c48d846695de3d04f4014ae646321d83686

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page