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:
|
for language in babelfish.available_languages:
|
||||||
_abbrevs[language] = language
|
_abbrevs[language] = language
|
||||||
def translate(self, irc, msg, args):
|
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>.
|
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)
|
(fromLang, toLang, text) = privmsgs.getArgs(args, required=3)
|
||||||
try:
|
try:
|
||||||
fromLang = self._abbrevs[fromLang.lower()]
|
fromLang = self._abbrevs[fromLang.lower()]
|
||||||
|
@ -37,6 +37,8 @@ if network:
|
|||||||
def testTranslate(self):
|
def testTranslate(self):
|
||||||
self.assertResponse('translate en sp food',
|
self.assertResponse('translate en sp food',
|
||||||
'alimento')
|
'alimento')
|
||||||
|
self.assertResponse('translate en to sp food',
|
||||||
|
'alimento')
|
||||||
self.assertError('translate foo en food')
|
self.assertError('translate foo en food')
|
||||||
self.assertError('translate en foo food')
|
self.assertError('translate en foo food')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user