Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

A Django application that supports adding multiple third-party engines for text translation.

License

Notifications You must be signed in to change notification settings

rss-translator/django-text-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


⛔️This package has been merged into RSS Translator


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.