Translation System

Understanding how the HydroQC integration displays entity names in different languages

Overview

The HydroQC integration uses Home Assistant’s built-in translation system to display sensor and entity names in your preferred language. The integration supports English, French, and Spanish.

How Translation Works

Home Assistant determines which language to display based on a specific priority order:

  1. System Language (highest priority)
  2. User Profile Language (fallback)
  3. Default Language (English) (final fallback)

This means that entity names will appear in the language configured for your entire Home Assistant system, not necessarily the language set in your individual user profile.

Supported Languages

LanguageTranslation FileCoverage
Englishen.json✅ Complete (58 sensors, 16 binary sensors)
Frenchfr.json✅ Complete (58 sensors, 16 binary sensors)
Spanishes.json✅ Complete (58 sensors, 16 binary sensors)

Changing the Display Language

System-Wide Language

To change the language for all entity names system-wide:

  1. Go to SettingsSystemGeneral
  2. Under Language & Region, select your preferred language from the Language dropdown
  3. Click Save
  4. Refresh your browser to see the changes

User Profile Language

While you can set a different language in your user profile (SettingsProfile), this will not override the system language for entity names. The system language always takes precedence for entity translations.

Example Sensor Names

Here are some examples of how sensor names appear in each language:

Sensor KeyEnglishFrenchSpanish
balanceBalanceSoldeSaldo
current_billing_period_current_dayBilling Period DayJour période facturationDía período facturación
current_billing_period_total_consumptionBilling Period ConsumptionConso. période facturationConsumo período facturación
wc_cumulated_creditWinter CreditCrédit cumuléCrédito acumulado
dpc_pre_heatPre-heat PeriodPériode de préchauffagePeríodo de precalentamiento

Contributing Translations

If you’d like to improve existing translations or add support for a new language:

  1. Translation files are located in custom_components/hydroqc/translations/
  2. Each file follows the format {language_code}.json (e.g., es.json for Spanish)
  3. The structure includes:
    • Config flow translations (config.step.*)
    • Options flow translations (options.step.*)
    • Entity translations (entity.sensor.* and entity.binary_sensor.*)

For detailed instructions on contributing translations, see the CONTRIBUTING.md file in the repository.

Technical Details

Translation Keys

The integration uses Home Assistant’s translation_key system instead of hardcoded names. Each sensor has a unique key defined in const.py:

SENSORS = {
    "balance": {
        "data_source": "account.balance",
        "device_class": SensorDeviceClass.MONETARY,
        # No "name" field - uses translation_key instead
    },
}

The sensor entity then sets _attr_translation_key:

self._attr_translation_key = self._sensor_key

Home Assistant automatically looks up the translated name from the appropriate translation file based on the system language.

Benefits of Translation Keys

  • Maintainability: Update translations without changing Python code
  • Consistency: Names are consistent across the integration
  • Localization: Easy to add new languages by creating new translation files
  • User Experience: Entity names appear in the user’s preferred language