From fd32cb414fdb3100594f237884bcfd8c6127c0fc Mon Sep 17 00:00:00 2001 From: MarekWo Date: Fri, 31 Jul 2026 18:02:35 +0200 Subject: [PATCH] feat(i18n): translate the Console panel chrome (stage 2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 14 keys: title, connection status, the help hint, history and clear tooltips, the command placeholder, the scroll-to-latest button, and the two error wrappers. Everything the Console actually prints stays English, which is most of what is on screen: the `help` screen, command names, device replies, `(no output)`'s surroundings. data.output and data.error are composed by the backend and the firmware, so only the wrapper around them is translated — "Error: {error}" becomes "Błąd: {error}" with the English message intact. The 'help' inside the hint text is the literal command name and is marked as such in the template. "polecenie" over "komenda" for command, matching how Polish software normally renders CLI terminology. Also adds F:\tmp\pwverify\i18n-diff.js — a reusable check that renders a page in both languages and reports every visible string that came out identical. Each hit is either a missed extraction or something meant to stay English, so it turns "switch to Polish and hunt for English words" into a list to review rather than a squint. It pays for itself from stage 3 on, where the slices get large. Its output for this slice: /console has exactly one identical string, the user's own device name; /logs has eight, all Python logger names in the module filter. Both correct. Co-Authored-By: Claude Opus 5 --- app/static/js/console.js | 20 ++++++++++---------- app/templates/console.html | 18 ++++++++++-------- app/translations/en.json | 15 +++++++++++++++ app/translations/pl.json | 15 +++++++++++++++ 4 files changed, 50 insertions(+), 18 deletions(-) diff --git a/app/static/js/console.js b/app/static/js/console.js index 415b7fe..782ec63 100644 --- a/app/static/js/console.js +++ b/app/static/js/console.js @@ -60,7 +60,7 @@ function connectWebSocket() { updateStatus('disconnected'); enableInput(false); // Transient session event — show inline but don't persist to transcript - addMessage('Disconnected', 'error', false); + addMessage(t('console.status.disconnected'), 'error', false); // Clear pending command indicator if (pendingCommandDiv) { @@ -91,12 +91,12 @@ function connectWebSocket() { pendingCommandDiv = null; } - // Display response + // Display response. data.output and data.error are CLI output composed by + // the device/backend — English by design, only the wrapper is translated. if (data.success) { - const output = data.output || '(no output)'; - addMessage(output, 'response'); + addMessage(data.output || t('console.no_output'), 'response'); } else { - addMessage(`Error: ${data.error}`, 'error'); + addMessage(t('console.error_prefix', { error: data.error }), 'error'); } scrollToBottom(); }); @@ -104,7 +104,7 @@ function connectWebSocket() { } catch (error) { console.error('Failed to create WebSocket connection:', error); updateStatus('disconnected'); - addMessage('Failed to connect: ' + error.message, 'error', false); + addMessage(t('console.connect_failed', { error: error.message }), 'error', false); } } @@ -245,15 +245,15 @@ function updateStatus(status) { switch (status) { case 'connected': - text.textContent = 'Connected'; + text.textContent = t('console.status.connected'); text.className = 'text-success'; break; case 'disconnected': - text.textContent = 'Disconnected'; + text.textContent = t('console.status.disconnected'); text.className = 'text-danger'; break; case 'connecting': - text.textContent = 'Connecting...'; + text.textContent = t('console.status.connecting'); text.className = 'text-warning'; break; } @@ -391,7 +391,7 @@ function populateHistoryDropdown() { historyMenu.innerHTML = ''; if (serverHistory.length === 0) { - historyMenu.innerHTML = '
No commands in history
'; + historyMenu.innerHTML = `
${tHtml('console.history_empty')}
`; return; } diff --git a/app/templates/console.html b/app/templates/console.html index 664245e..d1dd9f0 100644 --- a/app/templates/console.html +++ b/app/templates/console.html @@ -3,7 +3,7 @@ - Console - mc-webui + {{ t('console.title') }} - mc-webui {% include "_head_i18n.html" %} @@ -309,16 +309,18 @@ {{ device_name }}
- Connecting... + {{ t('console.status.connecting') }}
-
Type 'help' for available commands.
+ {# 'help' is the literal command name — never translated. #} +
{{ t('console.help_hint') }}
-
@@ -328,21 +330,21 @@
-
-
No commands in history
+
{{ t('console.history_empty') }}
-