コード例 #1
0
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)
コード例 #2
0
ファイル: babel_plugin.py プロジェクト: MContagious/neutron
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)
コード例 #3
0
ファイル: NyReport.py プロジェクト: eaudeweb/naaya
 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 ''
コード例 #4
0
ファイル: NyReport.py プロジェクト: Hamzahashmi4444/Salman-
 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 ''