Saturday, January 2, 2010

Python Wrapper of Google Language API with GAE Support

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:

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.