Skip to main content

Another translate API for Python.

Project description

freetranslate

Translate your text using various APIs

Description

This library help you to translate text from a language to other for free

Installation

Either install from PyPI with pip install freetranslate or pip install git+https://gitlab.com/tretrauit/freetranslate to install from GitLab

Usage

import asyncio # This package uses aiohttp to do requests.
from freetranslate.googletranslate import GoogleTranslate

googletrans = GoogleTranslate()
translated_result = asyncio.run(googletrans.translate("Xin chào!", "en"))
print(translated_result.translated_text)

Tada, you've just translated "Xin chào!" to English and printed the translated text.

Status

Currently this library supports Google Translate, Bing Translator & LibreTranslate

Why another python translation library?

here's a translation library I love (py-googletrans) but its' stable branch is broken. Although there is a working one (Animenosekai/translate) but its license is AGPL 3 which is a strict license, and I don't like that. So this library was made.

Documentation (WIP)

class translatorabc.TranslatorABC()

Abstract class for Translators.

method translate(self, text: str, target_language: str, source_language: str = "auto") -> TranslateResult

Translate text from source_language (optional) to target_language.

method _parse_result(self, result: dict) -> TranslateResult

Default parser for translated result return from the server, and return a TranslateResult object.

method detect(self, text: str) -> str

Detect the language of text.

class googletranslate.GoogleTranslate(endpoint_url: str = None, endpoint_list: list() = None) -> GoogleTranslate

This class provides Google Translate used in Google Translate extensions & clients.

class googlewebtranslate.GoogleWebTranslate(endpoint_url: str = None, endpoint_list: list() = None) -> GoogleWebTranslate

This class provides Google Translate used in Google Translate website

class bingtranslator.BingTranslator() -> BingTranslator

This class provides Google Translate used in Google Translate website

class libretranslate.LibreTranslate(endpoint_url: str = "https://translate.argosopentech.com/") -> LibreTranslate

This class provides LibreTranslate using their API

Badges

On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.

Visuals

Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.

Support

Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.

Roadmap

If you have ideas for releases in the future, it is a good idea to list them in the README.

Contributing

State if you are open to contributions and what your requirements are for accepting them.

For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.

You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.

Authors and acknowledgment

py-googletrans library for most code in communicating with Google RPC Translate and deobfuscation code.

License

MIT Licensed

Project status

If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

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

freetranslate-0.2.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

freetranslate-0.2.1-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file freetranslate-0.2.1.tar.gz.

File metadata

  • Download URL: freetranslate-0.2.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for freetranslate-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ebb7f09f13751cb8098c5f23c8b14c194bb8906dfb5f98d8906764095d9858e5
MD5 723a9ac07292bd63c49caf683d1ee7aa
BLAKE2b-256 a014d820ded6b21dcee9a9c1295e017c9e606e99e39f31411b9e486e6bf8e22f

See more details on using hashes here.

File details

Details for the file freetranslate-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: freetranslate-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for freetranslate-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 426301025e1d3b0070151320e3ed6198ce98440272a37fff84db9ff75d234bf0
MD5 9f93f412778bca53b20c888dd9445cca
BLAKE2b-256 a78cbd2875fa69fa1a7c98fd573e8fbfe47a3dc7e4250783578244e6bb4518ec

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