fixed language settings
This commit is contained in:
parent
b7b7c054d3
commit
64da9e9327
4
main.cpp
4
main.cpp
|
@ -48,16 +48,12 @@ int main(int argc, char *argv[]) {
|
||||||
QString lang = "en_US";
|
QString lang = "en_US";
|
||||||
|
|
||||||
if (s.get_all_settings().contains("language")) {
|
if (s.get_all_settings().contains("language")) {
|
||||||
std::cout << "settings" << std::endl;
|
|
||||||
lang = QString::fromStdString(s.get_all_settings()["language"]);
|
lang = QString::fromStdString(s.get_all_settings()["language"]);
|
||||||
} else if (translator.load(":/translation/"+QLocale::system().name()+".qm")) {
|
} else if (translator.load(":/translation/"+QLocale::system().name()+".qm")) {
|
||||||
std::cout << "system" << std::endl;
|
|
||||||
lang = QLocale::system().name();
|
lang = QLocale::system().name();
|
||||||
} else {
|
} else {
|
||||||
std::cout << "default" << std::endl;
|
|
||||||
lang = QString::fromStdString("en_US");
|
lang = QString::fromStdString("en_US");
|
||||||
}
|
}
|
||||||
std::cout << lang.toStdString() << std::endl;
|
|
||||||
translator.load(":/translation/" + lang + ".qm");
|
translator.load(":/translation/" + lang + ".qm");
|
||||||
|
|
||||||
a.installTranslator(&translator);
|
a.installTranslator(&translator);
|
||||||
|
|
|
@ -26,7 +26,6 @@ Settings::Settings(std::string path) {
|
||||||
"stores_modules_url":"https://foxarmy.org/checks-parser/modules/stores/",
|
"stores_modules_url":"https://foxarmy.org/checks-parser/modules/stores/",
|
||||||
"print_header": true,
|
"print_header": true,
|
||||||
"print_total": true,
|
"print_total": true,
|
||||||
"language":"en_US",
|
|
||||||
"output_order": {
|
"output_order": {
|
||||||
"goods_name": {
|
"goods_name": {
|
||||||
"position":1,
|
"position":1,
|
||||||
|
|
|
@ -35,8 +35,18 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
||||||
ui->printHeaderCheckBox->setChecked(this->settings.get_all_settings()["print_header"]);
|
ui->printHeaderCheckBox->setChecked(this->settings.get_all_settings()["print_header"]);
|
||||||
ui->printTotalCheckBox->setChecked(this->settings.get_all_settings()["print_total"]);
|
ui->printTotalCheckBox->setChecked(this->settings.get_all_settings()["print_total"]);
|
||||||
|
|
||||||
int index = ui->languageComboBox->findText(QString::fromStdString(this->settings.get_all_settings()["language"]));
|
|
||||||
ui->languageComboBox->setCurrentIndex(index);
|
int currentLanguageIndex = 0;
|
||||||
|
if (!this->settings.get_all_settings().contains("language")) {
|
||||||
|
currentLanguageIndex = ui->languageComboBox->findText(QLocale::system().name());
|
||||||
|
if (currentLanguageIndex < 0) {
|
||||||
|
currentLanguageIndex = ui->languageComboBox->findText("en_US");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currentLanguageIndex = ui->languageComboBox->findText(QString::fromStdString(this->settings.get_all_settings()["language"]));
|
||||||
|
}
|
||||||
|
ui->languageComboBox->setCurrentIndex(currentLanguageIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsDialog::~SettingsDialog() { delete ui; }
|
SettingsDialog::~SettingsDialog() { delete ui; }
|
||||||
|
@ -127,7 +137,12 @@ void SettingsDialog::on_buttonBox_accepted() { this->settings.flush(); }
|
||||||
void SettingsDialog::on_buttonBox_rejected() { this->close(); }
|
void SettingsDialog::on_buttonBox_rejected() { this->close(); }
|
||||||
|
|
||||||
void SettingsDialog::on_languageComboBox_currentTextChanged(const QString &changed) {
|
void SettingsDialog::on_languageComboBox_currentTextChanged(const QString &changed) {
|
||||||
|
if (this->settings.get_all_settings().contains("language")) {
|
||||||
if (changed == QString::fromStdString(this->settings.get_all_settings()["language"])) return;
|
if (changed == QString::fromStdString(this->settings.get_all_settings()["language"])) return;
|
||||||
|
} else {
|
||||||
|
if (changed == QLocale::system().name()) return;
|
||||||
|
}
|
||||||
|
|
||||||
this->settings.get_all_settings()["language"] = changed.toStdString();
|
this->settings.get_all_settings()["language"] = changed.toStdString();
|
||||||
|
|
||||||
QMessageBox infoDialog;
|
QMessageBox infoDialog;
|
||||||
|
|
|
@ -311,12 +311,12 @@
|
||||||
<context>
|
<context>
|
||||||
<name>SettingsDialog</name>
|
<name>SettingsDialog</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../settingsdialog.cpp" line="134"/>
|
<location filename="../settingsdialog.cpp" line="149"/>
|
||||||
<source>You need to restart program to apply language changes</source>
|
<source>You need to restart program to apply language changes</source>
|
||||||
<translation>You need to restart program to apply language changes</translation>
|
<translation>You need to restart program to apply language changes</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../settingsdialog.cpp" line="136"/>
|
<location filename="../settingsdialog.cpp" line="151"/>
|
||||||
<source>Restart required</source>
|
<source>Restart required</source>
|
||||||
<translation>Restart required</translation>
|
<translation>Restart required</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -307,12 +307,12 @@
|
||||||
<context>
|
<context>
|
||||||
<name>SettingsDialog</name>
|
<name>SettingsDialog</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../settingsdialog.cpp" line="134"/>
|
<location filename="../settingsdialog.cpp" line="149"/>
|
||||||
<source>You need to restart program to apply language changes</source>
|
<source>You need to restart program to apply language changes</source>
|
||||||
<translation>Требуется перезагрузить программу, чтобы применить изменения языка</translation>
|
<translation>Требуется перезагрузить программу, чтобы применить изменения языка</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../settingsdialog.cpp" line="136"/>
|
<location filename="../settingsdialog.cpp" line="151"/>
|
||||||
<source>Restart required</source>
|
<source>Restart required</source>
|
||||||
<translation>Требуется перезагрузка</translation>
|
<translation>Требуется перезагрузка</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
Loading…
Reference in New Issue