diff --git a/plugin-designs/my-upg-100-list/data/legend-tree.js b/plugin-designs/my-upg-100-list/data/legend-tree.js index c0cd33ef8..54bf1e97b 100644 --- a/plugin-designs/my-upg-100-list/data/legend-tree.js +++ b/plugin-designs/my-upg-100-list/data/legend-tree.js @@ -85,6 +85,16 @@ function leafPopulation(row, records) { export function buildLegendNodes(clusters, opts = {}) { const deafCount = opts.deafCount ?? 123; const records = Array.isArray(opts.records) ? opts.records : null; + // ★ OPTIONAL GENERATED TITLE (Driver, 2026-09-27). `opts.title(zone)` returns a localized title + // composed from already-translated parts, or NULL for a zone whose title cannot be generated — see + // data/zone-title.js. Passing nothing keeps every hand-written English label exactly as it was, which + // is why this is an option rather than a rewrite: the legend, the poster and the packet adopt it + // independently, and a caller that has no records yet (records:null) still builds a correct tree. + // ⚠ NULL MEANS "KEEP YOURS", NOT "NO TITLE". 18 of 28 zones decline (their labels are sub-national or + // taxonomic, and Intl has no subdivisions), so the fallback is the normal path, not the error path. + const titleOf = typeof opts.title === 'function' + ? (zone, fallback) => opts.title(zone) || fallback + : (_zone, fallback) => fallback; const lists = clusters.lists || []; const asia = clusters.asia_lists || []; // slice 09b-6 §1(a): wire the 7 uncovered "Frontier Asia" zones (Nepal, @@ -137,7 +147,7 @@ export function buildLegendNodes(clusters, opts = {}) { { id: l.id, zoneKey: l.id, - label: l.label, + label: titleOf(l, l.label), // Carry the province enumeration the region-name label replaced. ...(l.provinceLabel ? { provinceLabel: l.provinceLabel } : {}), color: colorOf(l.id), @@ -171,7 +181,7 @@ export function buildLegendNodes(clusters, opts = {}) { { id: r.id, zoneKey: r.id, - label: r.label, + label: titleOf(r, r.label), // The province enumeration the region-name label replaced. Carried through // like adm0/provinces above — a node rebuilt field-by-field silently drops // anything not named, which is exactly how adm0 and population were lost. @@ -228,7 +238,7 @@ export function buildLegendNodes(clusters, opts = {}) { { id: u.id, zoneKey: u.id, - label: u.label, + label: titleOf(u, u.label), // Carry the province enumeration the region-name label replaced. ...(u.provinceLabel ? { provinceLabel: u.provinceLabel } : {}), color: colorOf(u.id),