Fixed translator for handling UTF-8 characters as input

This commit is contained in:
Manuel Cortez 2016-02-25 05:08:19 -06:00
parent 34b6a50e47
commit b0b3086540

View File

@ -27,21 +27,21 @@ class post(object):
def translate(self, *args, **kwargs): def translate(self, *args, **kwargs):
dlg = translator.gui.translateDialog() dlg = translator.gui.translateDialog()
if dlg.get_response() == widgetUtils.OK: if dlg.get_response() == widgetUtils.OK:
text_to_translate = self.message.get_text().encode("utf-8") text_to_translate = self.message.get_text()
source = [x[0] for x in translator.translator.available_languages()][dlg.get("source_lang")] source = [x[0] for x in translator.translator.available_languages()][dlg.get("source_lang")]
dest = [x[0] for x in translator.translator.available_languages()][dlg.get("dest_lang")] dest = [x[0] for x in translator.translator.available_languages()][dlg.get("dest_lang")]
msg = translator.translator.translate(text_to_translate, source, dest) msg = translator.translator.translate(text_to_translate, source, dest)
self.message.set_text(msg) self.message.set_text(msg)
self.message.text_focus() self.message.text_focus()
output.speak(_(u"Translated")) output.speak(_(u"Translated"))
else: dlg.Destroy()
return
def spellcheck(self, event=None): def spellcheck(self, event=None):
text = self.message.get_text() text = self.message.get_text()
checker = SpellChecker.spellchecker.spellChecker(text, "") checker = SpellChecker.spellchecker.spellChecker(text, "")
if hasattr(checker, "fixed_text"): if hasattr(checker, "fixed_text"):
self.message.set_text(checker.fixed_text) self.message.set_text(checker.fixed_text)
checker.clean()
# def attach(self, *args, **kwargs): # def attach(self, *args, **kwargs):
# def completed_callback(): # def completed_callback():