goslate
from accessing.Though a more sophisticated crawler may still work technically, however it would have crossed the fine line between using the service and breaking the service.goslate
will not be updated to break google’s ticket mechanism. Free lunch is over. Thanks for using.goslate
provides you free python API to google translation service by querying google translation website.Goslate().translate('Hi!','zh')
futures
pacakge is optional but recommended to install for best performance in large text translation task.(Translation-in-Native-Writing,Translation-in-Roman-Writing)
concurrent.futures
for concurent querying. The max worker number is 120 by default.concurrent.futures
backport lib in python2.7 (python3 has it by default) to enable concurrent querying.gs=Goslate(service_urls=['http://translate.google.de'])
goslate.py
is also a command line tool which you could use directlystdin
input into Chinese in GBK encoding--help
for detail usageGoslate.lookup_dictionary()
to get detail information for a single word/phrase, thanks for Adam’s suggestiongoslate.
Error
¶goslate.
Goslate
(writing=(u'trans', ), opener=None, retry_times=4, executor=None, timeout=4, service_urls=(u'http://translate.google.com', ), debug=False)¶Parameters: |
|
---|
goslate
will work under single thread modeExample: |
---|
detect
(text)¶Parameters: | text (UTF-8 str; unicode; sequence of string) – The source text(s) whose language you want to identify.Batch detection is supported via sequence input |
---|---|
Returns: | the language code(s)
|
Raises: | Error if parameter type or value is not valid |
get_languages
()¶Returns: | a dict of all supported language code and language name mapping {'language-code','Languagename'} |
---|---|
Example: |
lookup_dictionary
(text, target_language, source_language=u'auto', examples=False, etymology=False, pronunciation=False, related_words=False, synonyms=False, antonyms=False, output_language=None)¶Parameters: |
|
---|---|
Returns: | a complex list structure contains multiple translation meanings for this word/phrase and detail explaination. |
translate
(text, target_language, source_language=u'auto')¶Parameters: |
|
---|---|
Returns: | the translated text(s)
|
Raises: |
|
Example: |
Example: |
---|
goslate.
WRITING_NATIVE
= (u'trans',)¶goslate.
WRITING_NATIVE_AND_ROMAN
= (u'trans', u'translit')¶goslate.
WRITING_ROMAN
= (u'translit',)¶