Added code to apply default language before qml is loaded.

This commit is contained in:
Sale Djenic 2021-07-28 14:50:48 +02:00 committed by Iuri Matias
parent c1b47f1c9c
commit c8e3fd8735
3 changed files with 18 additions and 2 deletions

View File

@ -28,6 +28,8 @@ proc mainProc() =
if defined(macosx) and defined(production):
setCurrentDir(getAppDir())
var currentLanguageCode: string
let fleets =
if defined(windows) and defined(production):
"/../resources/fleets.json"
@ -137,6 +139,10 @@ proc mainProc() =
engine.setRootContextProperty("browserModel", browserController.variant)
proc changeLanguage(locale: string) =
if (locale == currentLanguageCode):
return
currentLanguageCode = locale
engine.setTranslationPackage(joinPath(i18nPath, fmt"qml_{locale}.qm"))
var profile = profile.newController(status, changeLanguage)
@ -210,6 +216,11 @@ proc mainProc() =
var prValue = newQVariant(if defined(production): true else: false)
engine.setRootContextProperty("production", prValue)
# We're applying default language before we load qml. Also we're aware that
# switch language at runtime will have some impact to cpu usage.
# https://doc.qt.io/archives/qtjambi-4.5.2_01/com/trolltech/qt/qtjambi-linguist-programmers.html
changeLanguage("en")
engine.load(newQUrl("qrc:///main.qml"))
# Please note that this must use the `cdecl` calling convention because

View File

@ -413,9 +413,10 @@ StatusAppLayout {
Connections {
target: profileModel.settings
onSettingsFileChanged: {
onGlobalSettingsFileChanged: {
profileModel.changeLocale(globalSettings.locale)
}
onSettingsFileChanged: {
// Since https://github.com/status-im/status-desktop/commit/93668ff75
// we're hiding the setting to change appearance for compact normal mode
// of the UI. For now, compact mode is the new default.

View File

@ -32,6 +32,10 @@ StatusWindow {
fileName: profileModel.settings.globalSettingsFile
property string locale: "en"
property int theme: 2
Component.onCompleted: {
profileModel.changeLocale(locale)
}
}
id: applicationWindow