Skip to content

v2.2.4 - i18n word order + auto-detect HA language

Choose a tag to compare

@eyalgal eyalgal released this 24 Apr 17:48
863ad0d

Two translation bugs fixed in this patch.

🐛 Bug Fixes

  • "X ago" word order broken in non-English locales: The previous _formatTimeAgo rendered <n> <unit_ago> (e.g. 1 hour ago), which only reads naturally in English. After French was added in #89, this produced 1 heure il y a instead of the correct il y a 1 heure. German (1 Stunde her -> vor 1 Stunde) and Spanish (1 hora atras -> hace 1 hora) had similar awkwardness. Every *_ago translation is now a template with a {n} placeholder (e.g. "il y a {n} heure", "vor {n} Stunde", "hace {n} hora"), and _formatTimeAgo interpolates via String.replace("{n}", n). Locales updated: en, de, es, da, it, fr (Danish/Italian keep their natural postfix order, just with the placeholder). (#90)
  • Card ignored the Home Assistant user language: setConfig hardcoded language: "en" as a default, so the this.hass.language fallback in _localize was never reached and the card stayed in English regardless of the user's HA language preference. The default is now removed so the card auto-detects the HA language, and the visual editor's Language dropdown reflects the auto-detected language until one is explicitly selected.
  • Auto-detect still failed for region-tagged locales: hass.language is a BCP-47 tag that can include a region (e.g. "de-DE", "pt-BR", "en_GB"), but TRANSLATIONS is keyed by base codes ("de", "es", ...). The lookup missed and silently fell back to English. The detected language is now normalized to lowercase and stripped to its base code before lookup. Falls back to English only when the base locale isn't translated.