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

@@ -28,7 +28,7 @@ MainWindow::MainWindow(Simulation* sim, const std::string& configDir, QWidget* p
, m_visuals(VisualsLoader::load(configDir + "/visuals.toml"))
, m_sim(sim)
{
setWindowTitle("Dota Factory");
setWindowTitle(tr("Dota Factory"));
resize(1280, 768);
m_headerBar = new HeaderBar(this);
@@ -127,8 +127,8 @@ MainWindow::MainWindow(Simulation* sim, const std::string& configDir, QWidget* p
}
catch (const std::exception& e)
{
QMessageBox::critical(this, "Load Error",
QString("Failed to load ship_layouts.toml:\n%1").arg(e.what()));
QMessageBox::critical(this, tr("Load Error"),
tr("Failed to load ship_layouts.toml:\n%1").arg(e.what()));
m_layoutBlueprints.clear();
}
}
@@ -183,10 +183,10 @@ void MainWindow::onEscapeMenuRequested()
m_gameWorldView->setGameSpeed(0.0);
QMessageBox box(this);
box.setWindowTitle("Paused");
QPushButton* continueBtn = box.addButton("Continue", QMessageBox::AcceptRole);
QPushButton* restartBtn = box.addButton("Restart", QMessageBox::ResetRole);
QPushButton* quitBtn = box.addButton("Quit", QMessageBox::DestructiveRole);
box.setWindowTitle(tr("Paused"));
QPushButton* continueBtn = box.addButton(tr("Continue"), QMessageBox::AcceptRole);
QPushButton* restartBtn = box.addButton(tr("Restart"), QMessageBox::ResetRole);
QPushButton* quitBtn = box.addButton(tr("Quit"), QMessageBox::DestructiveRole);
box.setEscapeButton(continueBtn);
box.exec();
@@ -202,8 +202,8 @@ void MainWindow::onEscapeMenuRequested()
}
catch (const std::exception& e)
{
QMessageBox::critical(this, "Config Error",
QString("Failed to reload config:\n%1").arg(e.what()));
QMessageBox::critical(this, tr("Config Error"),
tr("Failed to reload config:\n%1").arg(e.what()));
m_gameWorldView->setGameSpeed(prevSpeed);
return;
}
@@ -255,12 +255,12 @@ void MainWindow::onGameOver()
const int seconds = totalSeconds % 60;
QMessageBox box(this);
box.setWindowTitle("Game Over");
box.setText(QString("HQ destroyed!\nSurvival time: %1:%2")
box.setWindowTitle(tr("Game Over"));
box.setText(tr("HQ destroyed!\nSurvival time: %1:%2")
.arg(minutes, 2, 10, QChar('0'))
.arg(seconds, 2, 10, QChar('0')));
QPushButton* restartBtn = box.addButton("Restart", QMessageBox::AcceptRole);
box.addButton("Quit", QMessageBox::RejectRole);
QPushButton* restartBtn = box.addButton(tr("Restart"), QMessageBox::AcceptRole);
box.addButton(tr("Quit"), QMessageBox::RejectRole);
box.exec();
if (box.clickedButton() == restartBtn)
@@ -274,8 +274,8 @@ void MainWindow::onGameOver()
}
catch (const std::exception& e)
{
QMessageBox::critical(this, "Config Error",
QString("Failed to reload config:\n%1").arg(e.what()));
QMessageBox::critical(this, tr("Config Error"),
tr("Failed to reload config:\n%1").arg(e.what()));
return;
}
m_gameWorldView->resetForNewGame();