i18n(mining): route xmrig updater strings through TR()

Replace the English string literals in the miner-update dialog + the "Update miner…" mining-tab
button/tooltip with TR() keys, and register their English text in i18n.cpp's loadBuiltinEnglish()
(the in-code English fallback that non-English locales overlay). Reuses the existing cancel/close/
retry keys. Labeled values use a "%s %s" literal format with a TR'd label (no -Wformat-security
risk). Non-English locales fall back to English for the new xmrig_* keys until translations are
added to res/lang/*.json.

Both variants build; suite passes; hygiene clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 09:34:14 -05:00
parent b9881278af
commit 64fe8fc6c9
3 changed files with 51 additions and 29 deletions

View File

@@ -1582,11 +1582,11 @@ static void RenderMiningTabContent(App* app)
if (s_pool_mode) {
const bool minerBusy = state.pool_mining.xmrig_running;
ImGui::BeginDisabled(minerBusy);
if (TactileButton("Update miner…", ImVec2(availWidth, 0)))
if (TactileButton(TR("xmrig_update_button"), ImVec2(availWidth, 0)))
XmrigDownloadDialog::show(app);
ImGui::EndDisabled();
if (minerBusy && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
ImGui::SetTooltip("Stop mining before updating the miner.");
ImGui::SetTooltip("%s", TR("xmrig_stop_mining_first"));
ImGui::Dummy(ImVec2(0, gap));
}

View File

@@ -15,6 +15,7 @@
#include "../../app.h"
#include "../../config/settings.h"
#include "../../resources/embedded_resources.h" // resources::getDaemonDirectory()
#include "../../util/i18n.h"
#include "../../util/xmrig_updater.h"
#include "../material/draw_helpers.h"
#include "../material/type.h"
@@ -45,7 +46,7 @@ public:
}
using namespace material;
const float dp = Layout::dpiScale();
if (BeginOverlayDialog("Update Miner", &s_open, 480.0f, 0.94f)) {
if (BeginOverlayDialog(TR("xmrig_update_title"), &s_open, 480.0f, 0.94f)) {
const auto p = s_updater->getProgress();
using St = util::XmrigUpdater::State;
switch (p.state) {
@@ -77,7 +78,7 @@ private:
using namespace material;
if (s_app->isPoolMinerRunning()) {
Type().textColored(TypeStyle::Caption, OnSurfaceMedium(),
"Stop mining before updating the miner.");
TR("xmrig_stop_mining_first"));
return;
}
if (TactileButton(label, ImVec2(fullW(), 0)))
@@ -86,49 +87,48 @@ private:
static void renderChecking(float, const Progress&) {
using namespace material;
Type().text(TypeStyle::Body2, "Checking for the latest miner…");
Type().text(TypeStyle::Body2, TR("xmrig_checking"));
}
static void renderUnavailable(float, const Progress& p) {
using namespace material;
Type().text(TypeStyle::Subtitle2, "Miner updates unavailable");
Type().text(TypeStyle::Subtitle2, TR("xmrig_unavailable_title"));
ImGui::Spacing();
ImGui::TextWrapped("%s", p.status_text.empty()
? "No miner build is available for this platform."
? TR("xmrig_unavailable_body")
: p.status_text.c_str());
ImGui::Spacing();
if (TactileButton("Close", ImVec2(fullW(), 0))) s_open = false;
if (TactileButton(TR("close"), ImVec2(fullW(), 0))) s_open = false;
}
static void renderPrompt(float, const Progress& p) {
using namespace material;
const std::string installed = p.installed_tag.empty() ? "none" : p.installed_tag;
if (p.state == St::UpdateAvailable) {
Type().text(TypeStyle::Subtitle2, "A new miner is available");
Type().text(TypeStyle::Subtitle2, TR("xmrig_update_available"));
ImGui::Spacing();
ImGui::Text("Latest: %s", p.latest_tag.c_str());
ImGui::Text("Installed: %s", installed.c_str());
ImGui::Text("%s %s", TR("xmrig_latest"), p.latest_tag.c_str());
ImGui::Text("%s %s", TR("xmrig_installed"), installed.c_str());
ImGui::Spacing();
Type().textColored(TypeStyle::Caption, OnSurfaceMedium(),
"The download is checked against the release's published SHA-256 checksum before install.");
Type().textColored(TypeStyle::Caption, OnSurfaceMedium(), TR("xmrig_verify_note"));
ImGui::Spacing();
installAction("Download & install");
installAction(TR("xmrig_download_install"));
} else {
Type().text(TypeStyle::Subtitle2, "The miner is up to date");
Type().text(TypeStyle::Subtitle2, TR("xmrig_up_to_date"));
ImGui::Spacing();
ImGui::Text("Installed: %s", p.latest_tag.c_str());
ImGui::Text("%s %s", TR("xmrig_installed"), p.latest_tag.c_str());
ImGui::Spacing();
installAction("Reinstall");
installAction(TR("xmrig_reinstall"));
}
ImGui::Spacing();
if (TactileButton("Close", ImVec2(fullW(), 0))) s_open = false;
if (TactileButton(TR("close"), ImVec2(fullW(), 0))) s_open = false;
}
static void renderProgress(float dp, const Progress& p) {
using namespace material;
const char* title = p.state == St::Downloading ? "Downloading"
: p.state == St::Verifying ? "Verifying"
: "Installing";
const char* title = p.state == St::Downloading ? TR("xmrig_downloading")
: p.state == St::Verifying ? TR("xmrig_verifying")
: TR("xmrig_installing");
Type().text(TypeStyle::Subtitle2, title);
ImGui::Spacing();
const float barH = 8.0f * dp;
@@ -145,7 +145,7 @@ private:
ImGui::Text("%s", p.status_text.c_str());
ImGui::Spacing();
// Cancel aborts the in-flight transfer promptly (the curl progress callback returns abort).
if (TactileButton("Cancel", ImVec2(fullW(), 0))) {
if (TactileButton(TR("cancel"), ImVec2(fullW(), 0))) {
s_updater->cancel();
s_open = false;
}
@@ -160,22 +160,22 @@ private:
}
s_persisted = true;
}
Type().textColored(TypeStyle::Subtitle2, Success(), "Miner installed");
Type().textColored(TypeStyle::Subtitle2, Success(), TR("xmrig_installed_ok"));
ImGui::Spacing();
ImGui::Text("Version: %s", p.latest_tag.c_str());
ImGui::Text("%s %s", TR("xmrig_version"), p.latest_tag.c_str());
ImGui::Spacing();
if (TactileButton("Close", ImVec2(fullW(), 0))) s_open = false;
if (TactileButton(TR("close"), ImVec2(fullW(), 0))) s_open = false;
}
static void renderFailed(float, const Progress& p) {
using namespace material;
Type().textColored(TypeStyle::Subtitle2, Error(), "Update failed");
Type().textColored(TypeStyle::Subtitle2, Error(), TR("xmrig_update_failed"));
ImGui::Spacing();
ImGui::TextWrapped("%s", p.error.empty() ? "Unknown error." : p.error.c_str());
ImGui::TextWrapped("%s", p.error.empty() ? TR("xmrig_unknown_error") : p.error.c_str());
ImGui::Spacing();
installAction("Retry");
installAction(TR("retry"));
ImGui::Spacing();
if (TactileButton("Close", ImVec2(fullW(), 0))) s_open = false;
if (TactileButton(TR("close"), ImVec2(fullW(), 0))) s_open = false;
}
static inline bool s_open = false;

View File

@@ -1036,6 +1036,28 @@ void I18n::loadBuiltinEnglish()
strings_["mining_uptime"] = "Uptime";
strings_["mining_yesterday"] = "Yesterday";
// --- Miner (xmrig) updater ---
strings_["xmrig_update_button"] = "Update miner…";
strings_["xmrig_update_title"] = "Update Miner";
strings_["xmrig_stop_mining_first"] = "Stop mining before updating the miner.";
strings_["xmrig_checking"] = "Checking for the latest miner…";
strings_["xmrig_unavailable_title"] = "Miner updates unavailable";
strings_["xmrig_unavailable_body"] = "No miner build is available for this platform.";
strings_["xmrig_update_available"] = "A new miner is available";
strings_["xmrig_up_to_date"] = "The miner is up to date";
strings_["xmrig_latest"] = "Latest:";
strings_["xmrig_installed"] = "Installed:";
strings_["xmrig_version"] = "Version:";
strings_["xmrig_verify_note"] = "The download is checked against the release's published SHA-256 checksum before install.";
strings_["xmrig_download_install"] = "Download & install";
strings_["xmrig_reinstall"] = "Reinstall";
strings_["xmrig_downloading"] = "Downloading…";
strings_["xmrig_verifying"] = "Verifying…";
strings_["xmrig_installing"] = "Installing…";
strings_["xmrig_installed_ok"] = "Miner installed";
strings_["xmrig_update_failed"] = "Update failed";
strings_["xmrig_unknown_error"] = "Unknown error.";
// --- Peers Tab ---
strings_["peers_avg_ping"] = "Avg Ping";
strings_["peers_ban_24h"] = "Ban Peer 24h";