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

This commit is contained in:
Daniel Folkinshteyn 2010-04-11 17:37:09 -04:00
parent 34d91284a5
commit 127b3cfabd
2 changed files with 4 additions and 0 deletions

View File

@ -268,6 +268,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

@ -60,6 +60,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+')