Skip to main content

A Django application that supports adding multiple third-party engines for text translation.

Project description

django-text-translator

A Django application that supports adding multiple third-party engines for text translation.

Currently, it supports the following engines:

  • DeepL
  • DeepLX
  • OpenAI
  • ClaudeAI
  • Azure OpenAI
  • Google Gemini
  • Google Translate(Web)
  • Microsoft Translate API
  • Caiyun API
  • Moonshot AI

Installation

  1. Install: pip install django-text-translator
  2. Add "django_text_translator" to your INSTALLED_APPS setting like this:
        INSTALLED_APPS = [
            ...,
            "django_text_translator",
        ]
    
  3. Run python manage.py makemigrations and python manage.py migrate to create the models.
  4. Start the development server and visit the admin to add a translator.
  5. Translate a text:
    from django_text_translator.models import OpenAITranslator
    
    openai_translator = OpenAITranslator.filter(valid=True).first()
    
    results = openai_translator.translate(text="Hello, world!",target_language="Chinese")
    
    print(results.text) # 你好,世界!
    print(results.tokens) # 51
    
    
  6. More details can be found in the models.py file.

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_text_translator-2024.4.2.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django_text_translator-2024.4.2.tar.gz.

File metadata

File hashes

Hashes for django_text_translator-2024.4.2.tar.gz
Algorithm Hash digest
SHA256 95a44c97f99e1b09d253ea2f1de5366d4124f616ff9369eb86bd9c31eb5f1aa8
MD5 1d0dde1617eaefbb3bf72a428be53793
BLAKE2b-256 c9bc1ffaeb370d904b52db65276a5fc5f45d92f0e55e25c2ea24cea69abed029

See more details on using hashes here.

File details

Details for the file django_text_translator-2024.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_text_translator-2024.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05235d74306886c4349ba9f39b24bf186bec6f1d3764a4ffba83f29f5b8e5c97
MD5 415e20e7c3b5f9f84e2dda200c0eda07
BLAKE2b-256 9695ec738b20338408311d13908baf817cb4a9178d279da69f4ebe9601fb9902

See more details on using hashes here.

Supported by

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