translation settings improvements

This commit is contained in:
ingvar1995 2016-06-18 23:50:12 +03:00
parent 48360ea54c
commit 03e34cc43f
4 changed files with 18 additions and 16 deletions

View File

@ -76,8 +76,8 @@ class Toxygen(object):
current_locale = QtCore.QLocale()
curr_lang = current_locale.languageToString(current_locale.language())
langs = Settings.supported_languages()
if curr_lang in map(lambda x: x[0], langs):
lang_path = filter(lambda x: x[0] == curr_lang, langs)[0][1]
if curr_lang in langs:
lang_path = langs[curr_lang]
translator = QtCore.QTranslator()
translator.load(curr_directory() + '/translations/' + lang_path)
app.installTranslator(translator)
@ -130,7 +130,7 @@ class Toxygen(object):
else:
settings.set_active_profile()
lang = filter(lambda x: x[0] == settings['language'], Settings.supported_languages())[0]
lang = Settings.supported_languages()[settings['language']]
translator = QtCore.QTranslator()
translator.load(curr_directory() + '/translations/' + lang[1])
app.installTranslator(translator)

View File

@ -532,11 +532,10 @@ class InterfaceSettings(CenteredWidget):
self.lang_choose = QtGui.QComboBox(self)
self.lang_choose.setGeometry(QtCore.QRect(30, 110, 160, 30))
supported = Settings.supported_languages()
for elem in supported:
self.lang_choose.addItem(elem[0])
lang = settings['language']
index = map(lambda x: x[0], supported).index(lang)
self.lang_choose.setCurrentIndex(index)
for key in supported:
self.lang_choose.insertItem(0, key)
if settings['language'] == key:
self.lang_choose.setCurrentIndex(0)
self.lang = QtGui.QLabel(self)
self.lang.setGeometry(QtCore.QRect(30, 80, 121, 20))
self.lang.setFont(font)
@ -596,8 +595,8 @@ class InterfaceSettings(CenteredWidget):
language = self.lang_choose.currentText()
if settings['language'] != language:
settings['language'] = language
index = self.lang_choose.currentIndex()
path = Settings.supported_languages()[index][1]
text = self.lang_choose.currentText()
path = Settings.supported_languages()[text]
app = QtGui.QApplication.instance()
app.removeTranslator(app.translator)
app.translator.load(curr_directory() + '/translations/' + path)

View File

@ -163,7 +163,10 @@ class Profile(contact.Contact, Singleton):
self._screen.typing.setVisible(False)
if value is not None:
if self._active_friend + 1:
self._friends[self._active_friend].curr_text = self._screen.messageEdit.toPlainText()
try:
self._friends[self._active_friend].curr_text = self._screen.messageEdit.toPlainText()
except:
pass
self._active_friend = value
friend = self._friends[value]
self._friends[value].reset_messages()

View File

@ -125,11 +125,11 @@ class Settings(Singleton, dict):
@staticmethod
def supported_languages():
return [
('English', 'en_EN'),
('Russian', 'ru_RU'),
('French', 'fr_FR')
]
return {
'English': 'en_EN',
'Russian': 'ru_RU',
'French': 'fr_FR'
}
def upgrade(self):
default = Settings.get_default_settings()