Port socializer to Python 3. #16

This commit is contained in:
2019-01-02 04:42:53 +03:00
parent 1aeab0aef5
commit 4442931dd4
68 changed files with 967 additions and 1006 deletions

View File

@@ -1,4 +1,4 @@
import spellchecker
from . import spellchecker
import platform
if platform.system() == "Windows":
from wx_ui import *
from .wx_ui import *

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import logging
import wx_ui
import widgetUtils
import output
import config
@@ -8,6 +8,7 @@ import languageHandler
from enchant.checker import SpellChecker
from enchant.errors import DictNotFoundError
from enchant import tokenize
from . import wx_ui
log = logging.getLogger("extra.SpellChecker.spellChecker")
@@ -25,7 +26,7 @@ class spellChecker(object):
self.checker = SpellChecker(languageHandler.curLang, filters=[tokenize.EmailFilter, tokenize.URLFilter])
self.checker.set_text(text)
except DictNotFoundError:
print "no dict"
print("no dict")
log.exception("Dictionary for language %s not found." % (dictionary,))
wx_ui.dict_not_found_error()
self.active = False
@@ -42,9 +43,9 @@ class spellChecker(object):
def check(self):
try:
self.checker.next()
textToSay = _(u"Misspelled word: %s") % (self.checker.word,)
context = u"... %s %s %s" % (self.checker.leading_context(10), self.checker.word, self.checker.trailing_context(10))
next(self.checker)
textToSay = _("Misspelled word: %s") % (self.checker.word,)
context = "... %s %s %s" % (self.checker.leading_context(10), self.checker.word, self.checker.trailing_context(10))
self.dialog.set_title(textToSay)
output.speak(textToSay)
self.dialog.set_word_and_suggestions(word=self.checker.word, context=context, suggestions=self.checker.suggest())

View File

@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
############################################################
from __future__ import unicode_literals
import wx
import application
@@ -24,25 +25,25 @@ class spellCheckerDialog(wx.Dialog):
super(spellCheckerDialog, self).__init__(None, 1)
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
word = wx.StaticText(panel, -1, _(u"&Misspelled word"))
word = wx.StaticText(panel, -1, _("&Misspelled word"))
self.word = wx.TextCtrl(panel, -1)
wordBox = wx.BoxSizer(wx.HORIZONTAL)
wordBox.Add(word, 0, wx.ALL, 5)
wordBox.Add(self.word, 0, wx.ALL, 5)
context = wx.StaticText(panel, -1, _(u"Con&text"))
context = wx.StaticText(panel, -1, _("Con&text"))
self.context = wx.TextCtrl(panel, -1)
contextBox = wx.BoxSizer(wx.HORIZONTAL)
contextBox.Add(context, 0, wx.ALL, 5)
contextBox.Add(self.context, 0, wx.ALL, 5)
suggest = wx.StaticText(panel, -1, _(u"&Suggestions"))
suggest = wx.StaticText(panel, -1, _("&Suggestions"))
self.suggestions = wx.ListBox(panel, -1, choices=[], style=wx.LB_SINGLE)
suggestionsBox = wx.BoxSizer(wx.HORIZONTAL)
suggestionsBox.Add(suggest, 0, wx.ALL, 5)
suggestionsBox.Add(self.suggestions, 0, wx.ALL, 5)
self.ignore = wx.Button(panel, -1, _(u"&Ignore"))
self.ignoreAll = wx.Button(panel, -1, _(u"Ignore &all"))
self.replace = wx.Button(panel, -1, _(u"&Replace"))
self.replaceAll = wx.Button(panel, -1, _(u"Replace a&ll"))
self.ignore = wx.Button(panel, -1, _("&Ignore"))
self.ignoreAll = wx.Button(panel, -1, _("Ignore &all"))
self.replace = wx.Button(panel, -1, _("&Replace"))
self.replaceAll = wx.Button(panel, -1, _("Replace a&ll"))
close = wx.Button(panel, wx.ID_CANCEL)
btnBox = wx.BoxSizer(wx.HORIZONTAL)
btnBox.Add(self.ignore, 0, wx.ALL, 5)
@@ -73,7 +74,7 @@ class spellCheckerDialog(wx.Dialog):
return self.suggestions.GetStringSelection()
def dict_not_found_error():
wx.MessageDialog(None, _(u"An error has occurred. There are no dictionaries available for the selected language in {0}").format(application.name,), _(u"Error"), wx.ICON_ERROR).ShowModal()
wx.MessageDialog(None, _("An error has occurred. There are no dictionaries available for the selected language in {0}").format(application.name,), _("Error"), wx.ICON_ERROR).ShowModal()
def finished():
wx.MessageDialog(None, _(u"Spell check complete."), application.name, style=wx.OK).ShowModal()
wx.MessageDialog(None, _("Spell check complete."), application.name, style=wx.OK).ShowModal()

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
import translator
import platform
from . import translator
if platform.system() == "Windows":
import wx_ui as gui
from . import wx_ui as gui

View File

@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from builtins import zip
from yandex_translate import YandexTranslate
def translate(text="", target="en"):
@@ -9,97 +11,97 @@ def translate(text="", target="en"):
supported_langs = None
d = None
languages = {
"af": _(u"Afrikaans"),
"sq": _(u"Albanian"),
"am": _(u"Amharic"),
"ar": _(u"Arabic"),
"hy": _(u"Armenian"),
"az": _(u"Azerbaijani"),
"eu": _(u"Basque"),
"be": _(u"Belarusian"),
"bn": _(u"Bengali"),
"bh": _(u"Bihari"),
"bg": _(u"Bulgarian"),
"my": _(u"Burmese"),
"ca": _(u"Catalan"),
"chr": _(u"Cherokee"),
"zh": _(u"Chinese"),
"zh-CN": _(u"Chinese_simplified"),
"zh-TW": _(u"Chinese_traditional"),
"hr": _(u"Croatian"),
"cs": _(u"Czech"),
"da": _(u"Danish"),
"dv": _(u"Dhivehi"),
"nl": _(u"Dutch"),
"en": _(u"English"),
"eo": _(u"Esperanto"),
"et": _(u"Estonian"),
"tl": _(u"Filipino"),
"fi": _(u"Finnish"),
"fr": _(u"French"),
"gl": _(u"Galician"),
"ka": _(u"Georgian"),
"de": _(u"German"),
"el": _(u"Greek"),
"gn": _(u"Guarani"),
"gu": _(u"Gujarati"),
"iw": _(u"Hebrew"),
"hi": _(u"Hindi"),
"hu": _(u"Hungarian"),
"is": _(u"Icelandic"),
"id": _(u"Indonesian"),
"iu": _(u"Inuktitut"),
"ga": _(u"Irish"),
"it": _(u"Italian"),
"ja": _(u"Japanese"),
"kn": _(u"Kannada"),
"kk": _(u"Kazakh"),
"km": _(u"Khmer"),
"ko": _(u"Korean"),
"ku": _(u"Kurdish"),
"ky": _(u"Kyrgyz"),
"lo": _(u"Laothian"),
"lv": _(u"Latvian"),
"lt": _(u"Lithuanian"),
"mk": _(u"Macedonian"),
"ms": _(u"Malay"),
"ml": _(u"Malayalam"),
"mt": _(u"Maltese"),
"mr": _(u"Marathi"),
"mn": _(u"Mongolian"),
"ne": _(u"Nepali"),
"no": _(u"Norwegian"),
"or": _(u"Oriya"),
"ps": _(u"Pashto"),
"fa": _(u"Persian"),
"pl": _(u"Polish"),
"pt": _(u"Portuguese"),
"pa": _(u"Punjabi"),
"ro": _(u"Romanian"),
"ru": _(u"Russian"),
"sa": _(u"Sanskrit"),
"sr": _(u"Serbian"),
"sd": _(u"Sindhi"),
"si": _(u"Sinhalese"),
"sk": _(u"Slovak"),
"sl": _(u"Slovenian"),
"es": _(u"Spanish"),
"sw": _(u"Swahili"),
"sv": _(u"Swedish"),
"tg": _(u"Tajik"),
"ta": _(u"Tamil"),
"tl": _(u"Tagalog"),
"te": _(u"Telugu"),
"th": _(u"Thai"),
"bo": _(u"Tibetan"),
"tr": _(u"Turkish"),
"uk": _(u"Ukrainian"),
"ur": _(u"Urdu"),
"uz": _(u"Uzbek"),
"ug": _(u"Uighur"),
"vi": _(u"Vietnamese"),
"cy": _(u"Welsh"),
"yi": _(u"Yiddish")
"af": _("Afrikaans"),
"sq": _("Albanian"),
"am": _("Amharic"),
"ar": _("Arabic"),
"hy": _("Armenian"),
"az": _("Azerbaijani"),
"eu": _("Basque"),
"be": _("Belarusian"),
"bn": _("Bengali"),
"bh": _("Bihari"),
"bg": _("Bulgarian"),
"my": _("Burmese"),
"ca": _("Catalan"),
"chr": _("Cherokee"),
"zh": _("Chinese"),
"zh-CN": _("Chinese_simplified"),
"zh-TW": _("Chinese_traditional"),
"hr": _("Croatian"),
"cs": _("Czech"),
"da": _("Danish"),
"dv": _("Dhivehi"),
"nl": _("Dutch"),
"en": _("English"),
"eo": _("Esperanto"),
"et": _("Estonian"),
"tl": _("Filipino"),
"fi": _("Finnish"),
"fr": _("French"),
"gl": _("Galician"),
"ka": _("Georgian"),
"de": _("German"),
"el": _("Greek"),
"gn": _("Guarani"),
"gu": _("Gujarati"),
"iw": _("Hebrew"),
"hi": _("Hindi"),
"hu": _("Hungarian"),
"is": _("Icelandic"),
"id": _("Indonesian"),
"iu": _("Inuktitut"),
"ga": _("Irish"),
"it": _("Italian"),
"ja": _("Japanese"),
"kn": _("Kannada"),
"kk": _("Kazakh"),
"km": _("Khmer"),
"ko": _("Korean"),
"ku": _("Kurdish"),
"ky": _("Kyrgyz"),
"lo": _("Laothian"),
"lv": _("Latvian"),
"lt": _("Lithuanian"),
"mk": _("Macedonian"),
"ms": _("Malay"),
"ml": _("Malayalam"),
"mt": _("Maltese"),
"mr": _("Marathi"),
"mn": _("Mongolian"),
"ne": _("Nepali"),
"no": _("Norwegian"),
"or": _("Oriya"),
"ps": _("Pashto"),
"fa": _("Persian"),
"pl": _("Polish"),
"pt": _("Portuguese"),
"pa": _("Punjabi"),
"ro": _("Romanian"),
"ru": _("Russian"),
"sa": _("Sanskrit"),
"sr": _("Serbian"),
"sd": _("Sindhi"),
"si": _("Sinhalese"),
"sk": _("Slovak"),
"sl": _("Slovenian"),
"es": _("Spanish"),
"sw": _("Swahili"),
"sv": _("Swedish"),
"tg": _("Tajik"),
"ta": _("Tamil"),
"tl": _("Tagalog"),
"te": _("Telugu"),
"th": _("Thai"),
"bo": _("Tibetan"),
"tr": _("Turkish"),
"uk": _("Ukrainian"),
"ur": _("Urdu"),
"uz": _("Uzbek"),
"ug": _("Uighur"),
"vi": _("Vietnamese"),
"cy": _("Welsh"),
"yi": _("Yiddish")
}
def available_languages():

View File

@@ -16,15 +16,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
############################################################
import translator
from __future__ import unicode_literals
import wx
from . import translator
class translateDialog(wx.Dialog):
def __init__(self):
super(translateDialog, self).__init__(None, -1, title=_(u"Translate message"))
super(translateDialog, self).__init__(None, -1, title=_("Translate message"))
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
staticDest = wx.StaticText(panel, -1, _(u"Target language"))
staticDest = wx.StaticText(panel, -1, _("Target language"))
self.dest_lang = wx.ComboBox(panel, -1, choices=[x[1] for x in translator.available_languages()], style = wx.CB_READONLY)
self.dest_lang.SetFocus()
self.dest_lang.SetSelection(0)