feat: improve translations

This commit is contained in:
Marcin Mitura 2024-09-04 13:33:47 +02:00
parent b97b5a7db4
commit 84b92c732e
30 changed files with 32497 additions and 25595 deletions

View file

@ -6,15 +6,17 @@
#include <QFileDialog>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QIcon>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QPushButton>
#include <QVBoxLayout>
#include "game_install_dialog.h"
GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
GameInstallDialog::GameInstallDialog(QWidget* parent)
: QDialog(parent), m_gamesDirectory(new QLineEdit(this)) // Initialize member variable
{
auto layout = new QVBoxLayout(this);
layout->addWidget(SetupGamesDirectory());
@ -25,7 +27,7 @@ GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
setWindowIcon(QIcon(":images/shadps4.ico"));
}
GameInstallDialog::~GameInstallDialog() {}
GameInstallDialog::~GameInstallDialog() = default;
void GameInstallDialog::Browse() {
auto path = QFileDialog::getExistingDirectory(this, tr("Directory to install games"));
@ -40,7 +42,6 @@ QWidget* GameInstallDialog::SetupGamesDirectory() {
auto layout = new QHBoxLayout(group);
// Input.
m_gamesDirectory = new QLineEdit();
m_gamesDirectory->setText(QString::fromStdString(Config::getGameInstallDir()));
m_gamesDirectory->setMinimumWidth(400);
@ -70,9 +71,9 @@ void GameInstallDialog::Save() {
auto gamesDirectory = m_gamesDirectory->text();
if (gamesDirectory.isEmpty() || !QDir(gamesDirectory).exists() ||
!QDir::isAbsolutePath(gamesDirectory)) {
!QDir(gamesDirectory).isAbsolute()) {
QMessageBox::critical(this, tr("Error"),
"The value for location to install games is not valid.");
tr("The value for location to install games is not valid."));
return;
}
@ -80,4 +81,4 @@ void GameInstallDialog::Save() {
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
Config::save(config_dir / "config.toml");
accept();
}
}

View file

@ -4,25 +4,23 @@
#pragma once
#include <QDialog>
#include <QLineEdit>
#include "common/config.h"
#include "common/path_util.h"
class QLineEdit;
class GameInstallDialog : public QDialog {
Q_OBJECT // This macro is necessary for Qt's meta-object system
class GameInstallDialog final : public QDialog {
public:
GameInstallDialog();
~GameInstallDialog();
public : explicit GameInstallDialog(QWidget* parent = nullptr);
~GameInstallDialog() override;
private slots:
void Browse();
void Save();
private:
QWidget* SetupGamesDirectory();
QWidget* SetupDialogActions();
void Save();
private:
QLineEdit* m_gamesDirectory;
QLineEdit* m_gamesDirectory; // Pointer to the QLineEdit widget
};

View file

@ -621,6 +621,9 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
auto extract_path = std::filesystem::path(Config::getGameInstallDir()) / pkg.GetTitleID();
QString pkgType = QString::fromStdString(pkg.GetPkgFlags());
QDir game_dir(QString::fromStdString(extract_path.string()));
bool isDLC = false; // Variable to track if the package is DLC
if (game_dir.exists()) {
QMessageBox msgBox;
msgBox.setWindowTitle(tr("PKG Extraction"));
@ -641,43 +644,45 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
QString game_app_version = QString::fromStdString(psf.GetString("APP_VER"));
double appD = game_app_version.toDouble();
double pkgD = pkg_app_version.toDouble();
QString message;
if (pkgD == appD) {
msgBox.setText(QString(tr("Patch detected!") + "\n" +
tr("PKG and Game versions match: ") + pkg_app_version +
"\n" + tr("Would you like to overwrite?")));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
message = tr("Patch detected!\nPKG and Game versions match: %1\nWould you like "
"to overwrite?")
.arg(pkg_app_version);
} else if (pkgD < appD) {
msgBox.setText(QString(tr("Patch detected!") + "\n" +
tr("PKG Version %1 is older than installed version: ")
.arg(pkg_app_version) +
game_app_version + "\n" +
tr("Would you like to overwrite?")));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
message = tr("Patch detected!\nPKG Version %1 is older than installed version: "
"%2\nWould you like to overwrite?")
.arg(pkg_app_version)
.arg(game_app_version);
} else {
msgBox.setText(QString(tr("Patch detected!") + "\n" +
tr("Game is installed: ") + game_app_version + "\n" +
tr("Would you like to install Patch: ") +
pkg_app_version + " ?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
message = tr("Patch detected!\nGame is installed: %1\nWould you like to "
"install Patch: %2?")
.arg(game_app_version)
.arg(pkg_app_version);
}
msgBox.setText(message);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setButtonText(QMessageBox::Yes, tr("Yes"));
msgBox.setButtonText(QMessageBox::No, tr("No"));
msgBox.setDefaultButton(QMessageBox::No);
int result = msgBox.exec();
if (result == QMessageBox::Yes) {
// Do nothing.
} else {
if (result != QMessageBox::Yes) {
return;
}
} else if (category == "ac") {
} else if (category == "ac") { // Check if category is DLC
isDLC = true; // Set flag for DLC
if (!addon_dir.exists()) {
QMessageBox addonMsgBox;
addonMsgBox.setWindowTitle(tr("DLC Installation"));
addonMsgBox.setText(QString(tr("Would you like to install DLC: %1?"))
addonMsgBox.setText(tr("Would you like to install DLC: %1?")
.arg(QString::fromStdString(entitlement_label)));
addonMsgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
addonMsgBox.setButtonText(QMessageBox::Yes, tr("Yes"));
addonMsgBox.setButtonText(QMessageBox::No, tr("No"));
addonMsgBox.setDefaultButton(QMessageBox::No);
int result = addonMsgBox.exec();
if (result == QMessageBox::Yes) {
extract_path = addon_extract_path;
@ -685,12 +690,17 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
return;
}
} else {
msgBox.setText(QString(tr("DLC already installed:") + "\n" +
QString::fromStdString(addon_extract_path.string()) +
"\n\n" + tr("Would you like to overwrite?")));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int result = msgBox.exec();
QMessageBox addonMsgBox;
addonMsgBox.setWindowTitle(tr("DLC Installation"));
addonMsgBox.setText(
tr("DLC already installed:\n%1\n\nWould you like to overwrite?")
.arg(QString::fromStdString(addon_extract_path.string())));
addonMsgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
addonMsgBox.setButtonText(QMessageBox::Yes, tr("Yes"));
addonMsgBox.setButtonText(QMessageBox::No, tr("No"));
addonMsgBox.setDefaultButton(QMessageBox::No);
int result = addonMsgBox.exec();
if (result == QMessageBox::Yes) {
extract_path = addon_extract_path;
} else {
@ -698,30 +708,32 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
}
}
} else {
msgBox.setText(QString(tr("Game already installed") + "\n" +
QString::fromStdString(extract_path.string()) + "\n" +
tr("Would you like to overwrite?")));
msgBox.setText(tr("Game already installed\n%1\nWould you like to overwrite?")
.arg(QString::fromStdString(extract_path.string())));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setButtonText(QMessageBox::Yes, tr("Yes"));
msgBox.setButtonText(QMessageBox::No, tr("No"));
msgBox.setDefaultButton(QMessageBox::No);
int result = msgBox.exec();
if (result == QMessageBox::Yes) {
// Do nothing.
} else {
if (result != QMessageBox::Yes) {
return;
}
}
} else {
// Do nothing;
if (pkgType.contains("PATCH")) {
QMessageBox::information(this, tr("PKG Extraction"),
tr("PKG is a patch, please install the game first!"));
return;
}
// what else?
// Handle case when the game directory does not exist and it's not a patch.
// You might need to provide appropriate logic here.
}
if (!pkg.Extract(file, extract_path, failreason)) {
QMessageBox::critical(this, tr("PKG ERROR"), QString::fromStdString(failreason));
QMessageBox::critical(
this, tr("PKG ERROR"),
tr("Failed to extract PKG: %1").arg(QString::fromStdString(failreason)));
} else {
int nfiles = pkg.GetNumberOfFiles();
@ -734,20 +746,27 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
QProgressDialog dialog;
dialog.setWindowTitle(tr("PKG Extraction"));
dialog.setWindowModality(Qt::WindowModal);
QString extractmsg = QString(tr("Extracting PKG %1/%2")).arg(pkgNum).arg(nPkg);
QString extractmsg = tr("Extracting PKG %1/%2").arg(pkgNum).arg(nPkg);
dialog.setLabelText(extractmsg);
dialog.setAutoClose(true);
dialog.setRange(0, nfiles);
QFutureWatcher<void> futureWatcher;
connect(&futureWatcher, &QFutureWatcher<void>::finished, this, [=, this]() {
connect(&futureWatcher, &QFutureWatcher<void>::finished, this, [=]() {
if (pkgNum == nPkg) {
QString path = QString::fromStdString(Config::getGameInstallDir());
QMessageBox extractMsgBox(this);
extractMsgBox.setWindowTitle(tr("Extraction Finished"));
extractMsgBox.setText(
QString(tr("Game successfully installed at %1")).arg(path));
extractMsgBox.addButton(QMessageBox::Ok);
// Display the appropriate message based on whether it was a DLC or a game
if (isDLC) {
extractMsgBox.setText(tr("DLC successfully installed at %1").arg(path));
} else {
extractMsgBox.setText(
tr("Game successfully installed at %1").arg(path));
}
extractMsgBox.setButtonText(QMessageBox::Ok, tr("Ok"));
extractMsgBox.setDefaultButton(QMessageBox::Ok);
connect(&extractMsgBox, &QMessageBox::buttonClicked, this,
[&](QAbstractButton* button) {

View file

@ -1,43 +1,46 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <QApplication>
#include <QCompleter>
#include <QDirIterator>
#include <QLocale>
#include <QTranslator>
#include "main_window.h"
#include "settings_dialog.h"
#include "ui_settings_dialog.h"
QStringList languageNames = {"Arabic",
"Czech",
"Danish",
"Dutch",
"English (United Kingdom)",
"English (United States)",
"Finnish",
"French (Canada)",
"French (France)",
"German",
"Greek",
"Hungarian",
"Indonesian",
"Italian",
"Japanese",
"Korean",
"Norwegian",
"Polish",
"Portuguese (Brazil)",
"Portuguese (Portugal)",
"Romanian",
"Russian",
"Simplified Chinese",
"Spanish (Latin America)",
"Spanish (Spain)",
"Swedish",
"Thai",
"Traditional Chinese",
"Turkish",
"Vietnamese"};
QStringList languageNames = {QObject::tr("Arabic"),
QObject::tr("Czech"),
QObject::tr("Danish"),
QObject::tr("Dutch"),
QObject::tr("English (United Kingdom)"),
QObject::tr("English (United States)"),
QObject::tr("Finnish"),
QObject::tr("French (Canada)"),
QObject::tr("French (France)"),
QObject::tr("German"),
QObject::tr("Greek"),
QObject::tr("Hungarian"),
QObject::tr("Indonesian"),
QObject::tr("Italian"),
QObject::tr("Japanese"),
QObject::tr("Korean"),
QObject::tr("Norwegian"),
QObject::tr("Polish"),
QObject::tr("Portuguese (Brazil)"),
QObject::tr("Portuguese (Portugal)"),
QObject::tr("Romanian"),
QObject::tr("Russian"),
QObject::tr("Simplified Chinese"),
QObject::tr("Spanish (Latin America)"),
QObject::tr("Spanish (Spain)"),
QObject::tr("Swedish"),
QObject::tr("Thai"),
QObject::tr("Traditional Chinese"),
QObject::tr("Turkish"),
QObject::tr("Vietnamese")};
const QVector<int> languageIndexes = {21, 23, 14, 6, 18, 1, 12, 22, 2, 4, 25, 24, 29, 5, 0,
9, 15, 16, 17, 7, 26, 8, 11, 20, 3, 13, 27, 10, 19, 28};
@ -51,7 +54,7 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
ui->buttonBox->button(QDialogButtonBox::StandardButton::Close)->setFocus();
// Add list of available GPUs
ui->graphicsAdapterBox->addItem("Auto Select"); // -1, auto selection
ui->graphicsAdapterBox->addItem(tr("Auto Select")); // -1, auto selection
for (const auto& device : physical_devices) {
ui->graphicsAdapterBox->addItem(device);
}
@ -197,7 +200,7 @@ void SettingsDialog::InitializeEmulatorLanguages() {
locale.remove(0, locale.lastIndexOf(QLatin1Char{'/'}) + 1);
const QString lang = QLocale::languageToString(QLocale(locale).language());
const QString country = QLocale::territoryToString(QLocale(locale).territory());
ui->emulatorLanguageComboBox->addItem(QStringLiteral("%1 (%2)").arg(lang, country), locale);
ui->emulatorLanguageComboBox->addItem(tr("%1 (%2)").arg(lang, country), locale);
languages[locale.toStdString()] = idx;
idx++;
@ -220,4 +223,4 @@ int SettingsDialog::exec() {
return QDialog::exec();
}
SettingsDialog::~SettingsDialog() {}
SettingsDialog::~SettingsDialog() {}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff