i18n: localize per-metric status labels (Poor/Elevated/…) across all locales#37
Open
mzspicoli wants to merge 1 commit into
Open
i18n: localize per-metric status labels (Poor/Elevated/…) across all locales#37mzspicoli wants to merge 1 commit into
mzspicoli wants to merge 1 commit into
Conversation
The per-metric status badge (the "Poor" / "Elevated" chip inside each CO₂, PM2.5, humidity, etc. card) was rendered in English regardless of the configured language because METRIC_DEFS held the display strings directly. Only the overall header badge went through the translation layer, leaving non-English users with mixed-language cards. Replace `labels` with `labelKeys` in METRIC_DEFS — these are now keys into TRANSLATIONS[<lang>].status — and have _getMetricStatus resolve them through _t(). Add the previously-untranslated status keys (safe, low, high, elevated, clean, too_dry, dry, comfortable, humid, too_humid, cold, cool, warm, hot) to every locale (en/es/fr/de/pt). Test coverage in test.js verifies CO₂, PM2.5, humidity, and temperature badges translate correctly across locales. Bumps CARD_VERSION to 2.9.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First — thanks again for merging PR #33 (the Portuguese translation)! It's working great. While using it I noticed one remaining spot that didn't pick up the translation: the small status pill inside each metric card (CO₂, PM2.5, humidity, temperature, …) was always rendering "Poor" / "Elevated" / "Warm" / etc. in English regardless of the configured language. I reproduced the same thing with
esandde, so it's not pt-specific.Here's the bug with
language: pt— header badge says "Ruim" (translated) but the per-metric pills still say "Poor":Root cause:
METRIC_DEFS.labelsheld English display strings, and_getMetricStatus()returned them verbatim — the only place that bypassed the_t('status', …)lookup that_getOverallStatus()already uses for the header badge.Fix: smallest viable patch that reuses the existing translation machinery — no new helpers, no new translation groups, no change to thresholds, recommendation cascade, or overall-status logic:
METRIC_DEFS[*].labels→labelKeysand lowercase the values intostatustranslation keys ('Poor'→'poor','Too Dry'→'too_dry', etc.)._getMetricStatus()resolves the key throughthis._t('status', key)— the same path the header badge already uses.statusgroup with the previously-untranslated keys:safe,low,high,elevated,clean,too_dry,dry,comfortable,humid,too_humid,cold,cool,warm,hot. English values match what was inMETRIC_DEFS.labelsso en behavior is byte-identical.CARD_VERSIONto2.9.2.Spanish, French, German, and Portuguese values follow the same domain vocabulary already used elsewhere in those locales (e.g. pt uses "Muito Seco" / "Muito Úmido" matching the existing
recommendation.too_dry/too_humid).Test plan
All 368 tests pass (
node test.js) — 360 existing + 8 new covering the bug:enCO₂ 2000 ppm →Poor(unchanged)ptCO₂ 2000 ppm →RuimesCO₂ 2000 ppm →MalodePM2.5 50 µg/m³ →SchlechtfrCO₂ 1200 ppm →Élevépthumidity 20% →Muito Secopttemperature 23 °C →Mornoestemperature 23 °C →Cálido_getCO2Status/_getMetricStatus/_getTempStatuscontinue to pass (English fallback is byte-identical to the old hard-coded labels).Tested locally in Home Assistant with
language: pt— the per-metric pill now matches the header badge ("Ruim" instead of "Poor"). Screenshot above shows the pre-fix state.🤖 Generated with Claude Code / I reviewed each translation before opening :)