def handler_babel_babel(type, source, parameters): splitdata = string.split(parameters) if len(splitdata) >= 3: from_lang = splitdata[0] to_lang = splitdata[1] body = string.join(splitdata[2:]) try: reply = babelizer.translate(body, from_lang, to_lang) except babelizer.LanguageNotAvailableError: reply = 'Invalid Language' except babelizer.BabelfishChangedError: print str(sys.exc_info()[0]) + ' - ' + str(sys.exc_info()[1]) reply = 'Unknown Error' else: reply = 'Syntax Error' if not reply: reply = 'No Results' reply = unicode(reply, 'utf-8') smsg(type, source, reply)
def translate_comment(self, phrase, from_lang='', to_lang='', REQUEST=None): """ """ if not phrase.strip(): return '' try: return babelizer.translate(phrase, from_lang, to_lang) except: return ''