diff --git a/config/schemas/settings.json b/config/schemas/settings.json index 9baa638c6..34a721a61 100644 --- a/config/schemas/settings.json +++ b/config/schemas/settings.json @@ -17,7 +17,7 @@ "type" : "object", "default": {}, "additionalProperties" : false, - "required" : [ "playerName", "showfps", "music", "sound", "encoding", "swipe", "saveRandomMaps", "saveFrequency", "notifications", "extraDump" ], + "required" : [ "playerName", "showfps", "music", "sound", "encoding", "language", "swipe", "saveRandomMaps", "saveFrequency", "notifications", "extraDump" ], "properties" : { "playerName" : { "type":"string", @@ -51,6 +51,10 @@ "type":"string", "default" : "Maps/Arrogance" }, + "language" : { + "type":"string", + "default" : "english" + }, "lastSave" : { "type":"string", "default" : "NEWGAME" diff --git a/launcher/mainwindow_moc.cpp b/launcher/mainwindow_moc.cpp index a88c3845f..35591185e 100644 --- a/launcher/mainwindow_moc.cpp +++ b/launcher/mainwindow_moc.cpp @@ -51,6 +51,7 @@ MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent), ui(new Ui::MainWindow) { load(); // load FS before UI + updateTranslation(); // load translation ui->setupUi(this); diff --git a/launcher/settingsView/csettingsview_moc.cpp b/launcher/settingsView/csettingsview_moc.cpp index 74d98a02f..73befdcad 100644 --- a/launcher/settingsView/csettingsview_moc.cpp +++ b/launcher/settingsView/csettingsview_moc.cpp @@ -114,6 +114,11 @@ void CSettingsView::loadSettings() if(encodingIndex < ui->comboBoxEncoding->count()) ui->comboBoxEncoding->setCurrentIndex((int)encodingIndex); ui->comboBoxAutoSave->setCurrentIndex(settings["general"]["saveFrequency"].Integer() > 0 ? 1 : 0); + + std::string language = settings["general"]["language"].String(); + size_t languageIndex = boost::range::find(languageTagList, language) - languageTagList; + if(languageIndex < ui->comboBoxLanguage->count()) + ui->comboBoxLanguage->setCurrentIndex((int)languageIndex); } void CSettingsView::fillValidResolutions(bool isExtraResolutionsModEnabled) @@ -319,7 +324,8 @@ void CSettingsView::on_comboBoxLanguage_currentIndexChanged(int index) Settings node = settings.write["general"]["language"]; node->String() = languageTagList[index]; - dynamic_cast(qApp->activeWindow())->updateTranslation(); + if ( qApp->activeWindow() && dynamic_cast(qApp->activeWindow()) ) + dynamic_cast(qApp->activeWindow())->updateTranslation(); } void CSettingsView::changeEvent(QEvent *event)