for google translate, error if destination language is 'auto'.

This commit is contained in:
Daniel Folkinshteyn 2010-04-11 17:37:09 -04:00 committed by Valentin Lorentz
parent 261a646451
commit 8d45228642
2 changed files with 4 additions and 0 deletions

View File

@ -284,6 +284,9 @@ class Google(callbacks.PluginRegexp):
toLang = lang.normalize('lang_'+toLang)[5:]
if fromLang == 'auto':
fromLang = ''
if toLang == 'auto':
irc.error("Destination language cannot be 'auto'.")
return
opts['langpair'] = '%s|%s' % (fromLang, toLang)
fd = utils.web.getUrlFd('%s?%s' % (self._gtranslateUrl,
urllib.urlencode(opts)),

View File

@ -62,6 +62,7 @@ class GoogleTestCase(ChannelPluginTestCase):
def testTranslate(self):
self.assertRegexp('translate en es hello world', 'mundo')
self.assertRegexp('translate auto en ciao', 'Italian.*hello')
self.assertError('translate en to auto stuff')
def testCalcDoesNotHaveExtraSpaces(self):
self.assertNotRegexp('google calc 1000^2', r'\s+,\s+')