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

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

Uploaded Source

Built Distribution

File details

Details for the file django-text-translator-2024.2.29.1.tar.gz.

File metadata

File hashes

Hashes for django-text-translator-2024.2.29.1.tar.gz
Algorithm Hash digest
SHA256 6e60d37c6ed155ad39a7f90cfc787eeead1765b5094e6b5b932197a4042c3c02
MD5 ad5ebaf246d02e86f9e239453fccc4a7
BLAKE2b-256 bba564fd1704410dc81de8b81e72b7458e17a573fb497b67a6c9bdcc8eb4aca9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_text_translator-2024.2.29.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a0d768e3602213efcc45b33daf5322df9f13d93523f02138eed61ecc9de7c34
MD5 526d82283e6061586eb9c54c88fc9df5
BLAKE2b-256 c9d40285bfb55565d1e9c22a14aedba3fd29b88340933f7d674b46cefef7891f

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