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.
This commit is contained in:
daikaginza committed 2026-10-17 07:58:56 +07:00
1 parent 4515c5146a
commit e2651bb094
2 files changed
+9 -4

No files matched your search

@@ -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',
+4 -4
View File
@@ -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);
}