From 59451e6a767f3d8a3c2ea0d4a322fa2c52c6ad2d Mon Sep 17 00:00:00 2001 From: German Khokhlov Date: Wed, 14 Oct 2026 19:10:40 +0400 Subject: [PATCH] fix(i18n): selected fire card power and coordinates in the UI language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The selected fire card read "4.9 MW" and "8.389°S 44.162°W" in every language; it now uses the locale's decimal separator and hemisphere words ("4,9 МВт", "8,389° ю. ш."). The data labels stay as they were. Co-Authored-By: Claude Opus 5.5 --- src/layers/firms/model.js | 41 ++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/layers/firms/model.js b/src/layers/firms/model.js index 0e721f198..3a1df327b 100644 --- a/src/layers/firms/model.js +++ b/src/layers/firms/model.js @@ -1,5 +1,5 @@ import * as Cesium from 'cesium'; -import { t } from '../../i18n/index.js'; +import { formatNumber, t } from '../../i18n/index.js'; import { satelliteShortName, fireDetectionKey, @@ -351,10 +351,10 @@ export function createModel({ cullPosition: fireCullPosition(fire), gapPx: frpPixelSize(fire.frp), accent: accentForSeverity(detectionColorStop(fire).name), - title: t('FIRE · {frp} MW', { frp: formatFrp(fire.frp) }), + title: t('FIRE · {frp} MW', { frp: formatFrpLabel(fire.frp) }), details: [ meta.join(' · '), - formatLatLon(fire.lat, fire.lon) + + formatLatLonLabel(fire.lat, fire.lon) + (fire.night ? ` · ${t('NIGHT')}` : ''), ], selected: true, @@ -388,7 +388,7 @@ export function createModel({ cullPosition: candidate.cullPosition || candidate.position, gapPx: frpPixelSize(fire.frp), accent: accentForSeverity(detectionColorStop(fire).name), - title: t('▲ {frp} MW', { frp: formatFrp(fire.frp) }), + title: t('▲ {frp} MW', { frp: formatFrpLabel(fire.frp) }), details: [meta.join(' · ')], selected: false, priority: Number(fire.frp) || 0, @@ -407,7 +407,7 @@ export function createModel({ function buildCellCard(candidate, nowMs) { const cell = candidate.cell; const noun = cell.count === 1 ? t('FIRE') : t('FIRES'); - const parts = [t('max {value} MW', { value: formatFrp(cell.maxFrp) })]; + const parts = [t('max {value} MW', { value: formatFrpLabel(cell.maxFrp) })]; if (cell.newestAcqMs > 0) { const age = formatAgeLabel(nowMs - cell.newestAcqMs); if (age) parts.push(t('new {value}', { value: age })); @@ -483,6 +483,37 @@ export function createModel({ return frp >= 10 ? frp.toFixed(0) : frp.toFixed(1); } + /** formatFrp for a card, with the locale's decimal separator ("4,9"). */ + + function formatFrpLabel(frp) { + const digits = frp >= 10 ? 0 : 1; + return formatNumber(frp, { + minimumFractionDigits: digits, + maximumFractionDigits: digits, + useGrouping: false, + }); + } + + /** formatLatLon for a card: "8,389° ю. ш. 44,162° з. д." in Russian. */ + + function formatLatLonLabel(lat, lon) { + const amount = (value) => + formatNumber(Math.abs(value), { + minimumFractionDigits: 3, + maximumFractionDigits: 3, + useGrouping: false, + }); + const latPart = + lat >= 0 + ? t('{value}°N', { value: amount(lat) }) + : t('{value}°S', { value: amount(lat) }); + const lonPart = + lon >= 0 + ? t('{value}°E', { value: amount(lon) }) + : t('{value}°W', { value: amount(lon) }); + return `${latPart} ${lonPart}`; + } + /** Millisecond delta → "<1h" / "Xh" / "Xd", or '' for invalid input. */ function formatAge(deltaMs) {