Internationalization (i18n) & Localization Guide
The Home Assistant WhatsApp Integration & WhatsApp Addon Web UI feature 100% dynamic i18n support for English (EN), German (DE), and any additional community-contributed language.
Architecture Overview
All language dictionaries are stored as flat, top-level .json files directly inside the respective translation folder. There are no subdirectories β every language file behaves 100% uniformly and identically to en.json and de.json.
βββ custom_components/whatsapp/
β βββ strings.json # Base keys template for Home Assistant
β βββ translations/
β βββ en.json # English translation
β βββ de.json # German translation
β βββ fr.json # French translation (drop-in)
β βββ es.json # Spanish translation (drop-in)
β
βββ whatsapp/app/src/locales/
βββ loader.js # Dynamic file-based locale loader (no hardcoded language lists)
βββ en.json # English dictionary
βββ de.json # German dictionary
βββ fr.json # French dictionary (drop-in)
βββ es.json # Spanish dictionary (drop-in)
Automatic Browser Language Detection & Manual Override
The Web UI automatically detects the userβs preferred language on initial visit:
- Browser Auto-Detection: Reads
navigator.language(e.g.de-DE->deoren-US->en). - Default Fallback: If an unsupported language or no language is detected, the system automatically defaults to
en(English). - Manual Selection: Users can switch the UI language anytime using the language selector (
π DE / EN) in the top navigation header. - Persistence: Manual preferences are stored in
localStorage(ha-whatsapp-lang) and override browser auto-detection.
1. Adding a New Language to the Web UI & Addon
Adding a new language to the Addon Web UI requires zero code modifications.
- Create a new
.jsonfile insidewhatsapp/app/src/locales/<lang_code>.json(e.g.,es.jsonorfr.json). - Include language metadata in the
metasection:{ "meta": { "code": "es", "name": "EspaΓ±ol", "flag": "πͺπΈ" }, "nav": { ... }, "common": { ... } } - The server-side
loader.jswill automatically discover the new language file on startup and expose it via/api/i18n/languages.
2. Adding a New Language to the Home Assistant Integration
- Create a new file in
custom_components/whatsapp/translations/<lang_code>.json. - Mirror all key structures from
custom_components/whatsapp/strings.json.
3. Automated Translation Verification
Run the automated test suite to verify key parity across all language files:
npm test
The test runner automatically validates:
- Key parity across all locale files in
src/locales/ - Interpolation placeholder matching (
{count},{name}, etc.) - Parity between Home Assistant
strings.jsonandtranslations/de.json