Online translation as a Python module & command line tool. No key, no authentication needed.
Python Makefile
Latest commit 35a8a8b Jun 15, 2015 @terryyin Merge pull request #20 from terryyin/revert-18-revert-16-master
Revert "wrong order ...."
Permalink
Failed to load latest commit information.
test switch to mymemory Apr 13, 2015
.gitignore translate from en to en May 6, 2013
.travis.yml add files May 6, 2013
MANIFEST new version Feb 14, 2015
Makefile translate from en to en May 6, 2013
README.rst publish new Apr 13, 2015
setup.py publish new Apr 13, 2015
translate switch to mymemory Apr 13, 2015
translate.py Revert "wrong order ...." Jun 15, 2015

README.rst

google-translate-python

Now google has stop providing free translation API. So I have to switch to http://mymemory.translated.net/, which has a limit for 1000 words/day free usage. Please let me know if there's any other better free translation API.

The default from language is English (en). The default to language is Simplified Chinese (zh). Of course, you can specify it in the parameter or commandline.

利用google translate实现的命令行工具(translate),也可以当做Python模块用在你的代码中。

Installation

pip install translate

Or, you can download the source and

python setup.py install

Add sudo in the beginning if you met problem.

Command-Line Usage

In your command-line:

translate "This is a pen."

Or

translate -f zh -t ja 我是谁?

Use As A Python Module

from translate import Translator
translator= Translator(to_lang="zh")
translation = translator.translate("This is a pen.")

The result is in translation, and it’s usually a unicode string.

Change Default Languages

In ~/.python-translate.cfg:

[DEFAULT]
from_lang = auto
to_lang = 'de'

The cfg is not for using as a Python module.