Make hardcoded strings in Launcher and Wizard localizable

macos_ci_fix
Andrei Kortunov 1 year ago
parent e3e9b39a16
commit ca19f7006c

@ -164,11 +164,14 @@ Launcher::DataFilesPage::DataFilesPage(const Files::ConfigurationManager& cfg, C
const QString encoding = mGameSettings.value("encoding", "win1252"); const QString encoding = mGameSettings.value("encoding", "win1252");
mSelector->setEncoding(encoding); mSelector->setEncoding(encoding);
QStringList languages; QVector<std::pair<QString, QString>> languages = { { "English", tr("English") }, { "French", tr("French") },
languages << tr("English") << tr("French") << tr("German") << tr("Italian") << tr("Polish") << tr("Russian") { "German", tr("German") }, { "Italian", tr("Italian") }, { "Polish", tr("Polish") },
<< tr("Spanish"); { "Russian", tr("Russian") }, { "Spanish", tr("Spanish") } };
mSelector->languageBox()->addItems(languages); for (auto lang : languages)
{
mSelector->languageBox()->addItem(lang.second, lang.first);
}
mNewProfileDialog = new TextInputDialog(tr("New Content List"), tr("Content List name:"), this); mNewProfileDialog = new TextInputDialog(tr("New Content List"), tr("Content List name:"), this);
mCloneProfileDialog = new TextInputDialog(tr("Clone Content List"), tr("Content List name:"), this); mCloneProfileDialog = new TextInputDialog(tr("Clone Content List"), tr("Content List name:"), this);
@ -254,9 +257,17 @@ bool Launcher::DataFilesPage::loadSettings()
if (!currentProfile.isEmpty()) if (!currentProfile.isEmpty())
addProfile(currentProfile, true); addProfile(currentProfile, true);
const int index = mSelector->languageBox()->findText(mLauncherSettings.getLanguage()); auto language = mLauncherSettings.getLanguage();
if (index != -1)
mSelector->languageBox()->setCurrentIndex(index); for (int i = 0; i < mSelector->languageBox()->count(); ++i)
{
QString languageItem = mSelector->languageBox()->itemData(i).toString();
if (language == languageItem)
{
mSelector->languageBox()->setCurrentIndex(i);
break;
}
}
return true; return true;
} }
@ -386,7 +397,7 @@ void Launcher::DataFilesPage::saveSettings(const QString& profile)
mLauncherSettings.setContentList(profileName, dirList, selectedArchivePaths(), fileNames); mLauncherSettings.setContentList(profileName, dirList, selectedArchivePaths(), fileNames);
mGameSettings.setContentList(dirList, selectedArchivePaths(), fileNames); mGameSettings.setContentList(dirList, selectedArchivePaths(), fileNames);
QString language(mSelector->languageBox()->currentText()); QString language(mSelector->languageBox()->currentData().toString());
mLauncherSettings.setLanguage(language); mLauncherSettings.setLanguage(language);

@ -154,8 +154,13 @@ bool Launcher::GraphicsPage::loadSettings()
if (Settings::shadows().mEnableIndoorShadows) if (Settings::shadows().mEnableIndoorShadows)
indoorShadowsCheckBox->setCheckState(Qt::Checked); indoorShadowsCheckBox->setCheckState(Qt::Checked);
shadowComputeSceneBoundsComboBox->setCurrentIndex( auto boundMethod = Settings::shadows().mComputeSceneBounds.get();
shadowComputeSceneBoundsComboBox->findText(QString(tr(Settings::shadows().mComputeSceneBounds.get().c_str())))); if (boundMethod == "bounds")
shadowComputeSceneBoundsComboBox->setCurrentIndex(0);
else if (boundMethod == "primitives")
shadowComputeSceneBoundsComboBox->setCurrentIndex(1);
else
shadowComputeSceneBoundsComboBox->setCurrentIndex(2);
const int shadowDistLimit = Settings::shadows().mMaximumShadowMapDistance; const int shadowDistLimit = Settings::shadows().mMaximumShadowMapDistance;
if (shadowDistLimit > 0) if (shadowDistLimit > 0)
@ -254,7 +259,14 @@ void Launcher::GraphicsPage::saveSettings()
Settings::shadows().mEnableIndoorShadows.set(indoorShadowsCheckBox->checkState() != Qt::Unchecked); Settings::shadows().mEnableIndoorShadows.set(indoorShadowsCheckBox->checkState() != Qt::Unchecked);
Settings::shadows().mShadowMapResolution.set(shadowResolutionComboBox->currentText().toInt()); Settings::shadows().mShadowMapResolution.set(shadowResolutionComboBox->currentText().toInt());
Settings::shadows().mComputeSceneBounds.set(shadowComputeSceneBoundsComboBox->currentText().toStdString());
auto index = shadowComputeSceneBoundsComboBox->currentIndex();
if (index == 0)
Settings::shadows().mComputeSceneBounds.set("bounds");
else if (index == 1)
Settings::shadows().mComputeSceneBounds.set("primitives");
else
Settings::shadows().mComputeSceneBounds.set("none");
} }
QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen) QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)

@ -1,5 +1,6 @@
#include "installationpage.hpp" #include "installationpage.hpp"
#include <QComboBox>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QThread> #include <QThread>
@ -123,7 +124,7 @@ void Wizard::InstallationPage::startInstallation()
mUnshield->setPath(path); mUnshield->setPath(path);
// Set the right codec to use for Morrowind.ini // Set the right codec to use for Morrowind.ini
QString language(field(QLatin1String("installation.language")).toString()); QString language(field(QLatin1String("installation.language")).value<QComboBox*>()->currentData().toString());
if (language == QLatin1String("Polish")) if (language == QLatin1String("Polish"))
{ {

@ -14,12 +14,14 @@ Wizard::LanguageSelectionPage::LanguageSelectionPage(QWidget* parent)
void Wizard::LanguageSelectionPage::initializePage() void Wizard::LanguageSelectionPage::initializePage()
{ {
QStringList languages; QVector<std::pair<QString, QString>> languages = { { "English", tr("English") }, { "French", tr("French") },
languages << QLatin1String("English") << QLatin1String("French") << QLatin1String("German") { "German", tr("German") }, { "Italian", tr("Italian") }, { "Polish", tr("Polish") },
<< QLatin1String("Italian") << QLatin1String("Polish") << QLatin1String("Russian") { "Russian", tr("Russian") }, { "Spanish", tr("Spanish") } };
<< QLatin1String("Spanish");
languageComboBox->addItems(languages); for (auto lang : languages)
{
languageComboBox->addItem(lang.second, lang.first);
}
} }
int Wizard::LanguageSelectionPage::nextId() const int Wizard::LanguageSelectionPage::nextId() const

@ -270,8 +270,7 @@ void Wizard::MainWizard::runSettingsImporter()
arguments.append(QLatin1String("--encoding")); arguments.append(QLatin1String("--encoding"));
// Set encoding // Set encoding
QString language(field(QLatin1String("installation.language")).toString()); QString language(field(QLatin1String("installation.language")).value<QComboBox*>()->currentData().toString());
if (language == QLatin1String("Polish")) if (language == QLatin1String("Polish"))
{ {
arguments.append(QLatin1String("win1250")); arguments.append(QLatin1String("win1250"));
@ -392,7 +391,7 @@ void Wizard::MainWizard::reject()
void Wizard::MainWizard::writeSettings() void Wizard::MainWizard::writeSettings()
{ {
// Write the encoding and language settings // Write the encoding and language settings
QString language(field(QLatin1String("installation.language")).toString()); QString language(field(QLatin1String("installation.language")).value<QComboBox*>()->currentData().toString());
mLauncherSettings.setLanguage(language); mLauncherSettings.setLanguage(language);
if (language == QLatin1String("Polish")) if (language == QLatin1String("Polish"))

@ -32,7 +32,7 @@ void ContentSelectorView::ContentSelector::buildContentModel(bool showOMWScripts
void ContentSelectorView::ContentSelector::buildGameFileView() void ContentSelectorView::ContentSelector::buildGameFileView()
{ {
ui.gameFileView->addItem("<No game file>"); ui.gameFileView->addItem(tr("<No game file>"));
ui.gameFileView->setVisible(true); ui.gameFileView->setVisible(true);
connect(ui.gameFileView, qOverload<int>(&ComboBox::currentIndexChanged), this, connect(ui.gameFileView, qOverload<int>(&ComboBox::currentIndexChanged), this,

Loading…
Cancel
Save