A translation package
Project description
translation is a python translation package based on website service.
It provids google, youdao, baidu, iciba translation service.
Installation
pip install translation
Usage
from translation import baidu, google, youdao, iciba
print(google('hello world!', dst = 'zh-CN'))
print(google('hello world!', dst = 'ru'))
print(baidu('hello world!', dst = 'zh'))
print(baidu('hello world!', dst = 'ru'))
print(youdao('hello world!', dst = 'zh-CN'))
print(iciba('hello world!', dst = 'zh'))
print(bing('hello world!', dst = 'zh-CHS'))
Documents
You may find document here
Advanced usage
Proxies
You may not use some of the function without proxies.
Proxies can be set as following.
from translation import google, ConnectError
# 127.0.0.1:1080 is a vaild proxies
try:
print(google('hello world!', dst = 'zh-CN', proxies = {'http': '127.0.0.1:1080'}))
except ConnectError:
print('Invaild proxy')
Default
You may change default setting such as:
default source language (auto if not set)
default destination language (zh-CN if not set)
default translation (youdao if not set)
default proxies (no proxy if not set)
from translation import (set_default_translation, set_default_language,
set_default_proxies, get, ConnectError)
set_default_translation('google')
set_default_language('auto', 'zh-CN')
set_default_proxies({'http': '127.0.0.1:1080'})
try:
print(get('hello world!'))
except ConnectError:
print('Invaild proxy')
More
More functions are introduced in the document.
Language
Language list of all the translation are provided in document.
Somehow, iciba and youdao can only provide English translation.
el : Greek,
eo : Esperanto,
en : English,
af : Afrikaans,
sw : Swahili,
ca : Catalan,
it : Italian,
iw : Hebrew,
sv : Swedish,
cs : Czech,
cy : Welsh,
ar : Arabic,
ur : Urdu,
ga : Irish,
eu : Basque,
et : Estonian,
az : Azerbaijani,
id : Indonesian,
es : Spanish,
ru : Russian,
gl : Galician,
nl : Dutch,
pt : Portuguese,
la : Latin,
tr : Turkish,
tl : Filipino,
lv : Latvian,
lt : Lithuanian,
th : Thai,
vi : Vietnamese,
gu : Gujarati,
ro : Romanian,
is : Icelandic,
pl : Polish,
ta : Tamil,
yi : Yiddish,
be : Belarusian,
fr : French,
bg : Bulgarian,
uk : Ukrainian,
hr : Croatian,
bn : Bengali,
sl : Slovenian,
ht : Haitian Creole,
da : Danish,
fa : Persian,
hi : Hindi,
fi : Finnish,
hu : Hungarian,
ja : Japanese,
ka : Georgian,
te : Telugu,
zh-TW : Chinese Traditional,
sq : Albanian,
no : Norwegian,
ko : Korean,
kn : Kannada,
mk : Macedonian,
zh-CN : Chinese Simplified,
sk : Slovak,
mt : Maltese,
de : German,
ms : Malay,
sr : Serbian
Comments
If you have any problem or suggestion, you may contact me in this issue.
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
Built Distributions
File details
Details for the file translation-1.0.5.zip
.
File metadata
- Download URL: translation-1.0.5.zip
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6228e2ae4882a3dae73a8b5b1864f2df1e22a07a186b9ad26aa8094f9b5db627 |
|
MD5 | 78e3332c141b06eb85c3ef002e375ab0 |
|
BLAKE2b-256 | abc11e498a4df819838794db35a50a2483079b35c9911aaa0e300214ca70e2e4 |
File details
Details for the file translation-1.0.5-py3-none-any.whl
.
File metadata
- Download URL: translation-1.0.5-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64dfdb33c2203130eba683214f38428a97e77c74d842e2d0e7e406df77f98a81 |
|
MD5 | 2eeac0b0aed30eaf1893f3b3596a01f6 |
|
BLAKE2b-256 | 7cb08e2c6a46d36ccb52c2e05a3b81c9d7ad8fd3a99193bb378400899b3d812c |
File details
Details for the file translation-1.0.5-py2-none-any.whl
.
File metadata
- Download URL: translation-1.0.5-py2-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e44349b6e4e6a8cca82a90d2ee218472d75d08000b6f000bd40d9865b8ef1a28 |
|
MD5 | b266fa33cf6439ef005c37a184488d98 |
|
BLAKE2b-256 | 461fe3e54131591e62f6604ccc77bdd4bff95292cc03d698ba821da0c99782c4 |