mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
i18n: fix review findings and polish ru/es strings
Fixes the 51 P0–P2 findings from the full review of the i18n branch and the issues found while checking every new string on screen in ru and es. - Translate errors and statuses that still reached ru/es in English: feed and tile errors, provider statuses, the ALPR chip, the traffic mode chip, voice plan step labels, fire feed values, receiver bands, scene save reasons and the Cesium attribution link. - Show preset city names in the UI language (src/ui/placeNames.js); data and everything sent to the model stay English. - Share layer names between the layer panel, HUD and voice card (src/ui/layerNames.js). - Keep long ru/es strings whole: voice card error lines, analyst titles, the voice tier status, the Nepal evidence button, the ALPR retry chip. English layout is unchanged. - Ask before a language switch drops unsaved work. - Catalog fixes: glossary terms (пуск, пресет), gender agreement and consistent "peticiones" in es, fewer calques in both languages. - Fix English text that was itself wrong (e.g. "Exit cockpit to fly to a weather", raw tool ids in voice plan steps). Catalogs: es/ru 2535 messages each, complete. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
8029747b7e
commit
00704ddc89
212 files changed
+9871
-909
No files matched your search
@@ -0,0 +1,150 @@
|
||||
// K-37 / K-29: the selected-fire card of Fire Perimeters and its accessible
|
||||
// label follow the UI language, like the legend of the same layer
|
||||
// (perimeters/index.js). cards.test.mjs pins the English card.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { setLocale, t } from '../../i18n/index.js';
|
||||
import { buildIncidentCard } from './cards.js';
|
||||
|
||||
const now = Date.UTC(2026, 9, 14);
|
||||
const row = {
|
||||
stableId: 'x',
|
||||
name: 'Lake',
|
||||
acres: 1200,
|
||||
containedPct: 40,
|
||||
state: 'CA',
|
||||
discoveredTime: now - 2 * 3600e3,
|
||||
updatedTime: now - 3600e3,
|
||||
cause: 'Human',
|
||||
behavior: 'Moderate',
|
||||
complexity: 'Type 3 Incident',
|
||||
personnel: 1500,
|
||||
county: 'Plumas',
|
||||
costToDate: 4200000,
|
||||
complexName: 'NORTH COMPLEX',
|
||||
};
|
||||
|
||||
test('en: the fire card keeps its English wording', () => {
|
||||
setLocale('en');
|
||||
const card = buildIncidentCard(row, now, { link: 'https://inciweb.example' });
|
||||
assert.equal(card.title, 'FIRE · Lake');
|
||||
assert.deepEqual(card.details, [
|
||||
'1,200 ac · 40% contained · CA',
|
||||
'part of North Complex',
|
||||
'Human cause · Moderate · Type 3 Incident',
|
||||
'1,500 personnel · Plumas County · $4.2M to date',
|
||||
'discovered 2h ago · updated 1h ago',
|
||||
'InciWeb ↗ · click card to open',
|
||||
]);
|
||||
assert.equal(card.accessibilityLabel, 'Open FIRE · Lake on InciWeb');
|
||||
});
|
||||
|
||||
for (const locale of ['es', 'ru']) {
|
||||
test(`${locale}: selected fire card follows the UI language`, () => {
|
||||
setLocale(locale);
|
||||
try {
|
||||
assert.notEqual(
|
||||
t('Fully contained'),
|
||||
'Fully contained',
|
||||
'legend is translated',
|
||||
);
|
||||
const card = buildIncidentCard(row, now, {
|
||||
link: 'https://inciweb.example',
|
||||
});
|
||||
const text = [card.title, ...card.details, card.accessibilityLabel].join(
|
||||
' | ',
|
||||
);
|
||||
for (const english of [
|
||||
'FIRE',
|
||||
' ac ',
|
||||
'contained',
|
||||
'discovered',
|
||||
'updated',
|
||||
'part of',
|
||||
'cause',
|
||||
'personnel',
|
||||
'County',
|
||||
'to date',
|
||||
'click card to open',
|
||||
'Open ',
|
||||
])
|
||||
assert.ok(
|
||||
!text.includes(english),
|
||||
`${locale}: English "${english}" in ${text}`,
|
||||
);
|
||||
assert.ok(
|
||||
!text.includes('1,200'),
|
||||
`${locale}: en-US grouping in ${text}`,
|
||||
);
|
||||
} finally {
|
||||
setLocale('en');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// C5 / C11 / E7: known WFIGS values, the cost and the unnamed title follow the
|
||||
// UI language; the row keeps the feed's English for the AI tools.
|
||||
const expected = {
|
||||
es: {
|
||||
situation: 'causa: humana · actividad moderada · incidente de tipo 3',
|
||||
cost: '4,2 M$ hasta la fecha',
|
||||
unnamed: 'INCENDIO · Sin nombre',
|
||||
},
|
||||
ru: {
|
||||
situation:
|
||||
'причина: деятельность человека · умеренная активность · инцидент 3-го типа',
|
||||
cost: '4,2 млн $ на сегодня',
|
||||
unnamed: 'ПОЖАР · Без названия',
|
||||
},
|
||||
};
|
||||
|
||||
for (const [locale, want] of Object.entries(expected)) {
|
||||
test(`${locale}: feed values, cost and unnamed title are localized`, () => {
|
||||
setLocale(locale);
|
||||
try {
|
||||
const card = buildIncidentCard(row, now);
|
||||
assert.equal(card.details[2], want.situation);
|
||||
assert.ok(
|
||||
card.details[3].endsWith(want.cost),
|
||||
`${locale}: ${card.details[3]}`,
|
||||
);
|
||||
assert.equal(
|
||||
buildIncidentCard({ ...row, name: '' }, now).title,
|
||||
want.unnamed,
|
||||
);
|
||||
assert.equal(row.cause, 'Human', 'the row keeps the feed value');
|
||||
} finally {
|
||||
setLocale('en');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
test('unknown WFIGS values are shown as sent', () => {
|
||||
setLocale('ru');
|
||||
try {
|
||||
const card = buildIncidentCard(
|
||||
{
|
||||
...row,
|
||||
cause: 'Investigated',
|
||||
behavior: 'Smoldering',
|
||||
complexity: 'Complex Incident',
|
||||
},
|
||||
now,
|
||||
);
|
||||
assert.equal(
|
||||
card.details[2],
|
||||
'причина: Investigated · Smoldering · Complex Incident',
|
||||
);
|
||||
} finally {
|
||||
setLocale('en');
|
||||
}
|
||||
});
|
||||
|
||||
test('en: compact costs keep the dollar prefix', () => {
|
||||
setLocale('en');
|
||||
const cost = (costToDate) =>
|
||||
buildIncidentCard({ ...row, costToDate }, now).details[3].split(' · ')[2];
|
||||
assert.equal(cost(85_000), '$85K to date');
|
||||
assert.equal(cost(999_600), '$1M to date');
|
||||
assert.equal(cost(1_300_000_000), '$1.3B to date');
|
||||
});
|
||||
+102
-30
@@ -1,4 +1,5 @@
|
||||
/** Card model for one selected fire-perimeter incident. Pure — no Cesium types. */
|
||||
import { formatNumber, t, tn } from '../../i18n/index.js';
|
||||
|
||||
export const PERIMETER_OVERLAY_SOURCE_ID = 'fire-perimeters';
|
||||
|
||||
@@ -50,25 +51,70 @@ export function perimeterAnchorDegrees(polygons) {
|
||||
return { lon: lon / count, lat: lat / count };
|
||||
}
|
||||
|
||||
/** Compact USD, e.g. $85K / $4.2M / $1.3B. Null under $1,000. */
|
||||
/**
|
||||
* Compact USD in the UI language: en "$85K / $4.2M / $1.3B", ru "4,2 млн $",
|
||||
* es "4,2 M$". Null under $1,000.
|
||||
*/
|
||||
function formatCost(dollars) {
|
||||
if (!Number.isFinite(dollars) || dollars < 1000) return null;
|
||||
const units = [
|
||||
[1e3, 'K'],
|
||||
[1e6, 'M'],
|
||||
[1e9, 'B'],
|
||||
];
|
||||
const units = [1e3, 1e6, 1e9];
|
||||
let index = 0;
|
||||
for (let i = units.length - 1; i >= 0; i--) {
|
||||
if (dollars >= units[i][0]) {
|
||||
if (dollars >= units[i]) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 999,500 must promote to $1M, never render as $1000K.
|
||||
if (dollars >= units[index][0] * 999.5 && index < units.length - 1) index++;
|
||||
const value = dollars / units[index][0];
|
||||
return `$${value >= 10 ? Math.round(value) : Math.round(value * 10) / 10}${units[index][1]}`;
|
||||
if (dollars >= units[index] * 999.5 && index < units.length - 1) index++;
|
||||
const value = dollars / units[index];
|
||||
const amount = formatNumber(
|
||||
value >= 10 ? Math.round(value) : Math.round(value * 10) / 10,
|
||||
);
|
||||
if (index === 0) return t('${amount}K', { amount });
|
||||
if (index === 1) return t('${amount}M', { amount });
|
||||
return t('${amount}B', { amount });
|
||||
}
|
||||
|
||||
/** WFIGS attr_FireCause values in the UI language; others as sent. */
|
||||
function causeLabel(cause) {
|
||||
switch (cause) {
|
||||
case 'Human':
|
||||
return t('Human', { context: 'fire cause' });
|
||||
case 'Natural':
|
||||
return t('Natural', { context: 'fire cause' });
|
||||
case 'Undetermined':
|
||||
return t('Undetermined', { context: 'fire cause' });
|
||||
case 'Unknown':
|
||||
return t('Unknown', { context: 'fire cause' });
|
||||
default:
|
||||
return cause;
|
||||
}
|
||||
}
|
||||
|
||||
/** WFIGS attr_FireBehaviorGeneral values in the UI language; others as sent. */
|
||||
function behaviorLabel(behavior) {
|
||||
switch (behavior) {
|
||||
case 'Minimal':
|
||||
return t('Minimal', { context: 'fire behavior' });
|
||||
case 'Moderate':
|
||||
return t('Moderate', { context: 'fire behavior' });
|
||||
case 'Active':
|
||||
return t('Active', { context: 'fire behavior' });
|
||||
case 'Extreme':
|
||||
return t('Extreme', { context: 'fire behavior' });
|
||||
default:
|
||||
return behavior;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WFIGS attr_IncidentComplexityLevel ("Type 1 Incident" … "Type 5 Incident")
|
||||
* in the UI language; other values as sent.
|
||||
*/
|
||||
function complexityLabel(complexity) {
|
||||
const match = /^Type ([1-5]) Incident$/.exec(complexity);
|
||||
return match ? t('Type {level} Incident', { level: match[1] }) : complexity;
|
||||
}
|
||||
|
||||
/** WFIGS complex names arrive ALL-CAPS; render them in title case. */
|
||||
@@ -78,12 +124,17 @@ function titleCase(name) {
|
||||
.replace(/\b[a-z]/g, (letter) => letter.toUpperCase());
|
||||
}
|
||||
|
||||
/** Compact age, "5m" / "3h" / "2d", in the UI language ("3 h", "3 ч"). */
|
||||
function formatAge(deltaMs) {
|
||||
if (!Number.isFinite(deltaMs) || deltaMs < 0) return null;
|
||||
const hours = Math.floor(deltaMs / 3600000);
|
||||
if (hours < 1) return `${Math.max(1, Math.floor(deltaMs / 60000))}m`;
|
||||
if (hours < 24) return `${hours}h`;
|
||||
return `${Math.floor(hours / 24)}d`;
|
||||
if (hours < 1)
|
||||
return t('{count}m', {
|
||||
context: 'age',
|
||||
count: Math.max(1, Math.floor(deltaMs / 60000)),
|
||||
});
|
||||
if (hours < 24) return t('{count}h', { context: 'age', count: hours });
|
||||
return t('{count}d', { context: 'age', count: Math.floor(hours / 24) });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,48 +146,67 @@ function formatAge(deltaMs) {
|
||||
* @returns {Object} World-overlay entry without `position`.
|
||||
*/
|
||||
export function buildIncidentCard(row, nowMs, { link = null } = {}) {
|
||||
// Feed values stay as WFIGS sends them in the row (and in what the AI tools
|
||||
// read); the card translates the known cause, behavior and complexity values
|
||||
// and the wording around them. State, category, county and complex names
|
||||
// are shown as sent.
|
||||
const facts = [];
|
||||
if (Number.isFinite(row.acres))
|
||||
facts.push(`${Math.round(row.acres).toLocaleString('en-US')} ac`);
|
||||
if (Number.isFinite(row.acres)) {
|
||||
const acres = Math.round(row.acres);
|
||||
facts.push(
|
||||
tn(acres, '{acres} ac', '{acres} ac', { acres: formatNumber(acres) }),
|
||||
);
|
||||
}
|
||||
facts.push(
|
||||
Number.isFinite(row.containedPct)
|
||||
? `${Math.round(row.containedPct)}% contained`
|
||||
: 'containment unknown',
|
||||
? t('{percent}% contained', { percent: Math.round(row.containedPct) })
|
||||
: t('containment unknown'),
|
||||
);
|
||||
if (row.state) facts.push(row.state);
|
||||
else if (row.category) facts.push(row.category);
|
||||
|
||||
const situation = [];
|
||||
if (row.cause) situation.push(`${row.cause} cause`);
|
||||
if (row.behavior) situation.push(row.behavior);
|
||||
if (row.complexity) situation.push(row.complexity);
|
||||
if (row.cause)
|
||||
situation.push(t('{cause} cause', { cause: causeLabel(row.cause) }));
|
||||
if (row.behavior) situation.push(behaviorLabel(row.behavior));
|
||||
if (row.complexity) situation.push(complexityLabel(row.complexity));
|
||||
|
||||
const response = [];
|
||||
if (Number.isFinite(row.personnel))
|
||||
if (Number.isFinite(row.personnel)) {
|
||||
const personnel = Math.round(row.personnel);
|
||||
response.push(
|
||||
`${Math.round(row.personnel).toLocaleString('en-US')} personnel`,
|
||||
tn(personnel, '{personnel} personnel', '{personnel} personnel', {
|
||||
personnel: formatNumber(personnel),
|
||||
}),
|
||||
);
|
||||
if (row.county) response.push(`${row.county} County`);
|
||||
}
|
||||
if (row.county) response.push(t('{county} County', { county: row.county }));
|
||||
if (Number.isFinite(row.costToDate)) {
|
||||
const cost = formatCost(row.costToDate);
|
||||
if (cost) response.push(`${cost} to date`);
|
||||
if (cost) response.push(t('{cost} to date', { cost }));
|
||||
}
|
||||
|
||||
const ages = [];
|
||||
const discovered = formatAge(nowMs - row.discoveredTime);
|
||||
if (row.discoveredTime != null && discovered)
|
||||
ages.push(`discovered ${discovered} ago`);
|
||||
ages.push(t('discovered {age} ago', { age: discovered }));
|
||||
const updated = formatAge(nowMs - row.updatedTime);
|
||||
if (row.updatedTime != null && updated) ages.push(`updated ${updated} ago`);
|
||||
if (row.updatedTime != null && updated)
|
||||
ages.push(t('updated {age} ago', { age: updated }));
|
||||
|
||||
const details = [facts.join(' · ')];
|
||||
if (row.complexName) details.push(`part of ${titleCase(row.complexName)}`);
|
||||
if (row.complexName)
|
||||
details.push(
|
||||
t('part of {complex}', { complex: titleCase(row.complexName) }),
|
||||
);
|
||||
if (situation.length) details.push(situation.join(' · '));
|
||||
if (response.length) details.push(response.join(' · '));
|
||||
if (ages.length) details.push(ages.join(' · '));
|
||||
if (link) details.push('InciWeb ↗ · click card to open');
|
||||
if (link) details.push(t('InciWeb ↗ · click card to open'));
|
||||
|
||||
const title = `FIRE · ${row.name || 'Unnamed incident'}`;
|
||||
const title = t('FIRE · {name}', {
|
||||
name: row.name || t('Unnamed incident'),
|
||||
});
|
||||
return {
|
||||
id: `fire-perimeter-card:${row.stableId}`,
|
||||
// `selected` picks the paint lane and collision protection; an explicit
|
||||
@@ -145,7 +215,9 @@ export function buildIncidentCard(row, nowMs, { link = null } = {}) {
|
||||
// Only a linked card is clickable — the overlay host registers hit
|
||||
// rectangles solely for interactive entries.
|
||||
interactive: Boolean(link),
|
||||
...(link ? { accessibilityLabel: `Open ${title} on InciWeb` } : undefined),
|
||||
...(link
|
||||
? { accessibilityLabel: t('Open {title} on InciWeb', { title }) }
|
||||
: undefined),
|
||||
title,
|
||||
details,
|
||||
accent: containmentAccent(row.containedPct),
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
inciwebNodeId,
|
||||
isCurrentPublication,
|
||||
} from './inciweb.js';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { msg, t } from '../../i18n/index.js';
|
||||
export { normalizeFirePerimeterSnapshot } from './records.js';
|
||||
export { createWfigsPerimeterSource } from './source.js';
|
||||
export * from './cards.js';
|
||||
@@ -365,7 +365,7 @@ export function createFirePerimetersLayer({
|
||||
if (request.signal.aborted || _request !== request || !_enabled)
|
||||
return false;
|
||||
console.warn('[Data:FirePerimeters] Fetch error:', e);
|
||||
_lastError = e?.message || 'Perimeter source unavailable';
|
||||
_lastError = e?.message || msg('Perimeter source unavailable');
|
||||
return false;
|
||||
} finally {
|
||||
if (_request === request) _request = null;
|
||||
|
||||
Reference in new issue
Block a user