mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
refactor(i18n): show the installations status through translateStatusMessage
This commit is contained in:
1 parent
dc13be07c0
commit
e4e7b32289
5 files changed
+11
-22
No files matched your search
@@ -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 || '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user