Skip to content

Commit

Permalink
update languages for ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Gajenthran committed Mar 21, 2019
1 parent 4a6aa1e commit 40cf0b0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lisp/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"theme": "Dark",
"icons": "numix"
},
"language": "en",
"locale": "",
"session": {
"minSave": true
},
Expand Down
5 changes: 3 additions & 2 deletions lisp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ def main():
if locale:
QLocale().setDefault(QLocale(locale))
else:
locale = app_conf["language"]
QLocale().setDefault(QLocale(locale))
locale = app_conf["locale"]
if locale != "":
QLocale().setDefault(QLocale(locale))

logging.info(
'Using "{}" locale -> {}'.format(
Expand Down
31 changes: 16 additions & 15 deletions lisp/ui/settings/app_pages/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,26 @@
from lisp.ui.settings.pages import SettingsPage
from lisp.ui.themes import themes_names
from lisp.ui.ui_utils import translate
import os
import re

try:
from os import scandir, getcwd
except ImportError:
from scandir import scandir


class AppGeneral(SettingsPage):
Name = QT_TRANSLATE_NOOP("SettingsPageName", "General")

def __init__(self, **kwargs):
super().__init__(**kwargs)

languages = []
for entry in scandir("lisp/i18n/ts/"):
if entry.is_dir():
languages.append(entry.name[:2])
self.locales = {
"cs" : "český",
"de" : "Deutsche",
"fr" : "Français",
"es" : "Español",
"en" : "English",
"it" : "Italiano",
"nl" : "Nederlands (Belgique)",
}

self.languagesItem = []
for loc in self.locales:
self.languagesItem.append(self.locales[loc])

self.setLayout(QVBoxLayout())
self.layout().setAlignment(Qt.AlignTop)
Expand Down Expand Up @@ -84,7 +85,7 @@ def __init__(self, **kwargs):
self.languagesLabel = QLabel(self.themeGroup)
self.themeGroup.layout().addWidget(self.languagesLabel, 2, 0)
self.languagesCombo = QComboBox(self.themeGroup)
self.languagesCombo.addItems(languages)
self.languagesCombo.addItems(self.languagesItem)
self.themeGroup.layout().addWidget(self.languagesCombo, 2 ,1)

self.iconsLabel = QLabel(self.themeGroup)
Expand Down Expand Up @@ -117,7 +118,7 @@ def getSettings(self):
"theme": self.themeCombo.currentText(),
"icons": self.iconsCombo.currentText(),
},
"language": self.languagesCombo.currentText(),
"locale": list(self.locales.keys())[list(self.locales.values()).index(self.languagesCombo.currentText())],
"layout": {},
}

Expand All @@ -139,4 +140,4 @@ def loadSettings(self, settings):

self.themeCombo.setCurrentText(settings["theme"]["theme"])
self.iconsCombo.setCurrentText(settings["theme"]["icons"])
self.languagesCombo.setCurrentText(settings["language"])
self.languagesCombo.setCurrentText(self.locales[settings["locale"]])

0 comments on commit 40cf0b0

Please sign in to comment.