mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Added optional 'to' handling to translate.
This commit is contained in:
parent
64b368381f
commit
73a660164d
@ -68,10 +68,12 @@ class Babelfish(callbacks.Privmsg):
|
||||
for language in babelfish.available_languages:
|
||||
_abbrevs[language] = language
|
||||
def translate(self, irc, msg, args):
|
||||
"""<from-language> <to-language> <text>
|
||||
"""<from-language> [to] <to-language> <text>
|
||||
|
||||
Returns <text> translated from <from-language> into <to-language>.
|
||||
"""
|
||||
if len(args) >= 2 and args[1] == 'to':
|
||||
args.pop(1)
|
||||
(fromLang, toLang, text) = privmsgs.getArgs(args, required=3)
|
||||
try:
|
||||
fromLang = self._abbrevs[fromLang.lower()]
|
||||
|
@ -37,6 +37,8 @@ if network:
|
||||
def testTranslate(self):
|
||||
self.assertResponse('translate en sp food',
|
||||
'alimento')
|
||||
self.assertResponse('translate en to sp food',
|
||||
'alimento')
|
||||
self.assertError('translate foo en food')
|
||||
self.assertError('translate en foo food')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user