From 127b3cfabd1bd66e6c477be24de91e9e2ff7db97 Mon Sep 17 00:00:00 2001 From: Daniel Folkinshteyn Date: Sun, 11 Apr 2010 17:37:09 -0400 Subject: [PATCH] for google translate, error if destination language is 'auto'. --- plugins/Google/plugin.py | 3 +++ plugins/Google/test.py | 1 + 2 files changed, 4 insertions(+) diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index cbb95978f..1edafa76c 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -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)), diff --git a/plugins/Google/test.py b/plugins/Google/test.py index ca9b78207..0b73b504c 100644 --- a/plugins/Google/test.py +++ b/plugins/Google/test.py @@ -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+')