Adds missing tr functions for certain GUI strings that should be translatable (#2598)

* Adds missing tr functions for certain GUI strings that should be translatable

* set clang format off for multi-line strings, set userDir as arg

---------

Co-authored-by: rainmakerv2 <30595646+jpau02@users.noreply.github.com>
This commit is contained in:
rainmakerv2 2025-03-06 15:09:27 +08:00 committed by GitHub
parent f1aea5176d
commit 0efe9a4d0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 55 additions and 54 deletions

View file

@ -100,8 +100,8 @@ void ControlSettings::SaveControllerConfig(bool CloseOnSave) {
if (count_axis_left_x > 1 | count_axis_left_y > 1 | count_axis_right_x > 1 | if (count_axis_left_x > 1 | count_axis_left_y > 1 | count_axis_right_x > 1 |
count_axis_right_y > 1) { count_axis_right_y > 1) {
QMessageBox::StandardButton nosave; QMessageBox::StandardButton nosave;
nosave = QMessageBox::information(this, "Unable to Save", nosave = QMessageBox::information(this, tr("Unable to Save"),
"Cannot bind axis values more than once"); tr("Cannot bind axis values more than once"));
return; return;
} }

View file

@ -28,7 +28,7 @@ HelpDialog* helpDialog;
EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) { EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) {
setWindowTitle("Edit Keyboard + Mouse and Controller input bindings"); setWindowTitle(tr("Edit Keyboard + Mouse and Controller input bindings"));
resize(600, 400); resize(600, 400);
// Create the editor widget // Create the editor widget
@ -42,7 +42,7 @@ EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) {
// Load all installed games // Load all installed games
loadInstalledGames(); loadInstalledGames();
QCheckBox* unifiedInputCheckBox = new QCheckBox("Use Per-Game configs", this); QCheckBox* unifiedInputCheckBox = new QCheckBox(tr("Use Per-Game configs"), this);
unifiedInputCheckBox->setChecked(!Config::GetUseUnifiedInputConfig()); unifiedInputCheckBox->setChecked(!Config::GetUseUnifiedInputConfig());
// Connect checkbox signal // Connect checkbox signal
@ -94,7 +94,7 @@ void EditorDialog::loadFile(QString game) {
originalConfig = editor->toPlainText(); originalConfig = editor->toPlainText();
file.close(); file.close();
} else { } else {
QMessageBox::warning(this, "Error", "Could not open the file for reading"); QMessageBox::warning(this, tr("Error"), tr("Could not open the file for reading"));
} }
} }
@ -108,7 +108,7 @@ void EditorDialog::saveFile(QString game) {
out << editor->toPlainText(); out << editor->toPlainText();
file.close(); file.close();
} else { } else {
QMessageBox::warning(this, "Error", "Could not open the file for writing"); QMessageBox::warning(this, tr("Error"), tr("Could not open the file for writing"));
} }
} }
@ -121,7 +121,7 @@ void EditorDialog::closeEvent(QCloseEvent* event) {
} }
if (hasUnsavedChanges()) { if (hasUnsavedChanges()) {
QMessageBox::StandardButton reply; QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Save Changes", "Do you want to save changes?", reply = QMessageBox::question(this, tr("Save Changes"), tr("Do you want to save changes?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
if (reply == QMessageBox::Yes) { if (reply == QMessageBox::Yes) {
@ -168,7 +168,7 @@ void EditorDialog::onCancelClicked() {
void EditorDialog::onHelpClicked() { void EditorDialog::onHelpClicked() {
if (!isHelpOpen) { if (!isHelpOpen) {
helpDialog = new HelpDialog(&isHelpOpen, this); helpDialog = new HelpDialog(&isHelpOpen, this);
helpDialog->setWindowTitle("Help"); helpDialog->setWindowTitle(tr("Help"));
helpDialog->setAttribute(Qt::WA_DeleteOnClose); // Clean up on close helpDialog->setAttribute(Qt::WA_DeleteOnClose); // Clean up on close
// Get the position and size of the Config window // Get the position and size of the Config window
QRect configGeometry = this->geometry(); QRect configGeometry = this->geometry();
@ -188,10 +188,10 @@ void EditorDialog::onResetToDefaultClicked() {
bool default_default = gameComboBox->currentText() == "default"; bool default_default = gameComboBox->currentText() == "default";
QString prompt = QString prompt =
default_default default_default
? "Do you want to reset your custom default config to the original default config?" ? tr("Do you want to reset your custom default config to the original default config?")
: "Do you want to reset this config to your custom default config?"; : tr("Do you want to reset this config to your custom default config?");
QMessageBox::StandardButton reply = QMessageBox::StandardButton reply = QMessageBox::question(this, tr("Reset to Default"), prompt,
QMessageBox::question(this, "Reset to Default", prompt, QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) { if (reply == QMessageBox::Yes) {
if (default_default) { if (default_default) {
@ -206,7 +206,7 @@ void EditorDialog::onResetToDefaultClicked() {
editor->setPlainText(in.readAll()); editor->setPlainText(in.readAll());
file.close(); file.close();
} else { } else {
QMessageBox::warning(this, "Error", "Could not open the file for reading"); QMessageBox::warning(this, tr("Error"), tr("Could not open the file for reading"));
} }
// saveFile(gameComboBox->currentText()); // saveFile(gameComboBox->currentText());
} }

View file

@ -87,15 +87,16 @@ KBMSettings::KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, QWidget*
connect(ui->CopyCommonButton, &QPushButton::clicked, this, [this] { connect(ui->CopyCommonButton, &QPushButton::clicked, this, [this] {
if (ui->ProfileComboBox->currentText() == "Common Config") { if (ui->ProfileComboBox->currentText() == "Common Config") {
QMessageBox::information(this, "Common Config Selected", QMessageBox::information(this, tr("Common Config Selected"),
"This button copies mappings from the Common Config to the " // clang-format off
"currently selected profile, and cannot be used when the " tr("This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config."));
"currently selected profile is the Common Config."); // clang-format on
} else { } else {
QMessageBox::StandardButton reply = QMessageBox::StandardButton reply =
QMessageBox::question(this, "Copy values from Common Config", QMessageBox::question(this, tr("Copy values from Common Config"),
"Do you want to overwrite existing mappings with the " // clang-format off
"mappings from the Common Config?", tr("Do you want to overwrite existing mappings with the mappings from the Common Config?"),
// clang-format on
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) { if (reply == QMessageBox::Yes) {
SetUIValuestoMappings("default"); SetUIValuestoMappings("default");
@ -423,8 +424,8 @@ void KBMSettings::SaveKBMConfig(bool CloseOnSave) {
// Prevent duplicate inputs for KBM as this breaks the engine // Prevent duplicate inputs for KBM as this breaks the engine
for (auto it = inputs.begin(); it != inputs.end(); ++it) { for (auto it = inputs.begin(); it != inputs.end(); ++it) {
if (std::find(it + 1, inputs.end(), *it) != inputs.end()) { if (std::find(it + 1, inputs.end(), *it) != inputs.end()) {
QMessageBox::information(this, "Unable to Save", QMessageBox::information(this, tr("Unable to Save"),
"Cannot bind any unique input more than once"); tr("Cannot bind any unique input more than once"));
return; return;
} }
} }
@ -625,7 +626,7 @@ void KBMSettings::GetGameTitle() {
void KBMSettings::onHelpClicked() { void KBMSettings::onHelpClicked() {
if (!HelpWindowOpen) { if (!HelpWindowOpen) {
HelpWindow = new HelpDialog(&HelpWindowOpen, this); HelpWindow = new HelpDialog(&HelpWindowOpen, this);
HelpWindow->setWindowTitle("Help"); HelpWindow->setWindowTitle(tr("Help"));
HelpWindow->setAttribute(Qt::WA_DeleteOnClose); // Clean up on close HelpWindow->setAttribute(Qt::WA_DeleteOnClose); // Clean up on close
HelpWindow->show(); HelpWindow->show();
HelpWindowOpen = true; HelpWindowOpen = true;
@ -643,7 +644,7 @@ void KBMSettings::StartTimer(QPushButton*& button) {
mapping = button->text(); mapping = button->text();
DisableMappingButtons(); DisableMappingButtons();
button->setText("Press a key [" + QString::number(MappingTimer) + "]"); button->setText(tr("Press a key") + " [" + QString::number(MappingTimer) + "]");
timer = new QTimer(this); timer = new QTimer(this);
MappingButton = button; MappingButton = button;
connect(timer, &QTimer::timeout, this, [this]() { CheckMapping(MappingButton); }); connect(timer, &QTimer::timeout, this, [this]() { CheckMapping(MappingButton); });
@ -652,7 +653,7 @@ void KBMSettings::StartTimer(QPushButton*& button) {
void KBMSettings::CheckMapping(QPushButton*& button) { void KBMSettings::CheckMapping(QPushButton*& button) {
MappingTimer -= 1; MappingTimer -= 1;
button->setText("Press a key [" + QString::number(MappingTimer) + "]"); button->setText(tr("Press a key") + " [" + QString::number(MappingTimer) + "]");
if (MappingCompleted) { if (MappingCompleted) {
EnableMapping = false; EnableMapping = false;
@ -1003,15 +1004,15 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) { if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) {
SetMapping("mousewheelup"); SetMapping("mousewheelup");
} else { } else {
QMessageBox::information(this, "Cannot set mapping", QMessageBox::information(this, tr("Cannot set mapping"),
"Mousewheel cannot be mapped to stick outputs"); tr("Mousewheel cannot be mapped to stick outputs"));
} }
} else if (wheelEvent->angleDelta().y() < -5) { } else if (wheelEvent->angleDelta().y() < -5) {
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) { if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) {
SetMapping("mousewheeldown"); SetMapping("mousewheeldown");
} else { } else {
QMessageBox::information(this, "Cannot set mapping", QMessageBox::information(this, tr("Cannot set mapping"),
"Mousewheel cannot be mapped to stick outputs"); tr("Mousewheel cannot be mapped to stick outputs"));
} }
} }
if (wheelEvent->angleDelta().x() > 5) { if (wheelEvent->angleDelta().x() > 5) {
@ -1023,8 +1024,8 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
SetMapping("mousewheelright"); SetMapping("mousewheelright");
} }
} else { } else {
QMessageBox::information(this, "Cannot set mapping", QMessageBox::information(this, tr("Cannot set mapping"),
"Mousewheel cannot be mapped to stick outputs"); tr("Mousewheel cannot be mapped to stick outputs"));
} }
} else if (wheelEvent->angleDelta().x() < -5) { } else if (wheelEvent->angleDelta().x() < -5) {
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) { if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) {
@ -1034,8 +1035,8 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
SetMapping("mousewheelleft"); SetMapping("mousewheelleft");
} }
} else { } else {
QMessageBox::information(this, "Cannot set mapping", QMessageBox::information(this, tr("Cannot set mapping"),
"Mousewheel cannot be mapped to stick outputs"); tr("Mousewheel cannot be mapped to stick outputs"));
} }
} }
return true; return true;

View file

@ -77,11 +77,11 @@ HelpDialog::HelpDialog(bool* open_flag, QWidget* parent) : QDialog(parent) {
QVBoxLayout* containerLayout = new QVBoxLayout(containerWidget); QVBoxLayout* containerLayout = new QVBoxLayout(containerWidget);
// Add expandable sections to container layout // Add expandable sections to container layout
auto* quickstartSection = new ExpandableSection("Quickstart", quickstart()); auto* quickstartSection = new ExpandableSection(tr("Quickstart"), quickstart());
auto* faqSection = new ExpandableSection("FAQ", faq()); auto* faqSection = new ExpandableSection(tr("FAQ"), faq());
auto* syntaxSection = new ExpandableSection("Syntax", syntax()); auto* syntaxSection = new ExpandableSection(tr("Syntax"), syntax());
auto* specialSection = new ExpandableSection("Special Bindings", special()); auto* specialSection = new ExpandableSection(tr("Special Bindings"), special());
auto* bindingsSection = new ExpandableSection("Keybindings", bindings()); auto* bindingsSection = new ExpandableSection(tr("Keybindings"), bindings());
containerLayout->addWidget(quickstartSection); containerLayout->addWidget(quickstartSection);
containerLayout->addWidget(faqSection); containerLayout->addWidget(faqSection);
@ -109,4 +109,4 @@ HelpDialog::HelpDialog(bool* open_flag, QWidget* parent) : QDialog(parent) {
connect(syntaxSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize); connect(syntaxSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize);
connect(specialSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize); connect(specialSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize);
connect(bindingsSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize); connect(bindingsSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize);
} }

View file

@ -235,21 +235,6 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
Common::FS::GetUserPath(Common::FS::PathType::CustomTrophy)); Common::FS::GetUserPath(Common::FS::PathType::CustomTrophy));
QDesktopServices::openUrl(QUrl::fromLocalFile(userPath)); QDesktopServices::openUrl(QUrl::fromLocalFile(userPath));
}); });
connect(ui->PortableUserButton, &QPushButton::clicked, this, []() {
QString userDir;
Common::FS::PathToQString(userDir, std::filesystem::current_path() / "user");
if (std::filesystem::exists(std::filesystem::current_path() / "user")) {
QMessageBox::information(NULL, "Cannot create portable user folder",
userDir + " already exists");
} else {
std::filesystem::copy(Common::FS::GetUserPath(Common::FS::PathType::UserDir),
std::filesystem::current_path() / "user",
std::filesystem::copy_options::recursive);
QMessageBox::information(NULL, "Portable user folder created",
userDir + " successfully created");
}
});
} }
// Input TAB // Input TAB
@ -300,6 +285,21 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
ui->currentSaveDataPath->setText(save_data_path_string); ui->currentSaveDataPath->setText(save_data_path_string);
} }
}); });
connect(ui->PortableUserButton, &QPushButton::clicked, this, []() {
QString userDir;
Common::FS::PathToQString(userDir, std::filesystem::current_path() / "user");
if (std::filesystem::exists(std::filesystem::current_path() / "user")) {
QMessageBox::information(NULL, tr("Cannot create portable user folder"),
tr("%1 already exists").arg(userDir));
} else {
std::filesystem::copy(Common::FS::GetUserPath(Common::FS::PathType::UserDir),
std::filesystem::current_path() / "user",
std::filesystem::copy_options::recursive);
QMessageBox::information(NULL, tr("Portable user folder created"),
tr("%1 successfully created.").arg(userDir));
}
});
} }
// DEBUG TAB // DEBUG TAB