1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Fix language selection

This commit is contained in:
Ivan Savenko 2023-03-08 02:01:56 +02:00
parent dfaceb3a0e
commit 6fe319329b
7 changed files with 76 additions and 69 deletions

View File

@ -91,7 +91,7 @@
"language" : { "language" : {
"type":"string", "type":"string",
"description": "Base language of the mod, before applying localizations. By default vcmi assumes English", "description": "Base language of the mod, before applying localizations. By default vcmi assumes English",
"enum" : [ "chinese", "english", "german", "polish", "russian", "ukrainian" ], "enum" : [ "chinese", "english", "korean", "german", "polish", "russian", "ukrainian" ],
}, },
"depends": { "depends": {
"type":"array", "type":"array",
@ -125,12 +125,18 @@
"type":"boolean", "type":"boolean",
"description": "If set to true, mod will not be enabled automatically on install" "description": "If set to true, mod will not be enabled automatically on install"
}, },
"chinese" : {
"$ref" : "#/definitions/localizable"
},
"english" : { "english" : {
"$ref" : "#/definitions/localizable" "$ref" : "#/definitions/localizable"
}, },
"german" : { "german" : {
"$ref" : "#/definitions/localizable" "$ref" : "#/definitions/localizable"
}, },
"korean" : {
"$ref" : "#/definitions/localizable"
},
"polish" : { "polish" : {
"$ref" : "#/definitions/localizable" "$ref" : "#/definitions/localizable"
}, },

View File

@ -63,7 +63,7 @@
}, },
"language" : { "language" : {
"type":"string", "type":"string",
"enum" : [ "chinese", "english", "german", "polish", "russian", "ukrainian" ], "enum" : [ "chinese", "english", "german", "korean", "polish", "russian", "ukrainian", "other_cp1250", "other_cp1251", "other_cp1252" ],
"default" : "english" "default" : "english"
}, },
"lastSave" : { "lastSave" : {

View File

@ -11,10 +11,17 @@
#include "firstlaunch_moc.h" #include "firstlaunch_moc.h"
#include "ui_firstlaunch_moc.h" #include "ui_firstlaunch_moc.h"
#include "mainwindow_moc.h"
#include "../languages.h"
#include "../../lib/CConfigHandler.h"
FirstLaunchView::FirstLaunchView(QWidget * parent) FirstLaunchView::FirstLaunchView(QWidget * parent)
: QWidget(parent), ui(new Ui::FirstLaunchView) : QWidget(parent), ui(new Ui::FirstLaunchView)
{ {
ui->setupUi(this); ui->setupUi(this);
Languages::fillLanguages(ui->listWidgetLanguage);
} }
FirstLaunchView::~FirstLaunchView() FirstLaunchView::~FirstLaunchView()
@ -27,21 +34,37 @@ void FirstLaunchView::on_buttonTabLanguage_clicked()
ui->installerTabs->setCurrentIndex(0); ui->installerTabs->setCurrentIndex(0);
} }
void FirstLaunchView::on_buttonTabHeroesData_clicked() void FirstLaunchView::on_buttonTabHeroesData_clicked()
{ {
ui->installerTabs->setCurrentIndex(1); ui->installerTabs->setCurrentIndex(1);
} }
void FirstLaunchView::on_buttonTabModPreset_clicked() void FirstLaunchView::on_buttonTabModPreset_clicked()
{ {
ui->installerTabs->setCurrentIndex(2); ui->installerTabs->setCurrentIndex(2);
} }
void FirstLaunchView::on_buttonTabFinish_clicked() void FirstLaunchView::on_buttonTabFinish_clicked()
{ {
ui->installerTabs->setCurrentIndex(3); ui->installerTabs->setCurrentIndex(3);
} }
void FirstLaunchView::on_listWidgetLanguage_currentRowChanged(int currentRow)
{
Settings node = settings.write["general"]["language"];
QString selectedLanguage = ui->listWidgetLanguage->item(currentRow)->data(Qt::UserRole).toString();
node->String() = selectedLanguage.toStdString();
if(auto * mainWindow = dynamic_cast<MainWindow *>(qApp->activeWindow()))
mainWindow->updateTranslation();
}
void FirstLaunchView::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
Languages::fillLanguages(ui->listWidgetLanguage);
}
QWidget::changeEvent(event);
}

View File

@ -19,6 +19,7 @@ class FirstLaunchView : public QWidget
{ {
Q_OBJECT Q_OBJECT
void changeEvent(QEvent *event);
public: public:
explicit FirstLaunchView(QWidget * parent = 0); explicit FirstLaunchView(QWidget * parent = 0);
~FirstLaunchView(); ~FirstLaunchView();
@ -35,6 +36,8 @@ private slots:
void on_buttonTabFinish_clicked(); void on_buttonTabFinish_clicked();
void on_listWidgetLanguage_currentRowChanged(int currentRow);
private: private:
Ui::FirstLaunchView * ui; Ui::FirstLaunchView * ui;

View File

@ -157,7 +157,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="labelLanguageTitle">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -170,7 +170,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QPushButton" name="pushButton_3"> <widget class="QPushButton" name="pushButtonLanguageNext">
<property name="text"> <property name="text">
<string>Next</string> <string>Next</string>
</property> </property>
@ -203,35 +203,10 @@
</spacer> </spacer>
</item> </item>
<item row="1" column="0" rowspan="2"> <item row="1" column="0" rowspan="2">
<widget class="QListWidget" name="listWidget"> <widget class="QListWidget" name="listWidgetLanguage">
<property name="spacing"> <property name="spacing">
<number>5</number> <number>5</number>
</property> </property>
<item>
<property name="text">
<string>English</string>
</property>
</item>
<item>
<property name="text">
<string>German</string>
</property>
</item>
<item>
<property name="text">
<string>Polish</string>
</property>
</item>
<item>
<property name="text">
<string>Russian</string>
</property>
</item>
<item>
<property name="text">
<string>Ukrainian</string>
</property>
</item>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -254,7 +229,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="labelDataTitle">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -285,7 +260,7 @@
<number>6</number> <number>6</number>
</property> </property>
<item row="4" column="3"> <item row="4" column="3">
<widget class="QPushButton" name="pushButton_11"> <widget class="QPushButton" name="pushButtonDataHelp">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>25</horstretch> <horstretch>25</horstretch>
@ -298,7 +273,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="3"> <item row="2" column="3">
<widget class="QPushButton" name="pushButton_8"> <widget class="QPushButton" name="pushButtonDataSearch">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>25</horstretch> <horstretch>25</horstretch>
@ -311,7 +286,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="3"> <item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="lineEdit"> <widget class="QLineEdit" name="lineEditData1">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>50</horstretch> <horstretch>50</horstretch>
@ -321,7 +296,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="1" colspan="3"> <item row="0" column="1" colspan="3">
<widget class="QLineEdit" name="lineEdit_2"> <widget class="QLineEdit" name="lineEditData2">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>50</horstretch> <horstretch>50</horstretch>
@ -331,7 +306,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="3"> <item row="4" column="0" colspan="3">
<widget class="QLabel" name="label_14"> <widget class="QLabel" name="labelDataHelp">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>100</horstretch> <horstretch>100</horstretch>
@ -347,7 +322,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="3"> <item row="2" column="0" colspan="3">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="labelDataSearch">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>100</horstretch> <horstretch>100</horstretch>
@ -363,7 +338,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_23"> <widget class="QLabel" name="labelDataFiles">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>50</horstretch> <horstretch>50</horstretch>
@ -382,7 +357,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="3"> <item row="3" column="0" colspan="3">
<widget class="QLabel" name="label_13"> <widget class="QLabel" name="labelDataCopy">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>100</horstretch> <horstretch>100</horstretch>
@ -398,7 +373,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="3"> <item row="3" column="3">
<widget class="QPushButton" name="pushButton_10"> <widget class="QPushButton" name="pushButtonDataCopy">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>25</horstretch> <horstretch>25</horstretch>
@ -411,7 +386,7 @@
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="4"> <item row="5" column="0" colspan="4">
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="labelDataFound">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>100</horstretch> <horstretch>100</horstretch>
@ -447,7 +422,7 @@
<number>6</number> <number>6</number>
</property> </property>
<item row="1" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_25"> <widget class="QLabel" name="labelDataSuccess">
<property name="text"> <property name="text">
<string>You Heroes III language was succesfully detected automatically.</string> <string>You Heroes III language was succesfully detected automatically.</string>
</property> </property>
@ -457,7 +432,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_24"> <widget class="QLabel" name="labelDataFailure">
<property name="text"> <property name="text">
<string>Automatic detection of language failed. Please select language of your Heroes III copy</string> <string>Automatic detection of language failed. Please select language of your Heroes III copy</string>
</property> </property>
@ -467,10 +442,10 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="comboBox"/> <widget class="QComboBox" name="comboBoxLanguage"/>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="labelDataLanguage">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -519,14 +494,14 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_2"> <widget class="QPushButton" name="pushButtonDataBack">
<property name="text"> <property name="text">
<string>Back</string> <string>Back</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_4"> <widget class="QPushButton" name="pushButtonDataNext">
<property name="text"> <property name="text">
<string>Next</string> <string>Next</string>
</property> </property>
@ -551,7 +526,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="labelPresetTitle">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -579,7 +554,7 @@
<item> <item>
<layout class="QGridLayout" name="gridLayout_4" rowstretch="1,0,0,0"> <layout class="QGridLayout" name="gridLayout_4" rowstretch="1,0,0,0">
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_11"> <widget class="QLabel" name="labelPresetHota">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>100</horstretch> <horstretch>100</horstretch>
@ -595,7 +570,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QToolButton" name="toolButton"> <widget class="QToolButton" name="toolButtonPresetLanguage">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -603,7 +578,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Localization to (language)</string> <string>Localization to English</string>
</property> </property>
<property name="toolButtonStyle"> <property name="toolButtonStyle">
<enum>Qt::ToolButtonTextOnly</enum> <enum>Qt::ToolButtonTextOnly</enum>
@ -611,7 +586,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_12"> <widget class="QLabel" name="labelPresetWog">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>100</horstretch> <horstretch>100</horstretch>
@ -627,7 +602,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QToolButton" name="toolButton_3"> <widget class="QToolButton" name="toolButtonPresetHota">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -643,7 +618,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QToolButton" name="toolButton_4"> <widget class="QToolButton" name="toolButtonPresetWog">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -659,7 +634,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_10"> <widget class="QLabel" name="labelPresetExtras">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>100</horstretch> <horstretch>100</horstretch>
@ -675,7 +650,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="labelPresetLanguage">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>100</horstretch> <horstretch>100</horstretch>
@ -683,7 +658,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>VCMI provides translations of Heroes III into a different languages. If you wish, you can install translation to (your language)</string> <string>VCMI provides translations of Heroes III into a different languages. If you wish, you can install translation to English</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
@ -691,7 +666,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QToolButton" name="toolButton_2"> <widget class="QToolButton" name="toolButtonPresetExtras">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -737,14 +712,14 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_9"> <widget class="QPushButton" name="pushButtonPresetBack">
<property name="text"> <property name="text">
<string>Back</string> <string>Back</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_13"> <widget class="QPushButton" name="pushButtonPresetNext">
<property name="text"> <property name="text">
<string>Skip</string> <string>Skip</string>
</property> </property>
@ -810,14 +785,14 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_14"> <widget class="QPushButton" name="pushButtonFinishBack">
<property name="text"> <property name="text">
<string>Back</string> <string>Back</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_15"> <widget class="QPushButton" name="pushButtonFinishExit">
<property name="text"> <property name="text">
<string>Finish</string> <string>Finish</string>
</property> </property>

View File

@ -42,12 +42,12 @@ QString Languages::generateLanguageName(const Languages::Options & language)
QString localizedName = QApplication::translate("Language", language.nameEnglish.c_str()); QString localizedName = QApplication::translate("Language", language.nameEnglish.c_str());
QString nativeName = language.nameNative.c_str(); QString nativeName = language.nameNative.c_str();
if(activeLanguage == language.identifier)
return nativeName;
if(!language.hasTranslation) if(!language.hasTranslation)
return localizedName; return localizedName;
if(activeLanguage == language.identifier)
return nativeName;
QString displayName = QString("%1 (%2)").arg(localizedName, nativeName); QString displayName = QString("%1 (%2)").arg(localizedName, nativeName);
return displayName; return displayName;

View File

@ -67,7 +67,7 @@ inline const auto & getLanguageList()
{ "other_cp1250", "Other (East European)", "", "CP1251", false, false }, { "other_cp1250", "Other (East European)", "", "CP1251", false, false },
{ "other_cp1251", "Other (Cyrillic Script)", "", "CP1250", false, false }, { "other_cp1251", "Other (Cyrillic Script)", "", "CP1250", false, false },
{ "other_cp1250", "Other (West European)", "", "CP1252", false, false } { "other_cp1252", "Other (West European)", "", "CP1252", false, false }
} }; } };
static_assert(languages.size() == static_cast<size_t>(ELanguages::COUNT), "Languages array is missing a value!"); static_assert(languages.size() == static_cast<size_t>(ELanguages::COUNT), "Languages array is missing a value!");