Google翻訳が有料になるらしいので

bing翻訳に移行 精度もかなりいいらしい.
# -*- coding: utf8 -*-
import urllib
import urllib2
from xml.etree.ElementTree import *

#bing翻訳から訳を得る
class Translator:
 def __init__(self, langFrom='en', langTo='ja'):
  self.data = {
   "appid": <キー>,
   "from": langFrom,
   "to": langTo,
  }
 def translate(self, text):
  try:
   self.data['text'] = text
   req = urllib2.Request(
    "http://api.microsofttranslator.com/V2/Http.svc/Translate?" + urllib.urlencode(self.data),
    None,
    {'Referer': 'http://www.microsofttranslator.com/'})
   responseText = urllib2.urlopen(req).read()
   return fromstring(responseText).text
  except urllib2.URLError:
   return u"error: cannot access"

if __name__ == '__main__':
 t = Translator()
 print t.translate('Hello.')