Fix for bug #1028749, bad listing of babelfish languages.

This commit is contained in:
James Vega 2004-09-15 20:05:27 +00:00
parent 8f8a97261d
commit 105c371f6c

View File

@ -120,9 +120,13 @@ class Babelfish(callbacks.Privmsg):
translation = babelfish.translate(text, fromLang, toLang) translation = babelfish.translate(text, fromLang, toLang)
irc.reply(translation) irc.reply(translation)
except (KeyError, babelfish.LanguageNotAvailableError), e: except (KeyError, babelfish.LanguageNotAvailableError), e:
irc.error('%s is not a valid language. Valid languages ' languages = self.registryValue('languages', chan)
'include %s.' % if languages:
(e, self.registryValue('languages', chan))) languages = 'Valid languages include %s' % \
utils.commaAndify(sorted(languages))
else:
languages = 'I do not speak any other languages.'
irc.errorInvalid('language', str(e), languages)
except babelfish.BabelizerIOError, e: except babelfish.BabelizerIOError, e:
irc.error(str(e)) irc.error(str(e))
except babelfish.BabelfishChangedError, e: except babelfish.BabelfishChangedError, e:
@ -155,9 +159,13 @@ class Babelfish(callbacks.Privmsg):
translations = babelfish.babelize(text, fromLang, toLang) translations = babelfish.babelize(text, fromLang, toLang)
irc.reply(utils.htmlToText(translations[-1])) irc.reply(utils.htmlToText(translations[-1]))
except (KeyError, babelfish.LanguageNotAvailableError), e: except (KeyError, babelfish.LanguageNotAvailableError), e:
irc.reply('%s is not a valid language. Valid languages ' languages = self.registryValue('languages', chan)
'include %s.' % (e, if languages:
self.registryValue('languages', chan))) languages = 'Valid languages include %s' % \
utils.commaAndify(sorted(languages))
else:
languages = 'I do not speak any other languages.'
irc.errorInvalid('language', str(e), languages)
except babelfish.BabelizerIOError, e: except babelfish.BabelizerIOError, e:
irc.reply(e) irc.reply(e)
except babelfish.BabelfishChangedError, e: except babelfish.BabelfishChangedError, e: