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.2.tar.gz (10.5 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.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: freetranslate-0.2.2.tar.gz
  • Upload date:
  • Size: 10.5 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.9

File hashes

Hashes for freetranslate-0.2.2.tar.gz
Algorithm Hash digest
SHA256 f0dc6a6a40b67656827922ea16d804fc28f3f95c476462439c5726720dee6be6
MD5 9022638335932a1efefe58910e4cdb55
BLAKE2b-256 93a71008dbe4261a53250cba7bdad12337667c1363bb1665067467041453b87b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: freetranslate-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 12.3 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.9

File hashes

Hashes for freetranslate-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 db7e87107609260680ad5321e964d357cb082ede14a9c6a5cc03ed94ffa501ac
MD5 8bdcc07ff17fdfa41ed66daa6b6b287e
BLAKE2b-256 d0b1d78adc4d89b616d4a7d915c6f1b1c1e7254fcc4eb38977b965440fd8ea43

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