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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_text_translator-2024.3.26-py3-none-any.whl (41.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for django_text_translator-2024.3.26.tar.gz
Algorithm Hash digest
SHA256 5120fd1c932d27d8f2b9b373534989c1eb18a418d2047f005c127aacab392efc
MD5 6d8498787c828621e2b206b6f9d55eb0
BLAKE2b-256 d3c5ae31b59093cdbbe3e3b3fb7ce5a09d4e4f0394c66669427a713f8fb3a3e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_text_translator-2024.3.26-py3-none-any.whl
Algorithm Hash digest
SHA256 2ff0905ef52584e7c773f0c917dce560420effc638f910e9de8c3d3aa80a7c31
MD5 a60257a91b4b9fa59bfbd3c0d01f2944
BLAKE2b-256 5cd83f61f0be8d5950d8f63660797e96f2c7fc1b2dbeeeb4d4756fb94030af61

See more details on using hashes here.

Supported by

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