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.5.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for django_text_translator-2024.5.1.tar.gz
Algorithm Hash digest
SHA256 64aa3021cc6a71c2ade57de25a6931641aed2c3f5d391cf5b56e3201f27556e3
MD5 f495875989009b3aed48d16f47f31226
BLAKE2b-256 646d67eb685244714389d7b2f2f2b04fbd62c7d23a9bda3df9cf575f32ecc020

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_text_translator-2024.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1304d71d9bb130a28a73a73add9ae18d47ee34c88f50927750c85d37255c853c
MD5 57c96c415983cb9dc46b9ef34bbecc84
BLAKE2b-256 cfdce0031be786c792c4cf910380d5b19f931ef5b573161c3e3e38092c0b7be2

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