<#1038 Add pt/ca/it languages and locale-aware for...
# osctrl
g
#1038 Add pt/ca/it languages and locale-aware formatting Pull request opened by javuto Add pt/ca/it languages and locale-aware formatting (i18n phase 2) Problem Phase 1 established the i18n infrastructure with en/es/fr/de, but time formatting, chart axes/tooltips, and shared data components were still hardcoded to
en-US
or plain English strings. Change • New languages: Portuguese (pt-BR), Catalan (ca-ES), Italian (it-IT) added to the registry and selector — 7 languages total, each with a full catalog mirroring every English key. • Locale-aware time formatting (
lib/time.ts
): compact units and phrases in `formatRelative`/`formatTimeUntil`/`formatBucketAgo` now translate per language ("in 3d" → "en 3d" / "dans 3j" / "tra 3g"); the >7-day date fallback uses the active locale tag instead of hardcoded
en-US
. • Locale-aware charts (
chart-formatters.ts
): the module-level
en-US
formatter constants became per-language cached functions (
shortDateFmt()
,
weekdayDateFmt()
,
hmsTimeFmt()
,
intFmt()
); all four consumers (x-axis, chart shell, tooltips) updated. • Translated shared components:
Pagination
(empty state, range, prev/next),
SearchInput
(label, placeholder, clear button), and
StatCard
(numbers via
useLocale
formatters). • Fix: switched all catalogs to ICU
{var}
syntax —
i18next-icu
does not interpolate
{{var}}
, so existing placeholders like the user-menu aria label were rendering literally. Performance • Non-English catalogs remain lazy chunks (~1.7–1.8 KB gz each, 6 total); formatter objects are cached per (locale, preset) so charts with thousands of ticks never rebuild
Intl
objects. • Main bundle grew ~0.7 KB gz. Validation •
npm run check
— clean •
npm test
— 355 passed (new: 7-language catalog parity, pt/ca/it matching, translated time strings, locale date formatting) •
npm run build
— all 7 language chunks emitted correctly Follow-ups • Translate feature pages (dashboard, nodes, queries, carves, settings…) • Migrate remaining
toLocaleString()
calls in feature pages to
useLocale
• Optional: backend
PreferredLanguage
for cross-device sync jmpsec/osctrl