From 5d86dbe7e83c5bf8c005240dd999f642c1ab697f Mon Sep 17 00:00:00 2001 From: Hmmbob <33529490+hmmbob@users.noreply.github.com> Date: Fri, 24 Jul 2026 21:13:07 +0200 Subject: [PATCH] Resolve runtime translation references --- .../localthings/translations/en.json | 86 +++++++++---------- .../localthings/translations/nl.json | 86 +++++++++---------- tests/test_translations.py | 22 ++++- 3 files changed, 106 insertions(+), 88 deletions(-) diff --git a/custom_components/localthings/translations/en.json b/custom_components/localthings/translations/en.json index c3860aa..b6a8dd2 100644 --- a/custom_components/localthings/translations/en.json +++ b/custom_components/localthings/translations/en.json @@ -20,7 +20,7 @@ "name": "Current limit enabled" }, "cycle_active": { - "name": "[%key:component::binary_sensor::entity_component::running::name%]" + "name": "Running" }, "defrost_active": { "name": "Defrost active" @@ -32,7 +32,7 @@ "name": "Device active" }, "door_open": { - "name": "[%key:component::binary_sensor::entity_component::door::name%]" + "name": "Door" }, "firmware_update": { "name": "Firmware update available" @@ -73,16 +73,16 @@ "name": "Start diagnosis" }, "pause": { - "name": "[%key:common::action::pause%]" + "name": "Pause" }, "selfcheck_start": { "name": "Start self-check" }, "start": { - "name": "[%key:common::action::start%]" + "name": "Start" }, "stop": { - "name": "[%key:common::action::stop%]" + "name": "Stop" } }, "climate": { @@ -134,24 +134,24 @@ "brightness_level": { "name": "Night brightness", "state": { - "33": "[%key:common::state::low%]", - "66": "[%key:common::state::medium%]", - "100": "[%key:common::state::high%]" + "33": "Low", + "66": "Medium", + "100": "High" } }, "day_brightness": { "name": "Cabinet brightness", "state": { - "33": "[%key:common::state::low%]", - "66": "[%key:common::state::medium%]", - "100": "[%key:common::state::high%]" + "33": "Low", + "66": "Medium", + "100": "High" } }, "buzzer_sound": { "name": "Buzzer sound", "state": { - "off": "[%key:common::state::off%]", - "on": "[%key:common::state::on%]" + "off": "Off", + "on": "On" } }, "cycle": { @@ -161,16 +161,16 @@ "name": "Detergent quantity", "state": { "00": "None", - "01": "[%key:common::state::low%]", - "02": "[%key:common::state::medium%]", - "03": "[%key:common::state::high%]" + "01": "Low", + "02": "Medium", + "03": "High" } }, "detergent_water_hardness": { "name": "Detergent water hardness", "state": { "01": "Soft", - "02": "[%key:common::state::medium%]", + "02": "Medium", "03": "Hard" } }, @@ -220,8 +220,8 @@ "finish_sound": { "name": "Finish sound", "state": { - "off": "[%key:common::state::off%]", - "on": "[%key:common::state::on%]" + "off": "Off", + "on": "On" } }, "flex_zone_mode": { @@ -242,16 +242,16 @@ "heated_dry": { "name": "Smart Dry", "state": { - "off": "[%key:common::state::off%]", - "low": "[%key:common::state::low%]", - "high": "[%key:common::state::high%]", + "off": "Off", + "low": "Low", + "high": "High", "extra_high": "Extra high" } }, "ice_type": { "name": "{instance_name} type", "state": { - "off": "[%key:common::state::off%]", + "off": "Off", "whiskey_iceball_3": "3 balls/day", "whiskey_iceball_6": "6 balls/day", "whiskey_iceball_9": "9 balls/day" @@ -260,15 +260,15 @@ "led_brightness": { "name": "Door LED brightness", "state": { - "low": "[%key:common::state::low%]", - "high": "[%key:common::state::high%]" + "low": "Low", + "high": "High" } }, "led_night_brightness": { "name": "Door LED night brightness", "state": { - "low": "[%key:common::state::low%]", - "high": "[%key:common::state::high%]" + "low": "Low", + "high": "High" } }, "oven_mode": { @@ -297,7 +297,7 @@ "range_burner_power_level": { "name": "Burner {number} power level", "state": { - "0": "[%key:common::state::off%]", + "0": "Off", "boost": "Boost", "simmer": "Simmer" } @@ -324,9 +324,9 @@ "name": "Softener quantity", "state": { "00": "None", - "01": "[%key:common::state::low%]", - "02": "[%key:common::state::medium%]", - "03": "[%key:common::state::high%]" + "01": "Low", + "02": "Medium", + "03": "High" } }, "sound_mode": { @@ -342,9 +342,9 @@ "state": { "rinse_hold": "Rinse hold", "no_spin": "No spin", - "low": "[%key:common::state::low%]", - "medium": "[%key:common::state::medium%]", - "high": "[%key:common::state::high%]" + "low": "Low", + "medium": "Medium", + "high": "High" } }, "wash_temperature": { @@ -400,7 +400,7 @@ "120": "2 hr", "180": "3 hr", "240": "4 hr", - "none": "[%key:common::state::off%]", + "none": "Off", "cupboard": "Cupboard" } } @@ -441,7 +441,7 @@ "name": "Current limit level" }, "current_temp_c": { - "name": "[%key:component::sensor::entity_component::temperature::name%]" + "name": "Temperature" }, "diagnosis": { "name": "Diagnosis" @@ -468,7 +468,7 @@ "name": "Dust" }, "energy_kwh": { - "name": "[%key:component::sensor::entity_component::energy::name%]" + "name": "Energy" }, "energy_last_month_kwh": { "name": "Energy (last month)" @@ -555,7 +555,7 @@ "name": "Power energy" }, "power_watts": { - "name": "[%key:component::sensor::entity_component::power::name%]" + "name": "Power" }, "progress": { "name": "Progress" @@ -581,15 +581,15 @@ "machine_state": { "name": "Machine state", "state": { - "idle": "[%key:common::state::idle%]", - "active": "[%key:common::state::active%]", + "idle": "Idle", + "active": "Active", "pause": "Paused" } }, "filter_status": { "name": "Filter status", "state": { - "normal": "[%key:common::state::normal%]", + "normal": "Normal", "wash": "Wash", "replace": "Replace" } @@ -597,7 +597,7 @@ "ice_making_status": { "name": "{instance_name} making status", "state": { - "icestatus_stop": "[%key:common::state::idle%]", + "icestatus_stop": "Idle", "icestatus_run": "Making ice" } } @@ -756,7 +756,7 @@ "unknown": "Unexpected error. Check the Home Assistant logs for details." }, "abort": { - "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" + "already_configured": "Device is already configured" } }, "options": { diff --git a/custom_components/localthings/translations/nl.json b/custom_components/localthings/translations/nl.json index 4998fdd..e9957e1 100644 --- a/custom_components/localthings/translations/nl.json +++ b/custom_components/localthings/translations/nl.json @@ -20,7 +20,7 @@ "name": "Stroombegrenzing ingeschakeld" }, "cycle_active": { - "name": "[%key:component::binary_sensor::entity_component::running::name%]" + "name": "Actief" }, "defrost_active": { "name": "Ontdooien actief" @@ -32,7 +32,7 @@ "name": "Apparaat actief" }, "door_open": { - "name": "[%key:component::binary_sensor::entity_component::door::name%]" + "name": "Deur" }, "firmware_update": { "name": "Firmware-update beschikbaar" @@ -73,16 +73,16 @@ "name": "Diagnose starten" }, "pause": { - "name": "[%key:common::action::pause%]" + "name": "Pauzeren" }, "selfcheck_start": { "name": "Zelfcontrole starten" }, "start": { - "name": "[%key:common::action::start%]" + "name": "Starten" }, "stop": { - "name": "[%key:common::action::stop%]" + "name": "Stoppen" } }, "climate": { @@ -134,24 +134,24 @@ "brightness_level": { "name": "Nachthelderheid", "state": { - "33": "[%key:common::state::low%]", - "66": "[%key:common::state::medium%]", - "100": "[%key:common::state::high%]" + "33": "Laag", + "66": "Gemiddeld", + "100": "Hoog" } }, "day_brightness": { "name": "Helderheid kast", "state": { - "33": "[%key:common::state::low%]", - "66": "[%key:common::state::medium%]", - "100": "[%key:common::state::high%]" + "33": "Laag", + "66": "Gemiddeld", + "100": "Hoog" } }, "buzzer_sound": { "name": "Zoemergeluid", "state": { - "off": "[%key:common::state::off%]", - "on": "[%key:common::state::on%]" + "off": "Uit", + "on": "Aan" } }, "cycle": { @@ -161,16 +161,16 @@ "name": "Hoeveelheid wasmiddel", "state": { "00": "Geen", - "01": "[%key:common::state::low%]", - "02": "[%key:common::state::medium%]", - "03": "[%key:common::state::high%]" + "01": "Laag", + "02": "Gemiddeld", + "03": "Hoog" } }, "detergent_water_hardness": { "name": "Waterhardheid voor wasmiddel", "state": { "01": "Zacht", - "02": "[%key:common::state::medium%]", + "02": "Gemiddeld", "03": "Hard" } }, @@ -220,8 +220,8 @@ "finish_sound": { "name": "Eindgeluid", "state": { - "off": "[%key:common::state::off%]", - "on": "[%key:common::state::on%]" + "off": "Uit", + "on": "Aan" } }, "flex_zone_mode": { @@ -242,16 +242,16 @@ "heated_dry": { "name": "Smart Dry", "state": { - "off": "[%key:common::state::off%]", - "low": "[%key:common::state::low%]", - "high": "[%key:common::state::high%]", + "off": "Uit", + "low": "Laag", + "high": "Hoog", "extra_high": "Extra hoog" } }, "ice_type": { "name": "Type {instance_name}", "state": { - "off": "[%key:common::state::off%]", + "off": "Uit", "whiskey_iceball_3": "3 ijsballen per dag", "whiskey_iceball_6": "6 ijsballen per dag", "whiskey_iceball_9": "9 ijsballen per dag" @@ -260,15 +260,15 @@ "led_brightness": { "name": "Helderheid deur-LED", "state": { - "low": "[%key:common::state::low%]", - "high": "[%key:common::state::high%]" + "low": "Laag", + "high": "Hoog" } }, "led_night_brightness": { "name": "Nachtelijke helderheid deur-LED", "state": { - "low": "[%key:common::state::low%]", - "high": "[%key:common::state::high%]" + "low": "Laag", + "high": "Hoog" } }, "oven_mode": { @@ -297,7 +297,7 @@ "range_burner_power_level": { "name": "Vermogensniveau brander {number}", "state": { - "0": "[%key:common::state::off%]", + "0": "Uit", "boost": "Boost", "simmer": "Sudderen" } @@ -324,9 +324,9 @@ "name": "Hoeveelheid wasverzachter", "state": { "00": "Geen", - "01": "[%key:common::state::low%]", - "02": "[%key:common::state::medium%]", - "03": "[%key:common::state::high%]" + "01": "Laag", + "02": "Gemiddeld", + "03": "Hoog" } }, "sound_mode": { @@ -342,9 +342,9 @@ "state": { "rinse_hold": "Spoelstop", "no_spin": "Niet centrifugeren", - "low": "[%key:common::state::low%]", - "medium": "[%key:common::state::medium%]", - "high": "[%key:common::state::high%]" + "low": "Laag", + "medium": "Gemiddeld", + "high": "Hoog" } }, "wash_temperature": { @@ -400,7 +400,7 @@ "120": "2 uur", "180": "3 uur", "240": "4 uur", - "none": "[%key:common::state::off%]", + "none": "Uit", "cupboard": "Kastdroog" } } @@ -441,7 +441,7 @@ "name": "Niveau stroombegrenzing" }, "current_temp_c": { - "name": "[%key:component::sensor::entity_component::temperature::name%]" + "name": "Temperatuur" }, "diagnosis": { "name": "Diagnose" @@ -468,7 +468,7 @@ "name": "Stof" }, "energy_kwh": { - "name": "[%key:component::sensor::entity_component::energy::name%]" + "name": "Energie" }, "energy_last_month_kwh": { "name": "Energie (vorige maand)" @@ -555,7 +555,7 @@ "name": "Energieverbruik" }, "power_watts": { - "name": "[%key:component::sensor::entity_component::power::name%]" + "name": "Vermogen" }, "progress": { "name": "Voortgang" @@ -581,15 +581,15 @@ "machine_state": { "name": "Machinestatus", "state": { - "idle": "[%key:common::state::idle%]", - "active": "[%key:common::state::active%]", + "idle": "Inactief", + "active": "Actief", "pause": "Gepauzeerd" } }, "filter_status": { "name": "Filterstatus", "state": { - "normal": "[%key:common::state::normal%]", + "normal": "Normaal", "wash": "Reinigen", "replace": "Vervangen" } @@ -597,7 +597,7 @@ "ice_making_status": { "name": "{instance_name} ijsmaakstatus", "state": { - "icestatus_stop": "[%key:common::state::idle%]", + "icestatus_stop": "Inactief", "icestatus_run": "IJs maken" } } @@ -756,7 +756,7 @@ "unknown": "Onverwachte fout. Raadpleeg de Home Assistant-logboeken voor meer informatie." }, "abort": { - "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" + "already_configured": "Apparaat is al geconfigureerd" } }, "options": { diff --git a/tests/test_translations.py b/tests/test_translations.py index ab94b81..c5bb553 100644 --- a/tests/test_translations.py +++ b/tests/test_translations.py @@ -72,8 +72,26 @@ def _all_descriptions(): yield from visit(value) -def test_source_and_english_translation_are_identical(): - assert _load("strings.json") == _load("translations/en.json") +def test_source_and_english_translation_topology_and_placeholders_match(): + source = _load("strings.json") + english = _load("translations/en.json") + assert _topology(source) == _topology(english) + + english_strings = dict(_walk_strings(english)) + for path, value in _walk_strings(source): + assert _placeholders(value) == _placeholders(english_strings[path]), path + + +def test_runtime_translation_catalogs_have_no_unresolved_references(): + for language in ("en", "nl"): + unresolved = [ + (path, value) + for path, value in _walk_strings( + _load(f"translations/{language}.json") + ) + if "[%key:" in value + ] + assert unresolved == [] def test_english_and_dutch_catalog_topology_and_placeholders_match():