From dddd1fa03fe54481fbe5822f7d73cdd4435fda2f Mon Sep 17 00:00:00 2001 From: daikaginza Date: Sat, 17 Oct 2026 07:28:26 +0700 Subject: [PATCH 1/6] fix(i18n): translate mapped-site feedback by its shape where it is shown Add the Mapped Installations feedback shapes (site counts in view or around the contact, and the Overpass retry lines) to statusText.js, and show statusMessage through translateStatusPiece in the Layers panel, the nearby-search toast and the awareness panel. The voice card's analyst notes already fall back to translateStatusLine, so they pick the shapes up too. --- scripts/package-boundaries.json | 7 ++-- src/layers/awareness/panel.js | 5 +-- src/ui/contextBindings.js | 3 +- src/ui/layerPanel.js | 14 ++++---- src/ui/statusText.js | 52 +++++++++++++++++++++++++++- src/voice/analystEmptyNotes.test.mjs | 21 +++++++++++ 6 files changed, 88 insertions(+), 14 deletions(-) diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json index 43bc3d4de9..190e377e98 100644 --- a/scripts/package-boundaries.json +++ b/scripts/package-boundaries.json @@ -566,7 +566,8 @@ "src/i18n/locale.js", "src/i18n/locales/es.json", "src/i18n/locales/ru.json", - "src/ui/layerNames.js" + "src/ui/layerNames.js", + "src/ui/statusText.js" ], "external": [] }, @@ -1242,7 +1243,9 @@ "src/i18n/locale.js", "src/i18n/locales/es.json", "src/i18n/locales/ru.json", - "src/ui/unitLabels.js" + "src/ui/unitLabels.js", + "src/ui/layerNames.js", + "src/ui/statusText.js" ], "external": ["cesium"] }, diff --git a/src/layers/awareness/panel.js b/src/layers/awareness/panel.js index 5fe2a0ac8a..f8f3d55eb9 100644 --- a/src/layers/awareness/panel.js +++ b/src/layers/awareness/panel.js @@ -2,7 +2,8 @@ import { formatAwarenessLabel, AWARENESS_RADIUS_M, } from '../../data/militaryAwarenessEngine.js'; -import { formatNumber, t, translateKnown } from '../../i18n/index.js'; +import { formatNumber, t } from '../../i18n/index.js'; +import { translateStatusPiece } from '../../ui/statusText.js'; import { formatQuantity } from '../../ui/unitLabels.js'; import { AWARENESS_PAGE_SIZE, AWARENESS_PAGE_ROTATE_MS } from './policy.js'; @@ -39,7 +40,7 @@ function presentAwarenessDistance(meters) { function presentAwarenessReason(summary = {}) { return summary.reasonTemplate ? t(summary.reasonTemplate, summary.reasonValues) - : translateKnown(summary.reason || ''); + : translateStatusPiece(summary.reason || ''); } export function createPanel({ state: layerState, services, parts, source }) { diff --git a/src/ui/contextBindings.js b/src/ui/contextBindings.js index 16a21df4f4..ef663eb702 100644 --- a/src/ui/contextBindings.js +++ b/src/ui/contextBindings.js @@ -1,4 +1,5 @@ import { t } from '../i18n/index.js'; +import { translateStatusPiece } from './statusText.js'; import { shouldExpandGlobalContextPanel } from '../rightRailPolicy.js'; export function _initGlobalContextPanel() { @@ -109,7 +110,7 @@ export function _initGlobalContextPanel() { if (this.destroyed || searched === false) return false; const stats = this.installations.getStats?.(); this.showToast( - stats?.statusMessage || + (stats?.statusMessage && translateStatusPiece(stats.statusMessage)) || (stats?.status === 'zoom-in' ? t('Zoom in to search mapped installations') : t('Nearby installations refreshed')), diff --git a/src/ui/layerPanel.js b/src/ui/layerPanel.js index 109d96c60a..7a69f74281 100644 --- a/src/ui/layerPanel.js +++ b/src/ui/layerPanel.js @@ -11,14 +11,12 @@ import { } from './layerNames.js'; export { localizeLayerName } from './layerNames.js'; import { createWeatherPanel } from './weatherPanel.js'; -import { translateFeedError, translateStatusLine } from './statusText.js'; import { - formatNumber, - getLocale, - msg, - t, - translateKnown, -} from '../i18n/index.js'; + translateFeedError, + translateStatusLine, + translateStatusPiece, +} from './statusText.js'; +import { formatNumber, getLocale, msg, t } from '../i18n/index.js'; // Feed-state values are machine ids (QA hooks, CSS feed-* classes); only the // label translates. @@ -672,7 +670,7 @@ export class LayerPanel { typeof stats.statusMessage === 'string' && stats.statusMessage.trim() ) { - return `${source} · ${translateKnown(stats.statusMessage.trim())}`; + return `${source} · ${translateStatusPiece(stats.statusMessage.trim())}`; } const ago = stats.lastUpdate ? this._timeAgo(stats.lastUpdate) : t('never'); if (stats.loading) { diff --git a/src/ui/statusText.js b/src/ui/statusText.js index b0899d55e1..b241abdbff 100644 --- a/src/ui/statusText.js +++ b/src/ui/statusText.js @@ -208,9 +208,59 @@ const STATUS_PIECE_PATTERNS = [ ], ]; +// Mapped Installations feedback (installationFeedback in +// data/installationFeedback.js): getStats().statusMessage is English data, and +// the Layers panel, the toast, the awareness panel and the voice card's analyst +// note show it through here. Keep these in step with that helper. +const MAPPED_SITE_PATTERNS = [ + [ + /^(.+) — retrying in (\d+)s$/, + ([, reason, seconds]) => + t('{reason} — retrying in {seconds}s', { + reason: translateKnown(reason), + seconds, + }), + ], + [ + /^(.+) — retry pending$/, + ([, reason]) => + t('{reason} — retry pending', { reason: translateKnown(reason) }), + ], + [/^No mapped sites in view$/, () => t('No mapped sites in view')], + [ + /^(\d+) mapped sites? in view$/, + ([, count]) => + tn( + Number(count), + '{count} mapped site in view', + '{count} mapped sites in view', + ), + ], + [ + /^No mapped sites within (\d+) km of the contact$/, + ([, km]) => + t('No mapped sites within {km} km of the contact', { + km: formatNumber(Number(km)), + }), + ], + [ + /^(\d+) mapped sites? within (\d+) km of the contact$/, + ([, count, km]) => + tn( + Number(count), + '{count} mapped site within {km} km of the contact', + '{count} mapped sites within {km} km of the contact', + { km: formatNumber(Number(km)) }, + ), + ], +]; + /** A status piece by its shape in the UI language, or null. */ function statusPatternText(piece) { - for (const [pattern, format] of STATUS_PIECE_PATTERNS) { + for (const [pattern, format] of [ + ...STATUS_PIECE_PATTERNS, + ...MAPPED_SITE_PATTERNS, + ]) { const match = pattern.exec(piece); if (match) return format(match); } diff --git a/src/voice/analystEmptyNotes.test.mjs b/src/voice/analystEmptyNotes.test.mjs index b0de16ebd5..101fe06179 100644 --- a/src/voice/analystEmptyNotes.test.mjs +++ b/src/voice/analystEmptyNotes.test.mjs @@ -74,6 +74,14 @@ const transitCoverage = [ 'transit: No feed here yet · 12 regions available', ]; +// Mapped Installations' statusMessage (data/installationFeedback.js). +const installationNotes = [ + 'military-installations: No mapped sites in view', + 'military-installations: No mapped sites within 25 km of the contact', + 'military-installations: Overpass timed out — retrying in 30s', + 'military-installations: Zoom in to search mapped installations', +]; + for (const locale of ['es', 'ru']) { for (const [layerKey, caveat] of cases) { test(`${locale}: analyst note "${caveat}" is translated`, () => { @@ -85,6 +93,19 @@ for (const locale of ['es', 'ru']) { }); } + test(`${locale}: Mapped Installations' empty note is translated on the analyst card`, () => { + inLocale(locale, () => { + for (const caveat of installationNotes) { + const notes = notesFor('military-installations', caveat); + assert.ok(notes.length > 0, 'the note is shown'); + assert.doesNotMatch( + notes.join(' | '), + /mapped sites|retrying|Overpass timed out|Zoom in/, + ); + } + }); + }); + test(`${locale}: Transit's empty note is translated on the analyst card`, () => { inLocale(locale, () => { for (const caveat of transitCoverage) { From 4515c5146aa09b01cc81d7e9bad0cfaa05b58600 Mon Sep 17 00:00:00 2001 From: daikaginza Date: Sat, 17 Oct 2026 07:28:26 +0700 Subject: [PATCH 2/6] fix(analyst): keep the Mapped Installations empty note English getStats().statusMessage was translated inside the layer, and the analyst uses it as the empty note it returns to the model, so an empty military-installations query carried Spanish or Russian text in an English tool result. Report installationFeedback() as English again; the displays translate it by its shape. --- src/data/installationFeedback.js | 2 +- src/layers/installations/controls.js | 44 +---- .../installationFeedbackLocale.test.mjs | 160 ++++++++++++------ 3 files changed, 116 insertions(+), 90 deletions(-) diff --git a/src/data/installationFeedback.js b/src/data/installationFeedback.js index 13e92c8b99..4dc1858ddf 100644 --- a/src/data/installationFeedback.js +++ b/src/data/installationFeedback.js @@ -1,6 +1,6 @@ import { msg } from '../i18n/marker.js'; -// layers/installations/controls.js translates describeInstallationFeedback(). +// installationFeedback() is English data; ui/statusText.js shows it translated. const REASONS = Object.freeze({ rate_limited: msg('Overpass rate-limited'), timeout: msg('Overpass timed out'), diff --git a/src/layers/installations/controls.js b/src/layers/installations/controls.js index 2fa31e59ef..608d6efbfc 100644 --- a/src/layers/installations/controls.js +++ b/src/layers/installations/controls.js @@ -1,37 +1,11 @@ import * as Cesium from 'cesium'; -import { describeInstallationFeedback } from '../../data/installationFeedback.js'; +import { installationFeedback } from '../../data/installationFeedback.js'; import { LAYER_ID, DISTANCE_PREFILTER_MARGIN_M, ANCHOR_REFRESH_M, } from './policy.js'; -import { formatNumber, t, tn } from '../../i18n/index.js'; - -// installationFeedback.js is shared with the HUD (src/loadingFeedback.js) and -// hands back msg()-marked English plus values; getStats translates them here. -function localizeInstallationFeedback(feedback) { - if (feedback.text !== undefined) { - const values = {}; - if (feedback.reason !== undefined) values.reason = t(feedback.reason); - if (feedback.seconds !== undefined) values.seconds = feedback.seconds; - return t(feedback.text, values); - } - const { count, km } = feedback; - if (km) { - const kmText = formatNumber(km); - return count === 0 - ? t('No mapped sites within {km} km of the contact', { km: kmText }) - : tn( - count, - '{count} mapped site within {km} km of the contact', - '{count} mapped sites within {km} km of the contact', - { km: kmText }, - ); - } - return count === 0 - ? t('No mapped sites in view') - : tn(count, '{count} mapped site in view', '{count} mapped sites in view'); -} +import { t } from '../../i18n/index.js'; export function createControls({ state: layerState, services, parts, source }) { const methods = { @@ -252,13 +226,13 @@ export function createControls({ state: layerState, services, parts, source }) { retryAt: layerState.retryAt, retrying: layerState.loading && Boolean(layerState.failureReason), failureReason: layerState.failureReason, - statusMessage: localizeInstallationFeedback( - describeInstallationFeedback({ - ...layerState, - count: layerState.lastUpdate ? mappedCount : undefined, - retrying: layerState.loading && Boolean(layerState.failureReason), - }), - ), + // English data: it is also the analyst's empty note to the model. + // Displays translate it by its shape (ui/statusText.js). + statusMessage: installationFeedback({ + ...layerState, + count: layerState.lastUpdate ? mappedCount : undefined, + retrying: layerState.loading && Boolean(layerState.failureReason), + }), loadingLabel: layerState.loading ? t('loading mapped installation context') : '', diff --git a/src/layers/installations/installationFeedbackLocale.test.mjs b/src/layers/installations/installationFeedbackLocale.test.mjs index cf4e758a33..7dac443510 100644 --- a/src/layers/installations/installationFeedbackLocale.test.mjs +++ b/src/layers/installations/installationFeedbackLocale.test.mjs @@ -1,6 +1,10 @@ +// getStats().statusMessage is English data (it is also the analyst's empty +// note to the model); the displays show it in the UI language through +// translateStatusPiece (ui/statusText.js). import test from 'node:test'; import assert from 'node:assert/strict'; -import { setLocale, translateKnown } from '../../i18n/index.js'; +import { setLocale, t, tn, translateKnown } from '../../i18n/index.js'; +import { translateStatusPiece } from '../../ui/statusText.js'; import { createControls } from './controls.js'; function stats(state) { @@ -13,67 +17,115 @@ function stats(state) { }).methods.getStats(); } -for (const locale of ['es', 'ru']) { - test(`${locale}: installation feedback is in the UI language`, () => { - setLocale(locale); - const empty = stats({ status: 'empty', lastUpdate: 1 }).statusMessage; - assert.notEqual(empty, 'No mapped sites in view'); - const found = stats({ +function inLocale(locale, run) { + setLocale(locale); + try { + run(); + } finally { + setLocale('en'); + } +} + +// Each layer state, the English statusMessage it reports, and how the UI +// shows it. A retry a minute out reads "60s" (rounded up). +const cases = [ + [ + { status: 'empty', lastUpdate: 1 }, + 'No mapped sites in view', + () => t('No mapped sites in view'), + ], + [ + { status: 'ready', lastUpdate: 1, records: [{ kind: 'installation' }, { kind: 'installation' }], - }).statusMessage; - assert.notEqual(found, '2 mapped sites in view'); - const tiles = stats({ - status: 'unavailable', - failureReason: 'tiles_unavailable', - }).statusMessage; - assert.notEqual(tiles, 'Map tiles temporarily unavailable'); - const retry = stats({ + }, + '2 mapped sites in view', + () => tn(2, '{count} mapped site in view', '{count} mapped sites in view'), + ], + [ + { + status: 'empty', + lastUpdate: 1, + wide: true, + coverage: { kind: 'subject', radiusM: 25000 }, + }, + 'No mapped sites within 25 km of the contact', + () => t('No mapped sites within {km} km of the contact', { km: '25' }), + ], + [ + { + status: 'ready', + lastUpdate: 1, + wide: true, + coverage: { kind: 'subject', radiusM: 25000 }, + records: [{ kind: 'installation' }], + }, + '1 mapped site within 25 km of the contact', + () => + tn( + 1, + '{count} mapped site within {km} km of the contact', + '{count} mapped sites within {km} km of the contact', + { km: '25' }, + ), + ], + [ + { status: 'unavailable', failureReason: 'tiles_unavailable' }, + 'Map tiles temporarily unavailable', + () => t('Map tiles temporarily unavailable'), + ], + [ + { status: 'unavailable', failureReason: 'names_unavailable', - retryAt: Date.now() + 5000, - }).statusMessage; - assert.doesNotMatch(retry, /^Mapped names temporarily unavailable/); - for (const text of [ - 'Too many mapped sites in view to list them all', - 'Installation context unavailable', - ]) { - assert.notEqual(translateKnown(text), text); - } + get retryAt() { + return Date.now() + 60_000; + }, + }, + 'Mapped names temporarily unavailable — retrying in 60s', + () => + t('{reason} — retrying in {seconds}s', { + reason: t('Mapped names temporarily unavailable'), + seconds: 60, + }), + ], + [ + { status: 'zoom-in' }, + 'Zoom in to search mapped installations', + () => t('Zoom in to search mapped installations'), + ], +]; + +for (const locale of ['es', 'ru']) { + test(`${locale}: installation statusMessage stays English data`, () => { + inLocale(locale, () => { + for (const [state, english] of cases) + assert.equal(stats(state).statusMessage, english); + }); + }); + + test(`${locale}: installation statusMessage is shown in the UI language`, () => { + inLocale(locale, () => { + for (const [state, english, shown] of cases) { + const shownText = translateStatusPiece(stats(state).statusMessage); + assert.notEqual(shownText, english); + assert.equal(shownText, shown()); + } + for (const text of [ + 'Too many mapped sites in view to list them all', + 'Installation context unavailable', + ]) { + assert.notEqual(translateKnown(text), text); + } + }); }); } test('en: installation feedback keeps its English wording', () => { setLocale('en'); - assert.equal( - stats({ status: 'empty', lastUpdate: 1 }).statusMessage, - 'No mapped sites in view', - ); - assert.equal( - stats({ - status: 'ready', - lastUpdate: 1, - records: [{ kind: 'installation' }], - }).statusMessage, - '1 mapped site in view', - ); - assert.equal( - stats({ - status: 'ready', - lastUpdate: 1, - wide: true, - coverage: { kind: 'subject', radiusM: 25000 }, - records: [{ kind: 'installation' }, { kind: 'installation' }], - }).statusMessage, - '2 mapped sites within 25 km of the contact', - ); - assert.equal( - stats({ - status: 'unavailable', - failureReason: 'names_unavailable', - retryAt: Date.now() + 5000, - }).statusMessage, - 'Mapped names temporarily unavailable — retrying in 5s', - ); + for (const [state, english] of cases) { + assert.equal(stats(state).statusMessage, english); + assert.equal(translateStatusPiece(english), english); + } }); From e2651bb0942f96b678faca19a577b01dedf86d76 Mon Sep 17 00:00:00 2001 From: daikaginza Date: Sat, 17 Oct 2026 07:58:56 +0700 Subject: [PATCH 3/6] fix(i18n): build the status piece shapes once and cover one site in view statusPatternText runs on every row render; join the shape lists at module scope instead of on each call. Restore the singular in-view case to the installation feedback locale test. --- .../installations/installationFeedbackLocale.test.mjs | 5 +++++ src/ui/statusText.js | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/layers/installations/installationFeedbackLocale.test.mjs b/src/layers/installations/installationFeedbackLocale.test.mjs index 7dac443510..f85a0b3ae5 100644 --- a/src/layers/installations/installationFeedbackLocale.test.mjs +++ b/src/layers/installations/installationFeedbackLocale.test.mjs @@ -34,6 +34,11 @@ const cases = [ 'No mapped sites in view', () => t('No mapped sites in view'), ], + [ + { status: 'ready', lastUpdate: 1, records: [{ kind: 'installation' }] }, + '1 mapped site in view', + () => tn(1, '{count} mapped site in view', '{count} mapped sites in view'), + ], [ { status: 'ready', diff --git a/src/ui/statusText.js b/src/ui/statusText.js index b241abdbff..12d2025cc6 100644 --- a/src/ui/statusText.js +++ b/src/ui/statusText.js @@ -255,12 +255,12 @@ const MAPPED_SITE_PATTERNS = [ ], ]; +// Every status piece shape, in matching order. +const STATUS_SHAPES = [...STATUS_PIECE_PATTERNS, ...MAPPED_SITE_PATTERNS]; + /** A status piece by its shape in the UI language, or null. */ function statusPatternText(piece) { - for (const [pattern, format] of [ - ...STATUS_PIECE_PATTERNS, - ...MAPPED_SITE_PATTERNS, - ]) { + for (const [pattern, format] of STATUS_SHAPES) { const match = pattern.exec(piece); if (match) return format(match); } From 7d8ad93126589af6c93699547ea2d8a2de188ef1 Mon Sep 17 00:00:00 2001 From: daikaginza Date: Sun, 18 Oct 2026 14:35:07 +0700 Subject: [PATCH 4/6] docs(changelog): add the #1210 entry --- changelog.d/1210-installations-note-english.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog.d/1210-installations-note-english.md diff --git a/changelog.d/1210-installations-note-english.md b/changelog.d/1210-installations-note-english.md new file mode 100644 index 0000000000..e8fccd4add --- /dev/null +++ b/changelog.d/1210-installations-note-english.md @@ -0,0 +1,3 @@ +- Return the Mapped Installations status (site counts, Overpass retries) to the + voice analyst in English; the Layers panel, the nearby-search toast and the + awareness panel translate it where they show it (daikaginza, #1210). From dc13be07c0ae83cd99c1ee0a11dfaa227c723afe Mon Sep 17 00:00:00 2001 From: German Khokhlov Date: Wed, 18 Nov 2026 16:48:59 +0400 Subject: [PATCH 5/6] docs(i18n): tighten the Mapped Installations status comments --- src/data/installationFeedback.js | 3 ++- src/layers/installations/controls.js | 3 +-- .../installations/installationFeedbackLocale.test.mjs | 7 ++----- src/ui/statusText.js | 8 +++----- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/data/installationFeedback.js b/src/data/installationFeedback.js index 4dc1858ddf..cfc1ae6199 100644 --- a/src/data/installationFeedback.js +++ b/src/data/installationFeedback.js @@ -1,6 +1,7 @@ import { msg } from '../i18n/marker.js'; -// installationFeedback() is English data; ui/statusText.js shows it translated. +// installationFeedback() stays English for the analyst. ui/statusText.js and +// ui/shellFeedback.js (HUD) translate it: keep both in step with this wording. const REASONS = Object.freeze({ rate_limited: msg('Overpass rate-limited'), timeout: msg('Overpass timed out'), diff --git a/src/layers/installations/controls.js b/src/layers/installations/controls.js index fe03542055..8c8d729cbe 100644 --- a/src/layers/installations/controls.js +++ b/src/layers/installations/controls.js @@ -259,8 +259,7 @@ export function createControls({ state: layerState, services, parts, source }) { retryAt: layerState.retryAt, retrying: layerState.loading && Boolean(layerState.failureReason), failureReason: layerState.failureReason, - // English data: it is also the analyst's empty note to the model. - // Displays translate it by its shape (ui/statusText.js). + // English: the analyst reads it as is; displays translate it. statusMessage: installationFeedback({ ...layerState, count: layerState.lastUpdate ? mappedCount : undefined, diff --git a/src/layers/installations/installationFeedbackLocale.test.mjs b/src/layers/installations/installationFeedbackLocale.test.mjs index f85a0b3ae5..0591a74eee 100644 --- a/src/layers/installations/installationFeedbackLocale.test.mjs +++ b/src/layers/installations/installationFeedbackLocale.test.mjs @@ -1,6 +1,4 @@ -// getStats().statusMessage is English data (it is also the analyst's empty -// note to the model); the displays show it in the UI language through -// translateStatusPiece (ui/statusText.js). +// statusMessage stays English (the analyst's empty note); displays translate it. import test from 'node:test'; import assert from 'node:assert/strict'; import { setLocale, t, tn, translateKnown } from '../../i18n/index.js'; @@ -26,8 +24,7 @@ function inLocale(locale, run) { } } -// Each layer state, the English statusMessage it reports, and how the UI -// shows it. A retry a minute out reads "60s" (rounded up). +// A retry a minute out reads "60s" (rounded up). const cases = [ [ { status: 'empty', lastUpdate: 1 }, diff --git a/src/ui/statusText.js b/src/ui/statusText.js index 5f4bbf4f2f..8d43ccfbc1 100644 --- a/src/ui/statusText.js +++ b/src/ui/statusText.js @@ -242,10 +242,8 @@ const STATUS_PIECE_PATTERNS = [ ], ]; -// Mapped Installations feedback (installationFeedback in -// data/installationFeedback.js): getStats().statusMessage is English data, and -// the Layers panel, the toast, the awareness panel and the voice card's analyst -// note show it through here. Keep these in step with that helper. +// Shapes of installationFeedback() (data/installationFeedback.js), which stays +// English for the analyst. Keep them in step with its wording. const MAPPED_SITE_PATTERNS = [ [ /^(.+) — retrying in (\d+)s$/, @@ -289,7 +287,7 @@ const MAPPED_SITE_PATTERNS = [ ], ]; -// Every status piece shape, in matching order. +// First match wins. const STATUS_SHAPES = [...STATUS_PIECE_PATTERNS, ...MAPPED_SITE_PATTERNS]; /** A status piece by its shape in the UI language, or null. */ From e4e7b3228944d115f48c0409bdacd4faebd15ce3 Mon Sep 17 00:00:00 2001 From: German Khokhlov Date: Wed, 18 Nov 2026 16:52:52 +0400 Subject: [PATCH 6/6] refactor(i18n): show the installations status through translateStatusMessage --- src/data/installationFeedback.js | 2 +- src/layers/awareness/panel.js | 11 +++-------- .../installationFeedbackLocale.test.mjs | 14 ++++---------- src/ui/contextBindings.js | 4 ++-- src/ui/statusText.js | 2 +- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/data/installationFeedback.js b/src/data/installationFeedback.js index cfc1ae6199..7209ded520 100644 --- a/src/data/installationFeedback.js +++ b/src/data/installationFeedback.js @@ -20,7 +20,7 @@ const FALLBACK_REASON = msg('Overpass temporarily unavailable'); * @param {number} [now] * @returns {{text: string, reason?: string, seconds?: number}|{count: number, km: ?number}} */ -export function describeInstallationFeedback(stats = {}, now = Date.now()) { +function describeInstallationFeedback(stats = {}, now = Date.now()) { const reason = REASONS[stats.failureReason] || FALLBACK_REASON; if (stats.loading) return { diff --git a/src/layers/awareness/panel.js b/src/layers/awareness/panel.js index bf14e86b2e..33f206e225 100644 --- a/src/layers/awareness/panel.js +++ b/src/layers/awareness/panel.js @@ -2,14 +2,9 @@ import { formatAwarenessLabel, AWARENESS_RADIUS_M, } from '../../data/militaryAwarenessEngine.js'; -import { - formatNumber, - onLocaleChange, - t, - translateKnown, -} from '../../i18n/index.js'; +import { formatNumber, onLocaleChange, t } from '../../i18n/index.js'; import { sourceStatusLabel } from '../../ui/layerNames.js'; -import { translateStatusPiece } from '../../ui/statusText.js'; +import { translateStatusMessage } from '../../ui/statusText.js'; import { formatQuantity } from '../../ui/unitLabels.js'; import { AWARENESS_PAGE_SIZE, AWARENESS_PAGE_ROTATE_MS } from './policy.js'; import { distanceParts } from '../../data/distanceFormat.js'; @@ -46,7 +41,7 @@ export function presentAwarenessDistance(meters) { function presentAwarenessReason(summary = {}) { return summary.reasonTemplate ? t(summary.reasonTemplate, summary.reasonValues) - : translateStatusPiece(summary.reason || ''); + : translateStatusMessage(summary.reason || ''); } /** diff --git a/src/layers/installations/installationFeedbackLocale.test.mjs b/src/layers/installations/installationFeedbackLocale.test.mjs index 0591a74eee..c74c0ee477 100644 --- a/src/layers/installations/installationFeedbackLocale.test.mjs +++ b/src/layers/installations/installationFeedbackLocale.test.mjs @@ -1,8 +1,8 @@ // statusMessage stays English (the analyst's empty note); displays translate it. import test from 'node:test'; import assert from 'node:assert/strict'; -import { setLocale, t, tn, translateKnown } from '../../i18n/index.js'; -import { translateStatusPiece } from '../../ui/statusText.js'; +import { setLocale, t, tn } from '../../i18n/index.js'; +import { translateStatusMessage } from '../../ui/statusText.js'; import { createControls } from './controls.js'; function stats(state) { @@ -110,16 +110,10 @@ for (const locale of ['es', 'ru']) { test(`${locale}: installation statusMessage is shown in the UI language`, () => { inLocale(locale, () => { for (const [state, english, shown] of cases) { - const shownText = translateStatusPiece(stats(state).statusMessage); + const shownText = translateStatusMessage(stats(state).statusMessage); assert.notEqual(shownText, english); assert.equal(shownText, shown()); } - for (const text of [ - 'Too many mapped sites in view to list them all', - 'Installation context unavailable', - ]) { - assert.notEqual(translateKnown(text), text); - } }); }); } @@ -128,6 +122,6 @@ test('en: installation feedback keeps its English wording', () => { setLocale('en'); for (const [state, english] of cases) { assert.equal(stats(state).statusMessage, english); - assert.equal(translateStatusPiece(english), english); + assert.equal(translateStatusMessage(english), english); } }); diff --git a/src/ui/contextBindings.js b/src/ui/contextBindings.js index e786a8e3c6..c4e3a46155 100644 --- a/src/ui/contextBindings.js +++ b/src/ui/contextBindings.js @@ -1,6 +1,6 @@ import { t } from '../i18n/index.js'; import { spaceMissionsIndexFailure } from './contextActions.js'; -import { translateStatusPiece } from './statusText.js'; +import { translateStatusMessage } from './statusText.js'; import { shouldExpandGlobalContextPanel } from '../rightRailPolicy.js'; export function _initGlobalContextPanel() { @@ -113,7 +113,7 @@ export function _initGlobalContextPanel() { if (this.destroyed || searched === false) return false; const stats = this.installations.getStats?.(); this.showToast( - (stats?.statusMessage && translateStatusPiece(stats.statusMessage)) || + (stats?.statusMessage && translateStatusMessage(stats.statusMessage)) || (stats?.status === 'zoom-in' ? t('Zoom in to search mapped installations') : t('Nearby installations refreshed')), diff --git a/src/ui/statusText.js b/src/ui/statusText.js index 8d43ccfbc1..7d1c5cf988 100644 --- a/src/ui/statusText.js +++ b/src/ui/statusText.js @@ -300,7 +300,7 @@ function statusPatternText(piece) { } /** One piece of a status line in the UI language, or as it came. */ -export function translateStatusPiece(piece) { +function translateStatusPiece(piece) { const known = translateKnown(piece); if (known !== piece) return known; return statusPatternText(piece) ?? piece;