Rewrited languagebox module a bit

This commit is contained in:
Dmitri Bogomolov 2018-03-01 16:48:36 +02:00
parent 825ac4da00
commit 0bd1fe5a9c
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

View File

@ -22,12 +22,11 @@ class LanguageBox(QtWidgets.QComboBox):
self.languages = []
self.clear()
localesPath = os.path.join(paths.codePath(), 'translations')
configuredLocale = "system"
try:
configuredLocale = BMConfigParser().get(
'bitmessagesettings', 'userlocale', "system")
except:
pass
configuredLocale = "system"
self.addItem(
_translate("settingsDialog", "System Settings", "system"),
"system"
@ -39,14 +38,13 @@ class LanguageBox(QtWidgets.QComboBox):
):
localeShort = \
os.path.split(translationFile)[1].split("_", 1)[1][:-3]
locale = QtCore.QLocale(localeShort)
if localeShort in LanguageBox.languageName:
self.addItem(
LanguageBox.languageName[localeShort], localeShort)
elif locale.nativeLanguageName() == "":
self.addItem(localeShort, localeShort)
else:
self.addItem(locale.nativeLanguageName(), localeShort)
locale = QtCore.QLocale(localeShort)
self.addItem(
locale.nativeLanguageName() or localeShort, localeShort)
for i in range(self.count()):
if self.itemData(i) == configuredLocale:
self.setCurrentIndex(i)