Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

fix(awareness): keep cohort reasons English in data

daikaginzae82f6d5c9c23
diff --git a/src/data/militaryAwarenessEngine.js b/src/data/militaryAwarenessEngine.js
index 0f889d53f..5f359b757 100644
--- a/src/data/militaryAwarenessEngine.js
+++ b/src/data/militaryAwarenessEngine.js
@@ -1,6 +1,6 @@
/** Pure proximity helpers for Global Context. No capability modeling. */
-import { t } from '../i18n/index.js';
+import { msg, t } from '../i18n/index.js';
import { UNNAMED_PLACE_NAMES } from './installationNames.js';
const UNNAMED_NAMES = new Set(UNNAMED_PLACE_NAMES);
@@ -84,7 +84,8 @@ export function formatAwarenessLabel(value) {
/**
* Summarize sorted nearby results without promoting missing/stale feeds to a
* negative finding. `UNKNOWN` is an input-data state, never an out-of-range
- * claim in this MVP.
+ * claim in this MVP. `reason` is English data; the awareness panel shows it
+ * in the UI language.
*/
export function summarizeAwarenessCohort(
items,
@@ -95,14 +96,14 @@ export function summarizeAwarenessCohort(
relationship: AWARENESS_RELATIONSHIP.UNKNOWN,
count: null,
nearest: [],
- reason: t('feed unavailable'),
+ reason: msg('feed unavailable'),
};
if (stale)
return {
relationship: AWARENESS_RELATIONSHIP.UNKNOWN,
count: null,
nearest: [],
- reason: t('feed stale'),
+ reason: msg('feed stale'),
};
const normalized = (Array.isArray(items) ? items : [])
.filter(
@@ -119,8 +120,8 @@ export function summarizeAwarenessCohort(
count: normalized.length,
nearest: normalized.slice(0, limit),
reason: normalized.length
- ? t('observed or mapped nearby context')
- : t('no observed or mapped objects in current feeds'),
+ ? msg('observed or mapped nearby context')
+ : msg('no observed or mapped objects in current feeds'),
};
}
diff --git a/src/data/militaryAwarenessEngine.test.mjs b/src/data/militaryAwarenessEngine.test.mjs
index 3415fd5d7..8b8771f14 100644
--- a/src/data/militaryAwarenessEngine.test.mjs
+++ b/src/data/militaryAwarenessEngine.test.mjs
@@ -1,5 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
+import { setLocale, translateKnown } from '../i18n/index.js';
import {
AWARENESS_RELATIONSHIP,
findByDoublingRadius,
@@ -47,6 +48,25 @@ test('unavailable and stale feeds remain unknown', () => {
assert.equal(summarizeAwarenessCohort([], { stale: true }).reason, 'feed stale');
});
+test('cohort reasons stay English in data and translate where the panel shows them', (t) => {
+ t.after(() => setLocale('en'));
+ setLocale('ru');
+ const reasons = [
+ summarizeAwarenessCohort([], { available: false }).reason,
+ summarizeAwarenessCohort([], { stale: true }).reason,
+ summarizeAwarenessCohort([{ id: 'near', distanceM: 10 }]).reason,
+ summarizeAwarenessCohort([]).reason,
+ ];
+ assert.deepEqual(reasons, [
+ 'feed unavailable',
+ 'feed stale',
+ 'observed or mapped nearby context',
+ 'no observed or mapped objects in current feeds',
+ ]);
+ // The awareness panel shows a reason through translateKnown().
+ for (const reason of reasons) assert.notEqual(translateKnown(reason), reason);
+});
+
test('navigation prioritizes nearby targets from the selected cohort', () => {
const cohorts = [
{ id: 'flights', summary: { nearest: [{ icao24: 'a1', distanceM: 1000 }, { icao24: 'a2', distanceM: 2000 }] } },