A little python to parse Google Translate webpages
Project description
pyGoogleTranslate
A python module for Google Translate (without using the API)
This module lets you get two things:
- translate(text, destination_language, source_language)
Translates the given text into the chosen language.
text: The text to translate
destination_language: The language code (two letters) of the language you want to get.
source_language (default: auto): The language code (two letters) of the language the text is in. ('auto' detects automatically the language the text is in)
- detect_language(text, result_language)
Gives the language of the given text.
text: The text to check.
result_language: The language code (two letters) of the output language.
Installation
You can install pyGoogleTranslate via PIP the Python Package Index Manager.
pip install pyGoogleTranslate
But you also need to install a compatible browser:
| Browser | browser() command | Installation | Notes |
|---|---|---|---|
| PhantomJS | pyGoogleTranslate.browser('phantomjs') |
On macOS with Homebrew brew cask install phantomjs |
PhantomJS is not maintained anymore but is the most lightweight of all three. ⚠️It seems to not handle Japanese Characters well when rendering. |
| Firefox | pyGoogleTranslate.browser('firefox') |
Install Firefox (with the name Firefox) and install the driver (on macOS with Homebrew brew install geckodriver) |
I tested pyGoogleTranslate on Firefox and it seems to be quite long to start but works well with Japanese Characters which seemed to not work with PhantomJS |
| Chrome | pyGoogleTranslate.browser('chrome') |
Install Google Chrome and install the driver (on macOS with Homebrew brew cask install chromedriver) |
Same as Firefox. |
Usage
import pyGoogleTranslate
>>> pyGoogleTranslate.browser('<browser you want to use>')
>>> pyGoogleTranslate.translate('Hello', 'ja')
'こんにちは'
>>> pyGoogleTranslate.translate('Bonjour', source_language='fr', destination_language='en')
'Hello'
>>> pyGoogleTranslate.detect_language('Hola')
'Spanish'
>>> pyGoogleTranslate.detect_language('Hola', 'es')
'español'
>>> pyGoogleTranslate.detect_language('Nihao')
'Chinese'
>>> pyGoogleTranslate.detect_language('このPythonモジュールをダウンロード頂き誠にありがとうございました。')
'Japanese'
Dependencies
This module has one python module dependency: Selenium, used to automate browsers which is downloaded when installing python-google-translate with PIP.
Google Translate belongs to Google LLC, fully owned by Alphabet Inc.
© Anime no Sekai - 2020
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyGoogleTranslate-2.0.tar.gz.
File metadata
- Download URL: pyGoogleTranslate-2.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21104d69bd7ac83580e526a5357e0b6552969bf1ad0cc93563471ba76b09e47c
|
|
| MD5 |
3f897321038b973a36409b235d36b293
|
|
| BLAKE2b-256 |
bcf5adbd6ceba51d255a9a89c20808f84ca0b1d31e1c6ea7c50f581c8261db2d
|
File details
Details for the file pyGoogleTranslate-2.0-py3-none-any.whl.
File metadata
- Download URL: pyGoogleTranslate-2.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b4079d973716303adaa69012539591518a2ad5b4884851ef59d2b7271032b4d
|
|
| MD5 |
9f4a6dee42fdc6a3c836d3e6c89bdcf2
|
|
| BLAKE2b-256 |
c2d22cba40c007420a02111632062ab0d52eec98a1520c2f2cb3c44d638285f3
|