diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index ff056e7ca..437791cde 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -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)), diff --git a/plugins/Google/test.py b/plugins/Google/test.py index 3ef6eca81..e3c461aeb 100644 --- a/plugins/Google/test.py +++ b/plugins/Google/test.py @@ -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+')