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");
mSelector->setEncoding(encoding);
QStringList languages;
languages << tr("English") << tr("French") << tr("German") << tr("Italian") << tr("Polish") << tr("Russian")
<< tr("Spanish");
QVector<std::pair<QString, QString>> languages = { { "English", tr("English") }, { "French", tr("French") },
{ "German", tr("German") }, { "Italian", tr("Italian") }, { "Polish", tr("Polish") },
{ "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);
mCloneProfileDialog = new TextInputDialog(tr("Clone Content List"), tr("Content List name:"), this);
@ -254,9 +257,17 @@ bool Launcher::DataFilesPage::loadSettings()
if (!currentProfile.isEmpty())
addProfile(currentProfile, true);
const int index = mSelector->languageBox()->findText(mLauncherSettings.getLanguage());
if (index != -1)
mSelector->languageBox()->setCurrentIndex(index);
auto language = mLauncherSettings.getLanguage();
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;
}
@ -386,7 +397,7 @@ void Launcher::DataFilesPage::saveSettings(const QString& profile)
mLauncherSettings.setContentList(profileName, dirList, selectedArchivePaths(), fileNames);
mGameSettings.setContentList(dirList, selectedArchivePaths(), fileNames);
QString language(mSelector->languageBox()->currentText());
QString language(mSelector->languageBox()->currentData().toString());
mLauncherSettings.setLanguage(language);

@ -154,8 +154,13 @@ bool Launcher::GraphicsPage::loadSettings()
if (Settings::shadows().mEnableIndoorShadows)
indoorShadowsCheckBox->setCheckState(Qt::Checked);
shadowComputeSceneBoundsComboBox->setCurrentIndex(
shadowComputeSceneBoundsComboBox->findText(QString(tr(Settings::shadows().mComputeSceneBounds.get().c_str()))));
auto boundMethod = Settings::shadows().mComputeSceneBounds.get();
if (boundMethod == "bounds")
shadowComputeSceneBoundsComboBox->setCurrentIndex(0);
else if (boundMethod == "primitives")
shadowComputeSceneBoundsComboBox->setCurrentIndex(1);
else
shadowComputeSceneBoundsComboBox->setCurrentIndex(2);
const int shadowDistLimit = Settings::shadows().mMaximumShadowMapDistance;
if (shadowDistLimit > 0)
@ -254,7 +259,14 @@ void Launcher::GraphicsPage::saveSettings()
Settings::shadows().mEnableIndoorShadows.set(indoorShadowsCheckBox->checkState() != Qt::Unchecked);
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)

@ -1,5 +1,6 @@
#include "installationpage.hpp"
#include <QComboBox>
#include <QFileDialog>
#include <QMessageBox>
#include <QThread>
@ -123,7 +124,7 @@ void Wizard::InstallationPage::startInstallation()
mUnshield->setPath(path);
// 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"))
{

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

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

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

Loading…
Cancel
Save