wrap UI strings with tr()

This commit is contained in:
2026-06-05 16:31:54 +02:00
parent 900b5fdec1
commit 17e9913c98
9 changed files with 72 additions and 72 deletions

View File

@@ -29,7 +29,7 @@ BlueprintPanel::BlueprintPanel(Simulation* sim, const GameConfig* config, QWidge
layout->setContentsMargins(4, 4, 4, 4);
layout->setSpacing(4);
m_createBtn = new QPushButton("Create Blueprint", this);
m_createBtn = new QPushButton(tr("Create Blueprint"), this);
m_createBtn->setFixedHeight(48);
m_createBtn->setEnabled(false);
layout->addWidget(m_createBtn);
@@ -50,8 +50,8 @@ BlueprintPanel::BlueprintPanel(Simulation* sim, const GameConfig* config, QWidge
connect(m_createBtn, &QPushButton::clicked, this, &BlueprintPanel::onCreateClicked);
QHBoxLayout* ioLayout = new QHBoxLayout();
m_saveBtn = new QPushButton("Save", this);
m_loadBtn = new QPushButton("Load", this);
m_saveBtn = new QPushButton(tr("Save"), this);
m_loadBtn = new QPushButton(tr("Load"), this);
m_saveBtn->setFixedHeight(36);
m_loadBtn->setFixedHeight(36);
ioLayout->addWidget(m_saveBtn);
@@ -93,7 +93,7 @@ void BlueprintPanel::onCreateClicked()
bool ok = false;
const QString name = QInputDialog::getText(
this, "Create Blueprint", "Blueprint name:", QLineEdit::Normal, QString(), &ok);
this, tr("Create Blueprint"), tr("Blueprint name:"), QLineEdit::Normal, QString(), &ok);
if (!ok || name.trimmed().isEmpty()) { return; }
bp.name = name.trimmed();
@@ -223,7 +223,7 @@ void BlueprintPanel::rebuildButtons()
{
const Blueprint& bp = m_blueprints[static_cast<std::size_t>(i)];
const int cost = computeBlueprintCost(bp);
const QString label = bp.name + "\n" + QString::number(cost) + " Blocks";
const QString label = bp.name + "\n" + tr("%1 Blocks").arg(cost);
QWidget* row = new QWidget(m_buttonsContainer);
QHBoxLayout* rowLayout = new QHBoxLayout(row);
@@ -266,26 +266,26 @@ void BlueprintPanel::onSaveClicked()
QFile file(path);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QMessageBox::critical(this, "Save Failed",
QString("Could not open file for writing:\n%1").arg(path));
QMessageBox::critical(this, tr("Save Failed"),
tr("Could not open file for writing:\n%1").arg(path));
return;
}
file.write(QByteArray::fromStdString(content));
}
catch (const std::exception& e)
{
QMessageBox::critical(this, "Save Failed",
QString("Failed to save blueprints:\n%1").arg(e.what()));
QMessageBox::critical(this, tr("Save Failed"),
tr("Failed to save blueprints:\n%1").arg(e.what()));
}
}
void BlueprintPanel::onLoadClicked()
{
QMessageBox box(this);
box.setWindowTitle("Load Blueprints");
box.setText("Load blueprints? This will replace all current blueprints.");
QPushButton* confirmBtn = box.addButton("Confirm", QMessageBox::AcceptRole);
box.addButton("Cancel", QMessageBox::RejectRole);
box.setWindowTitle(tr("Load Blueprints"));
box.setText(tr("Load blueprints? This will replace all current blueprints."));
QPushButton* confirmBtn = box.addButton(tr("Confirm"), QMessageBox::AcceptRole);
box.addButton(tr("Cancel"), QMessageBox::RejectRole);
box.exec();
if (box.clickedButton() != confirmBtn) { return; }
@@ -295,8 +295,8 @@ void BlueprintPanel::onLoadClicked()
QFile file(path);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QMessageBox::critical(this, "Load Failed",
QString("Could not open file:\n%1").arg(path));
QMessageBox::critical(this, tr("Load Failed"),
tr("Could not open file:\n%1").arg(path));
return;
}
const std::string content = file.readAll().toStdString();
@@ -313,8 +313,8 @@ void BlueprintPanel::onLoadClicked()
}
catch (const std::exception& e)
{
QMessageBox::critical(this, "Load Failed",
QString("Failed to load blueprints:\n%1").arg(e.what()));
QMessageBox::critical(this, tr("Load Failed"),
tr("Failed to load blueprints:\n%1").arg(e.what()));
}
}