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

Uploaded Source

Built Distribution

django_text_translator-2024.4.20-py3-none-any.whl (43.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for django_text_translator-2024.4.20.tar.gz
Algorithm Hash digest
SHA256 bbefddb005bd59dccd7e28e692ce8607d1f60fccaebeb18e5034a5d5a4bfaa8a
MD5 079ee4127f075b7622140fcf6f274cda
BLAKE2b-256 3128d30eda1da925fed10139bf63643936677346ff2b6b80d83cb0d6605cd09c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_text_translator-2024.4.20-py3-none-any.whl
Algorithm Hash digest
SHA256 a84f0b5531cd98863337d11ffa79964730b53741365619da136e2f42bfd795f6
MD5 f0f28ff032371e15c0724e8700747091
BLAKE2b-256 c1bc527370005b80a9397a4f32b45b1ab7addcc8e5abf6abc7374dc657ddab90

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