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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for django_text_translator-2024.4.22.tar.gz
Algorithm Hash digest
SHA256 311f7e4e2ae9e04c5101e6986527e6b51e67284726ff231e820f2b05d096f568
MD5 91332bd3e775f7cdd20d6014896293d4
BLAKE2b-256 df522b6770b20d98e036d620ed35f5111c27bc1b2ec37835c5238ddef13c5633

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_text_translator-2024.4.22-py3-none-any.whl
Algorithm Hash digest
SHA256 d16ecc7cb32f8fc3ef2bd069acf309410afe8c1305ee06adc02453d232305889
MD5 2f462aa5540bf05a91b5683d58753e44
BLAKE2b-256 06e7cd62b2cf34a61210178214f73de4b119e33b0fe6b82ffbc218b774af34aa

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