translation settings improvements
This commit is contained in:
parent
48360ea54c
commit
03e34cc43f
@ -76,8 +76,8 @@ class Toxygen(object):
|
|||||||
current_locale = QtCore.QLocale()
|
current_locale = QtCore.QLocale()
|
||||||
curr_lang = current_locale.languageToString(current_locale.language())
|
curr_lang = current_locale.languageToString(current_locale.language())
|
||||||
langs = Settings.supported_languages()
|
langs = Settings.supported_languages()
|
||||||
if curr_lang in map(lambda x: x[0], langs):
|
if curr_lang in langs:
|
||||||
lang_path = filter(lambda x: x[0] == curr_lang, langs)[0][1]
|
lang_path = langs[curr_lang]
|
||||||
translator = QtCore.QTranslator()
|
translator = QtCore.QTranslator()
|
||||||
translator.load(curr_directory() + '/translations/' + lang_path)
|
translator.load(curr_directory() + '/translations/' + lang_path)
|
||||||
app.installTranslator(translator)
|
app.installTranslator(translator)
|
||||||
@ -130,7 +130,7 @@ class Toxygen(object):
|
|||||||
else:
|
else:
|
||||||
settings.set_active_profile()
|
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 = QtCore.QTranslator()
|
||||||
translator.load(curr_directory() + '/translations/' + lang[1])
|
translator.load(curr_directory() + '/translations/' + lang[1])
|
||||||
app.installTranslator(translator)
|
app.installTranslator(translator)
|
||||||
|
13
src/menu.py
13
src/menu.py
@ -532,11 +532,10 @@ class InterfaceSettings(CenteredWidget):
|
|||||||
self.lang_choose = QtGui.QComboBox(self)
|
self.lang_choose = QtGui.QComboBox(self)
|
||||||
self.lang_choose.setGeometry(QtCore.QRect(30, 110, 160, 30))
|
self.lang_choose.setGeometry(QtCore.QRect(30, 110, 160, 30))
|
||||||
supported = Settings.supported_languages()
|
supported = Settings.supported_languages()
|
||||||
for elem in supported:
|
for key in supported:
|
||||||
self.lang_choose.addItem(elem[0])
|
self.lang_choose.insertItem(0, key)
|
||||||
lang = settings['language']
|
if settings['language'] == key:
|
||||||
index = map(lambda x: x[0], supported).index(lang)
|
self.lang_choose.setCurrentIndex(0)
|
||||||
self.lang_choose.setCurrentIndex(index)
|
|
||||||
self.lang = QtGui.QLabel(self)
|
self.lang = QtGui.QLabel(self)
|
||||||
self.lang.setGeometry(QtCore.QRect(30, 80, 121, 20))
|
self.lang.setGeometry(QtCore.QRect(30, 80, 121, 20))
|
||||||
self.lang.setFont(font)
|
self.lang.setFont(font)
|
||||||
@ -596,8 +595,8 @@ class InterfaceSettings(CenteredWidget):
|
|||||||
language = self.lang_choose.currentText()
|
language = self.lang_choose.currentText()
|
||||||
if settings['language'] != language:
|
if settings['language'] != language:
|
||||||
settings['language'] = language
|
settings['language'] = language
|
||||||
index = self.lang_choose.currentIndex()
|
text = self.lang_choose.currentText()
|
||||||
path = Settings.supported_languages()[index][1]
|
path = Settings.supported_languages()[text]
|
||||||
app = QtGui.QApplication.instance()
|
app = QtGui.QApplication.instance()
|
||||||
app.removeTranslator(app.translator)
|
app.removeTranslator(app.translator)
|
||||||
app.translator.load(curr_directory() + '/translations/' + path)
|
app.translator.load(curr_directory() + '/translations/' + path)
|
||||||
|
@ -163,7 +163,10 @@ class Profile(contact.Contact, Singleton):
|
|||||||
self._screen.typing.setVisible(False)
|
self._screen.typing.setVisible(False)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
if self._active_friend + 1:
|
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
|
self._active_friend = value
|
||||||
friend = self._friends[value]
|
friend = self._friends[value]
|
||||||
self._friends[value].reset_messages()
|
self._friends[value].reset_messages()
|
||||||
|
@ -125,11 +125,11 @@ class Settings(Singleton, dict):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def supported_languages():
|
def supported_languages():
|
||||||
return [
|
return {
|
||||||
('English', 'en_EN'),
|
'English': 'en_EN',
|
||||||
('Russian', 'ru_RU'),
|
'Russian': 'ru_RU',
|
||||||
('French', 'fr_FR')
|
'French': 'fr_FR'
|
||||||
]
|
}
|
||||||
|
|
||||||
def upgrade(self):
|
def upgrade(self):
|
||||||
default = Settings.get_default_settings()
|
default = Settings.get_default_settings()
|
||||||
|
Loading…
Reference in New Issue
Block a user