From e2651bb0942f96b678faca19a577b01dedf86d76 Mon Sep 17 00:00:00 2001 From: daikaginza Date: Sat, 17 Oct 2026 07:58:56 +0700 Subject: [PATCH] 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); }