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

@@ -69,10 +69,10 @@ QString rotationLabel(Rotation r)
{
switch (r)
{
case Rotation::North: return "North (↑)";
case Rotation::East: return "East (→)";
case Rotation::South: return "South (↓)";
case Rotation::West: return "West (←)";
case Rotation::North: return QObject::tr("North (↑)");
case Rotation::East: return QObject::tr("East (→)");
case Rotation::South: return QObject::tr("South (↓)");
case Rotation::West: return QObject::tr("West (←)");
}
return "";
}
@@ -96,13 +96,13 @@ SelectedBuildingPanel::SelectedBuildingPanel(Simulation* sim,
m_titleLabel = new QLabel(this);
m_recipeCombo = new QComboBox(this);
m_clearBeltBtn = new QPushButton("Clear Items", this);
m_clearBeltBtn = new QPushButton(tr("Clear Items"), this);
m_filterALabel = new QLabel(this);
m_filterAList = new QListWidget(this);
m_filterBLabel = new QLabel(this);
m_filterBList = new QListWidget(this);
m_layoutPreview = new ShipLayoutPreview(this);
m_configureLayoutBtn = new QPushButton("Configure Layout", this);
m_configureLayoutBtn = new QPushButton(tr("Configure Layout"), this);
m_buffersLabel = new QLabel(this);
m_buffersLabel->setWordWrap(true);
@@ -192,7 +192,7 @@ void SelectedBuildingPanel::buildSingle(BuildingId id)
QString progress;
if (s->completesAt == 0)
{
progress = "Queued";
progress = tr("Queued");
}
else
{
@@ -207,15 +207,15 @@ void SelectedBuildingPanel::buildSingle(BuildingId id)
const Tick elapsed = m_sim->currentTick() - (s->completesAt - duration);
const int pct = static_cast<int>(
std::max(Tick(0), std::min(duration, elapsed)) * 100 / duration);
progress = QString::number(pct) + "% complete";
progress = tr("%1% complete").arg(pct);
}
else
{
progress = "Building...";
progress = tr("Building...");
}
}
m_titleLabel->setText("(Building) " + buildingTypeName(s->type));
m_titleLabel->setText(tr("(Building) %1").arg(buildingTypeName(s->type)));
m_titleLabel->show();
m_buffersLabel->setText(progress);
m_buffersLabel->show();
@@ -231,7 +231,7 @@ void SelectedBuildingPanel::buildSingle(BuildingId id)
m_recipeCombo->blockSignals(true);
m_recipeCombo->clear();
m_recipeCombo->addItem("(none)", QString());
m_recipeCombo->addItem(tr("(none)"), QString());
if (b->type == BuildingType::Shipyard)
{
@@ -333,7 +333,7 @@ void SelectedBuildingPanel::refreshBuffers(const Building* b)
if (!b->inputBuffer.counts.empty())
{
bufText += "Input: ";
bufText += tr("Input: ");
for (const std::pair<const ItemType, int>& entry : b->inputBuffer.counts)
{
int perCycle = 0;
@@ -389,7 +389,7 @@ void SelectedBuildingPanel::refreshBuffers(const Building* b)
{
outCounts[item.type.id]++;
}
bufText += "Output: ";
bufText += tr("Output: ");
for (const RecipeOutput& out : recipe->outputs)
{
const std::map<std::string, int>::const_iterator it =
@@ -407,7 +407,7 @@ void SelectedBuildingPanel::refreshBuffers(const Building* b)
{
outCounts[item.type.id]++;
}
bufText += "Output: ";
bufText += tr("Output: ");
for (const std::pair<const std::string, int>& entry : outCounts)
{
bufText += QString::fromStdString(entry.first)
@@ -436,7 +436,7 @@ void SelectedBuildingPanel::refreshBuffers(const Building* b)
}
}
bufText += QString("Cycle: %1 s\n").arg(durationSeconds, 0, 'f', 1);
bufText += tr("Cycle: %1 s\n").arg(durationSeconds, 0, 'f', 1);
if (b->production.has_value())
{
@@ -446,11 +446,11 @@ void SelectedBuildingPanel::refreshBuffers(const Building* b)
const Tick elapsed = currentTick - (completesAt - cycleTicks);
const int pct = static_cast<int>(
std::max(Tick(0), std::min(cycleTicks, elapsed)) * 100 / cycleTicks);
bufText += QString("Progress: %1%\n").arg(pct);
bufText += tr("Progress: %1%\n").arg(pct);
}
else
{
bufText += "Progress: idle\n";
bufText += tr("Progress: idle\n");
}
}
@@ -496,7 +496,7 @@ void SelectedBuildingPanel::onStateUpdated(Tick /*tick*/, int /*blocks*/, double
{
// If the panel was last showing this id as a construction site, the
// full building UI (recipe combo, ports, etc.) hasn't been built yet.
if (m_titleLabel->text().startsWith("(Building) "))
if (m_titleLabel->text().startsWith(tr("(Building) ")))
{
rebuild();
}
@@ -592,7 +592,7 @@ void SelectedBuildingPanel::buildSplitterFilters(QPoint splitterTile)
const QString& dirLabel,
const std::vector<ItemType>& filter)
{
label->setText(dirLabel + " filter (empty = all):");
label->setText(tr("%1 filter (empty = all):").arg(dirLabel));
list->blockSignals(true);
list->clear();
for (const std::string& itemId : items)