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
32 changed files with 435 additions and 321 deletions

View File

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