feat: improve translations

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

View file

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

View file

@ -4,25 +4,23 @@
#pragma once #pragma once
#include <QDialog> #include <QDialog>
#include <QLineEdit>
#include "common/config.h" #include "common/config.h"
#include "common/path_util.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 : explicit GameInstallDialog(QWidget* parent = nullptr);
public: ~GameInstallDialog() override;
GameInstallDialog();
~GameInstallDialog();
private slots: private slots:
void Browse(); void Browse();
void Save();
private: private:
QWidget* SetupGamesDirectory(); QWidget* SetupGamesDirectory();
QWidget* SetupDialogActions(); QWidget* SetupDialogActions();
void Save();
private: QLineEdit* m_gamesDirectory; // Pointer to the QLineEdit widget
QLineEdit* m_gamesDirectory;
}; };

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

View file

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