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:

  1. Browser Auto-Detection: Reads navigator.language (e.g. de-DE -> de or en-US -> en).
  2. Default Fallback: If an unsupported language or no language is detected, the system automatically defaults to en (English).
  3. Manual Selection: Users can switch the UI language anytime using the language selector (🌐 DE / EN) in the top navigation header.
  4. 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.

  1. Create a new .json file inside whatsapp/app/src/locales/<lang_code>.json (e.g., es.json or fr.json).
  2. Include language metadata in the meta section:
    {
      "meta": {
        "code": "es",
        "name": "EspaΓ±ol",
        "flag": "πŸ‡ͺπŸ‡Έ"
      },
      "nav": { ... },
      "common": { ... }
    }
    
  3. The server-side loader.js will 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

  1. Create a new file in custom_components/whatsapp/translations/<lang_code>.json.
  2. 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.json and translations/de.json

Maintained by FaserF. This project is not affiliated with WhatsApp Inc.

This site uses Just the Docs, a documentation theme for Jekyll.