Restructure translations for entity components (#89702)

This commit is contained in:
Franck Nijhof 2023-03-16 12:16:08 +01:00 committed by GitHub
parent f55aaf7664
commit f32b7859b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 435 additions and 321 deletions

View File

@ -26,19 +26,21 @@
"armed_vacation": "{entity_name} armed vacation" "armed_vacation": "{entity_name} armed vacation"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"armed": "Armed", "state": {
"disarmed": "Disarmed", "armed": "Armed",
"armed_home": "Armed home", "disarmed": "Disarmed",
"armed_away": "Armed away", "armed_home": "Armed home",
"armed_night": "Armed night", "armed_away": "Armed away",
"armed_vacation": "Armed vacation", "armed_night": "Armed night",
"armed_custom_bypass": "Armed custom bypass", "armed_vacation": "Armed vacation",
"pending": "Pending", "armed_custom_bypass": "Armed custom bypass",
"arming": "Arming", "pending": "Pending",
"disarming": "Disarming", "arming": "Arming",
"triggered": "Triggered" "disarming": "Disarming",
"triggered": "Triggered"
}
} }
} }
} }

View File

@ -1,10 +1,12 @@
{ {
"title": "Alert", "title": "Alert",
"state": { "entity_component": {
"_": { "_": {
"idle": "[%key:common::state::idle%]", "state": {
"off": "Acknowledged", "idle": "[%key:common::state::idle%]",
"on": "[%key:common::state::active%]" "off": "Acknowledged",
"on": "[%key:common::state::active%]"
}
} }
} }
} }

View File

@ -1,9 +1,11 @@
{ {
"title": "Automation", "title": "Automation",
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]" "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
} }
}, },
"issues": { "issues": {

View File

@ -106,114 +106,168 @@
"turned_off": "{entity_name} turned off" "turned_off": "{entity_name} turned off"
} }
}, },
"state": { "entity_component": {
"_": {
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
},
"battery": { "battery": {
"off": "Normal", "state": {
"on": "Low" "off": "Normal",
"on": "Low"
}
}, },
"battery_charging": { "battery_charging": {
"off": "Not charging", "state": {
"on": "Charging" "off": "Not charging",
"on": "Charging"
}
}, },
"carbon_monoxide": { "carbon_monoxide": {
"off": "[%key:component::binary_sensor::state::gas::off%]", "state": {
"on": "[%key:component::binary_sensor::state::gas::on%]" "off": "[%key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
}, },
"cold": { "cold": {
"off": "[%key:component::binary_sensor::state::battery::off%]", "state": {
"on": "Cold" "off": "[%key:component::binary_sensor::entity_component::battery::state::off%]",
"on": "Cold"
}
}, },
"connectivity": { "connectivity": {
"off": "[%key:common::state::disconnected%]", "state": {
"on": "[%key:common::state::connected%]" "off": "[%key:common::state::disconnected%]",
"on": "[%key:common::state::connected%]"
}
}, },
"door": { "door": {
"off": "[%key:common::state::closed%]", "state": {
"on": "[%key:common::state::open%]" "off": "[%key:common::state::closed%]",
"on": "[%key:common::state::open%]"
}
}, },
"garage_door": { "garage_door": {
"off": "[%key:common::state::closed%]", "state": {
"on": "[%key:common::state::open%]" "off": "[%key:common::state::closed%]",
"on": "[%key:common::state::open%]"
}
}, },
"gas": { "gas": {
"off": "Clear", "state": {
"on": "Detected" "off": "Clear",
"on": "Detected"
}
}, },
"heat": { "heat": {
"off": "[%key:component::binary_sensor::state::battery::off%]", "state": {
"on": "Hot" "off": "[%key:component::binary_sensor::entity_component::battery::state::off%]",
"on": "Hot"
}
}, },
"light": { "light": {
"off": "No light", "state": {
"on": "Light detected" "off": "No light",
"on": "Light detected"
}
}, },
"lock": { "lock": {
"off": "[%key:common::state::locked%]", "state": {
"on": "[%key:common::state::unlocked%]" "off": "[%key:common::state::locked%]",
"on": "[%key:common::state::unlocked%]"
}
}, },
"moisture": { "moisture": {
"off": "Dry", "state": {
"on": "Wet" "off": "Dry",
"on": "Wet"
}
}, },
"motion": { "motion": {
"off": "[%key:component::binary_sensor::state::gas::off%]", "state": {
"on": "[%key:component::binary_sensor::state::gas::on%]" "off": "[key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
}, },
"moving": { "moving": {
"off": "Not moving", "state": {
"on": "Moving" "off": "Not moving",
"on": "Moving"
}
}, },
"occupancy": { "occupancy": {
"off": "[%key:component::binary_sensor::state::gas::off%]", "state": {
"on": "[%key:component::binary_sensor::state::gas::on%]" "off": "[key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
}, },
"opening": { "opening": {
"off": "[%key:common::state::closed%]", "state": {
"on": "[%key:common::state::open%]" "off": "[%key:common::state::closed%]",
"on": "[%key:common::state::open%]"
}
}, },
"plug": { "plug": {
"off": "Unplugged", "state": {
"on": "Plugged in" "off": "Unplugged",
"on": "Plugged in"
}
}, },
"presence": { "presence": {
"off": "[%key:component::device_tracker::state::_::not_home%]", "state": {
"on": "[%key:component::device_tracker::state::_::home%]" "off": "[%key:component::device_tracker::entity_component::_::state::not_home%]",
"on": "[%key:component::device_tracker::entity_component::_::state::home%]"
}
}, },
"problem": { "problem": {
"off": "OK", "state": {
"on": "Problem" "off": "OK",
"on": "Problem"
}
}, },
"running": { "running": {
"off": "Not running", "state": {
"on": "Running" "off": "Not running",
"on": "Running"
}
}, },
"safety": { "safety": {
"off": "Safe", "state": {
"on": "Unsafe" "off": "Safe",
"on": "Unsafe"
}
}, },
"smoke": { "smoke": {
"off": "[%key:component::binary_sensor::state::gas::off%]", "state": {
"on": "[%key:component::binary_sensor::state::gas::on%]" "off": "[key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
}, },
"sound": { "sound": {
"off": "[%key:component::binary_sensor::state::gas::off%]", "state": {
"on": "[%key:component::binary_sensor::state::gas::on%]" "off": "[key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
}, },
"update": { "update": {
"off": "Up-to-date", "state": {
"on": "Update available" "off": "Up-to-date",
"on": "Update available"
}
}, },
"vibration": { "vibration": {
"off": "[%key:component::binary_sensor::state::gas::off%]", "state": {
"on": "[%key:component::binary_sensor::state::gas::on%]" "off": "[key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
}, },
"window": { "window": {
"off": "[%key:common::state::closed%]", "state": {
"on": "[%key:common::state::open%]" "off": "[%key:common::state::closed%]",
}, "on": "[%key:common::state::open%]"
"_": { }
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
} }
}, },
"device_class": { "device_class": {

View File

@ -1,9 +1,11 @@
{ {
"title": "Calendar", "title": "Calendar",
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]" "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
} }
} }
} }

View File

@ -1,10 +1,12 @@
{ {
"title": "Camera", "title": "Camera",
"state": { "entity_component": {
"_": { "_": {
"recording": "Recording", "state": {
"streaming": "Streaming", "recording": "Recording",
"idle": "[%key:common::state::idle%]" "streaming": "Streaming",
"idle": "[%key:common::state::idle%]"
}
} }
} }
} }

View File

@ -15,92 +15,92 @@
"set_preset_mode": "Change preset on {entity_name}" "set_preset_mode": "Change preset on {entity_name}"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"heat": "Heat", "off": "[%key:common::state::off%]",
"cool": "Cool", "heat": "Heat",
"heat_cool": "Heat/Cool", "cool": "Cool",
"auto": "Auto", "heat_cool": "Heat/Cool",
"dry": "Dry", "auto": "Auto",
"fan_only": "Fan only" "dry": "Dry",
} "fan_only": "Fan only"
},
"state_attributes": {
"_": {
"aux_heat": { "name": "Aux heat" },
"current_humidity": { "name": "Current humidity" },
"current_temperature": { "name": "Current temperature" },
"fan_mode": {
"name": "Fan mode",
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"auto": "Auto",
"low": "Low",
"medium": "Medium",
"high": "High",
"top": "Top",
"middle": "Middle",
"focus": "Focus",
"diffuse": "Diffuse"
}
}, },
"fan_modes": { "state_attributes": {
"name": "Fan modes" "aux_heat": { "name": "Aux heat" },
}, "current_humidity": { "name": "Current humidity" },
"humidity": { "name": "Target humidity" }, "current_temperature": { "name": "Current temperature" },
"hvac_action": { "fan_mode": {
"name": "Current action", "name": "Fan mode",
"state": { "state": {
"off": "Off", "off": "[%key:common::state::off%]",
"heating": "Heating", "on": "[%key:common::state::on%]",
"cooling": "Cooling", "auto": "Auto",
"drying": "Drying", "low": "Low",
"idle": "Idle", "medium": "Medium",
"fan": "Fan" "high": "High",
} "top": "Top",
}, "middle": "Middle",
"hvac_modes": { "focus": "Focus",
"name": "HVAC modes" "diffuse": "Diffuse"
}, }
"max_humidity": { "name": "Max target humidity" }, },
"max_temp": { "name": "Max target temperature" }, "fan_modes": {
"min_humidity": { "name": "Min target humidity" }, "name": "Fan modes"
"min_temp": { "name": "Min target temperature" }, },
"preset_mode": { "humidity": { "name": "Target humidity" },
"name": "Preset", "hvac_action": {
"state": { "name": "Current action",
"none": "None", "state": {
"eco": "Eco", "off": "Off",
"away": "Away", "heating": "Heating",
"boost": "Boost", "cooling": "Cooling",
"comfort": "Comfort", "drying": "Drying",
"home": "Home", "idle": "Idle",
"sleep": "Sleep", "fan": "Fan"
"activity": "Activity" }
} },
}, "hvac_modes": {
"preset_modes": { "name": "HVAC modes"
"name": "Presets" },
}, "max_humidity": { "name": "Max target humidity" },
"swing_mode": { "max_temp": { "name": "Max target temperature" },
"name": "Swing mode", "min_humidity": { "name": "Min target humidity" },
"state": { "min_temp": { "name": "Min target temperature" },
"off": "[%key:common::state::off%]", "preset_mode": {
"on": "[%key:common::state::on%]", "name": "Preset",
"both": "Both", "state": {
"vertical": "Vertical", "none": "None",
"horizontal": "Horizontal" "eco": "Eco",
} "away": "Away",
}, "boost": "Boost",
"swing_modes": { "comfort": "Comfort",
"name": "Swing modes" "home": "Home",
}, "sleep": "Sleep",
"target_temp_high": { "name": "Upper target temperature" }, "activity": "Activity"
"target_temp_low": { "name": "Lower target temperature" }, }
"target_temp_step": { "name": "Target temperature step" }, },
"temperature": { "name": "Target temperature" } "preset_modes": {
"name": "Presets"
},
"swing_mode": {
"name": "Swing mode",
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"both": "Both",
"vertical": "Vertical",
"horizontal": "Horizontal"
}
},
"swing_modes": {
"name": "Swing modes"
},
"target_temp_high": { "name": "Upper target temperature" },
"target_temp_low": { "name": "Lower target temperature" },
"target_temp_step": { "name": "Target temperature step" },
"temperature": { "name": "Target temperature" }
}
} }
} }
} }

View File

@ -1,9 +1,11 @@
{ {
"title": "Configurator", "title": "Configurator",
"state": { "entity_component": {
"_": { "_": {
"configure": "Configure", "state": {
"configured": "Configured" "configure": "Configure",
"configured": "Configured"
}
} }
} }
} }

View File

@ -27,13 +27,15 @@
"tilt_position": "{entity_name} tilt position changes" "tilt_position": "{entity_name} tilt position changes"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"open": "[%key:common::state::open%]", "state": {
"opening": "Opening", "open": "[%key:common::state::open%]",
"closed": "[%key:common::state::closed%]", "opening": "Opening",
"closing": "Closing", "closed": "[%key:common::state::closed%]",
"stopped": "Stopped" "closing": "Closing",
"stopped": "Stopped"
}
} }
} }
} }

View File

@ -10,10 +10,12 @@
"leaves": "{entity_name} leaves a zone" "leaves": "{entity_name} leaves a zone"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"home": "[%key:common::state::home%]", "state": {
"not_home": "[%key:common::state::not_home%]" "home": "[%key:common::state::home%]",
"not_home": "[%key:common::state::not_home%]"
}
} }
} }
} }

View File

@ -16,10 +16,12 @@
"turn_off": "Turn off {entity_name}" "turn_off": "Turn off {entity_name}"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]" "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
} }
} }
} }

View File

@ -155,18 +155,20 @@
} }
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]", "off": "[%key:common::state::off%]",
"home": "[%key:component::device_tracker::state::_::home%]", "on": "[%key:common::state::on%]",
"not_home": "[%key:component::device_tracker::state::_::not_home%]", "home": "[%key:component::device_tracker::entity_component::_::state::home%]",
"open": "[%key:common::state::open%]", "not_home": "[%key:component::device_tracker::entity_component::_::state::not_home%]",
"closed": "[%key:common::state::closed%]", "open": "[%key:common::state::open%]",
"locked": "[%key:common::state::locked%]", "closed": "[%key:common::state::closed%]",
"unlocked": "[%key:common::state::unlocked%]", "locked": "[%key:common::state::locked%]",
"ok": "[%key:component::binary_sensor::state::problem::off%]", "unlocked": "[%key:common::state::unlocked%]",
"problem": "[%key:component::binary_sensor::state::problem::on%]" "ok": "[%key:component::binary_sensor::entity_component::problem::state::off%]",
"problem": "[%key:component::binary_sensor::entity_component::problem::state::on%]"
}
} }
} }
} }

View File

@ -20,10 +20,12 @@
"turn_off": "Turn off {entity_name}" "turn_off": "Turn off {entity_name}"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]" "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
} }
} }
} }

View File

@ -1,9 +1,11 @@
{ {
"title": "Input boolean", "title": "Input boolean",
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]" "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
} }
} }
} }

View File

@ -19,10 +19,12 @@
"turned_off": "{entity_name} turned off" "turned_off": "{entity_name} turned off"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]" "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
} }
} }
} }

View File

@ -15,10 +15,12 @@
"unlocked": "{entity_name} unlocked" "unlocked": "{entity_name} unlocked"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"locked": "[%key:common::state::locked%]", "state": {
"unlocked": "[%key:common::state::unlocked%]" "locked": "[%key:common::state::locked%]",
"unlocked": "[%key:common::state::unlocked%]"
}
} }
} }
} }

View File

@ -19,15 +19,17 @@
"changed_states": "{entity_name} changed states" "changed_states": "{entity_name} changed states"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]", "off": "[%key:common::state::off%]",
"playing": "Playing", "on": "[%key:common::state::on%]",
"paused": "[%key:common::state::paused%]", "playing": "Playing",
"idle": "[%key:common::state::idle%]", "paused": "[%key:common::state::paused%]",
"standby": "[%key:common::state::standby%]", "idle": "[%key:common::state::idle%]",
"buffering": "Buffering" "standby": "[%key:common::state::standby%]",
"buffering": "Buffering"
}
} }
} }
} }

View File

@ -1,9 +1,11 @@
{ {
"title": "Person", "title": "Person",
"state": { "entity_component": {
"_": { "_": {
"home": "[%key:common::state::home%]", "state": {
"not_home": "[%key:common::state::not_home%]" "home": "[%key:common::state::home%]",
"not_home": "[%key:common::state::not_home%]"
}
} }
} }
} }

View File

@ -1,9 +1,11 @@
{ {
"title": "Plant Monitor", "title": "Plant Monitor",
"state": { "entity_component": {
"_": { "_": {
"ok": "[%key:component::binary_sensor::state::problem::off%]", "state": {
"problem": "[%key:component::binary_sensor::state::problem::on%]" "ok": "[%key:component::binary_sensor::entity_component::problem::state::off%]",
"problem": "[%key:component::binary_sensor::entity_component::problem::state::on%]"
}
} }
} }
} }

View File

@ -16,10 +16,12 @@
"turned_off": "{entity_name} turned off" "turned_off": "{entity_name} turned off"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]" "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
} }
} }
} }

View File

@ -1,9 +1,11 @@
{ {
"title": "Schedule", "title": "Schedule",
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]" "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
} }
} }
} }

View File

@ -1,9 +1,11 @@
{ {
"title": "Script", "title": "Script",
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]" "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
} }
} }
} }

View File

@ -94,10 +94,12 @@
"wind_speed": "{entity_name} wind speed changes" "wind_speed": "{entity_name} wind speed changes"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]" "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
} }
} }
} }

View File

@ -10,10 +10,12 @@
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]" "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"above_horizon": "Above horizon", "state": {
"below_horizon": "Below horizon" "above_horizon": "Above horizon",
"below_horizon": "Below horizon"
}
} }
} }
} }

View File

@ -16,10 +16,12 @@
"turned_off": "{entity_name} turned off" "turned_off": "{entity_name} turned off"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"on": "[%key:common::state::on%]" "off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
} }
} }
} }

View File

@ -1,9 +1,11 @@
{ {
"state": { "entity_component": {
"_": { "_": {
"active": "[%key:common::state::active%]", "state": {
"idle": "[%key:common::state::idle%]", "active": "[%key:common::state::active%]",
"paused": "[%key:common::state::paused%]" "idle": "[%key:common::state::idle%]",
"paused": "[%key:common::state::paused%]"
}
} }
} }
} }

View File

@ -14,16 +14,18 @@
"dock": "Let {entity_name} return to the dock" "dock": "Let {entity_name} return to the dock"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"cleaning": "Cleaning", "state": {
"docked": "Docked", "cleaning": "Cleaning",
"error": "Error", "docked": "Docked",
"idle": "[%key:common::state::idle%]", "error": "Error",
"off": "[%key:common::state::off%]", "idle": "[%key:common::state::idle%]",
"on": "[%key:common::state::on%]", "off": "[%key:common::state::off%]",
"paused": "[%key:common::state::paused%]", "on": "[%key:common::state::on%]",
"returning": "Returning to dock" "paused": "[%key:common::state::paused%]",
"returning": "Returning to dock"
}
} }
} }
} }

View File

@ -5,15 +5,17 @@
"turn_off": "Turn off {entity_name}" "turn_off": "Turn off {entity_name}"
} }
}, },
"state": { "entity_component": {
"_": { "_": {
"off": "[%key:common::state::off%]", "state": {
"eco": "Eco", "off": "[%key:common::state::off%]",
"electric": "Electric", "eco": "Eco",
"gas": "Gas", "electric": "Electric",
"high_demand": "High Demand", "gas": "Gas",
"heat_pump": "Heat Pump", "high_demand": "High Demand",
"performance": "Performance" "heat_pump": "Heat Pump",
"performance": "Performance"
}
} }
} }
} }

View File

@ -1,21 +1,23 @@
{ {
"state": { "entity_component": {
"_": { "_": {
"clear-night": "Clear, night", "state": {
"cloudy": "Cloudy", "clear-night": "Clear, night",
"exceptional": "Exceptional", "cloudy": "Cloudy",
"fog": "Fog", "exceptional": "Exceptional",
"hail": "Hail", "fog": "Fog",
"lightning": "Lightning", "hail": "Hail",
"lightning-rainy": "Lightning, rainy", "lightning": "Lightning",
"partlycloudy": "Partly cloudy", "lightning-rainy": "Lightning, rainy",
"pouring": "Pouring", "partlycloudy": "Partly cloudy",
"rainy": "Rainy", "pouring": "Pouring",
"snowy": "Snowy", "rainy": "Rainy",
"snowy-rainy": "Snowy, rainy", "snowy": "Snowy",
"sunny": "Sunny", "snowy-rainy": "Snowy, rainy",
"windy": "Windy", "sunny": "Sunny",
"windy-variant": "Windy" "windy": "Windy",
"windy-variant": "Windy"
}
} }
} }
} }

View File

@ -255,13 +255,16 @@ class _TranslationCache:
categories.update(resource) categories.update(resource)
for category in categories: for category in categories:
resource_func = (
_merge_resources if category == "state" else _build_resources
)
new_resources: Mapping[str, dict[str, Any] | str] new_resources: Mapping[str, dict[str, Any] | str]
new_resources = resource_func( # type: ignore[assignment]
translation_strings, components, category if category in ("state", "entity_component"):
) new_resources = _merge_resources(
translation_strings, components, category
)
else:
new_resources = _build_resources(
translation_strings, components, category
)
for component, resource in new_resources.items(): for component, resource in new_resources.items():
category_cache: dict[str, Any] = cached.setdefault( category_cache: dict[str, Any] = cached.setdefault(
@ -299,7 +302,7 @@ async def async_get_translations(
components = set(integrations) components = set(integrations)
elif config_flow: elif config_flow:
components = (await async_get_config_flows(hass)) - hass.config.components components = (await async_get_config_flows(hass)) - hass.config.components
elif category == "state": elif category in ("state", "entity_component"):
components = set(hass.config.components) components = set(hass.config.components)
else: else:
# Only 'state' supports merging, so remove platforms from selection # Only 'state' supports merging, so remove platforms from selection

View File

@ -231,25 +231,6 @@ def gen_strings_schema(config: Config, integration: Integration) -> vol.Schema:
vol.Optional("trigger_type"): {str: cv.string_with_no_html}, vol.Optional("trigger_type"): {str: cv.string_with_no_html},
vol.Optional("trigger_subtype"): {str: cv.string_with_no_html}, vol.Optional("trigger_subtype"): {str: cv.string_with_no_html},
}, },
vol.Optional("state"): cv.schema_with_slug_keys(
cv.schema_with_slug_keys(
cv.string_with_no_html, slug_validator=translation_key_validator
),
slug_validator=vol.Any("_", cv.slug),
),
vol.Optional("state_attributes"): cv.schema_with_slug_keys(
cv.schema_with_slug_keys(
{
vol.Optional("name"): str,
vol.Optional("state"): cv.schema_with_slug_keys(
cv.string_with_no_html,
slug_validator=translation_key_validator,
),
},
slug_validator=translation_key_validator,
),
slug_validator=vol.Any("_", cv.slug),
),
vol.Optional("system_health"): { vol.Optional("system_health"): {
vol.Optional("info"): cv.schema_with_slug_keys( vol.Optional("info"): cv.schema_with_slug_keys(
cv.string_with_no_html, slug_validator=translation_key_validator cv.string_with_no_html, slug_validator=translation_key_validator
@ -283,26 +264,48 @@ def gen_strings_schema(config: Config, integration: Integration) -> vol.Schema:
), ),
) )
}, },
vol.Optional("entity"): { vol.Optional("entity_component"): cv.schema_with_slug_keys(
str: { {
str: { vol.Optional("state"): cv.schema_with_slug_keys(
cv.string_with_no_html,
slug_validator=translation_key_validator,
),
vol.Optional("state_attributes"): cv.schema_with_slug_keys(
{
vol.Optional("name"): str,
vol.Optional("state"): cv.schema_with_slug_keys(
cv.string_with_no_html,
slug_validator=translation_key_validator,
),
},
slug_validator=translation_key_validator,
),
},
slug_validator=vol.Any("_", cv.slug),
),
vol.Optional("entity"): cv.schema_with_slug_keys(
cv.schema_with_slug_keys(
{
vol.Optional("name"): cv.string_with_no_html, vol.Optional("name"): cv.string_with_no_html,
vol.Optional("state_attributes"): { vol.Optional("state"): cv.schema_with_slug_keys(
str: { cv.string_with_no_html,
slug_validator=translation_key_validator,
),
vol.Optional("state_attributes"): cv.schema_with_slug_keys(
{
vol.Optional("name"): cv.string_with_no_html, vol.Optional("name"): cv.string_with_no_html,
vol.Optional("state"): cv.schema_with_slug_keys( vol.Optional("state"): cv.schema_with_slug_keys(
cv.string_with_no_html, cv.string_with_no_html,
slug_validator=translation_key_validator, slug_validator=translation_key_validator,
), ),
} },
},
vol.Optional("state"): cv.schema_with_slug_keys(
cv.string_with_no_html,
slug_validator=translation_key_validator, slug_validator=translation_key_validator,
), ),
} },
} slug_validator=translation_key_validator,
}, ),
slug_validator=cv.slug,
),
} }
) )

View File

@ -373,32 +373,32 @@ async def test_caching(hass: HomeAssistant) -> None:
"homeassistant.helpers.translation._merge_resources", "homeassistant.helpers.translation._merge_resources",
side_effect=translation._merge_resources, side_effect=translation._merge_resources,
) as mock_merge: ) as mock_merge:
load1 = await translation.async_get_translations(hass, "en", "state") load1 = await translation.async_get_translations(hass, "en", "entity_component")
assert len(mock_merge.mock_calls) == 1 assert len(mock_merge.mock_calls) == 1
load2 = await translation.async_get_translations(hass, "en", "state") load2 = await translation.async_get_translations(hass, "en", "entity_component")
assert len(mock_merge.mock_calls) == 1 assert len(mock_merge.mock_calls) == 1
assert load1 == load2 assert load1 == load2
for key in load1: for key in load1:
assert key.startswith("component.sensor.state.") or key.startswith( assert key.startswith(
"component.light.state." "component.sensor.entity_component._.state."
) ) or key.startswith("component.light.entity_component._.state.")
load_sensor_only = await translation.async_get_translations( load_sensor_only = await translation.async_get_translations(
hass, "en", "state", integrations={"sensor"} hass, "en", "entity_component", integrations={"sensor"}
) )
assert load_sensor_only assert load_sensor_only
for key in load_sensor_only: for key in load_sensor_only:
assert key.startswith("component.sensor.state.") assert key.startswith("component.sensor.entity_component._.state.")
load_light_only = await translation.async_get_translations( load_light_only = await translation.async_get_translations(
hass, "en", "state", integrations={"light"} hass, "en", "entity_component", integrations={"light"}
) )
assert load_light_only assert load_light_only
for key in load_light_only: for key in load_light_only:
assert key.startswith("component.light.state.") assert key.startswith("component.light.entity_component._.state.")
hass.config.components.add("media_player") hass.config.components.add("media_player")