Code is hosted here.
Licensed under MIT license.
Usage:
>>> from glanguage import Translator
>>> t = Translator()
>>> t.translate('Hello, World', lang_from='en', lang_to='fr')
'Bonjour tout le monde'
>>> what = t.detect('你好')
>>> what.lang
'Chinese_simplified'
>>> what.lang_code
'zh-CN'
>>> print what
<language: (chinese_simplified)="" zh-cn="">
>>>
If the value of lang_from in the translate() method is omitted,
the language of the original text will be detected automatically.
The value of lang_to is default to 'en'.
Support for Google App Engine is added. The usage stays the same
on GAE. I also did some simplification to the original code
found online.
A lot credit goes to Peteris Krumins (peter@catonmat.net), who
wrote the code originally.
2 comments:
Post a Comment