Fix translations merging (#34417)
Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>pull/34440/head
parent
e5a861dc90
commit
d10f5a48d4
|
@ -104,12 +104,15 @@ def build_resources(
|
|||
domain_resources.update(translation_cache[component])
|
||||
continue
|
||||
|
||||
if category not in translation_cache[component]:
|
||||
new_value = translation_cache[component].get(category)
|
||||
|
||||
if new_value is None:
|
||||
continue
|
||||
|
||||
domain_resources.setdefault(category, {}).update(
|
||||
translation_cache[component][category]
|
||||
)
|
||||
if isinstance(new_value, dict):
|
||||
domain_resources.setdefault(category, {}).update(new_value)
|
||||
else:
|
||||
domain_resources[category] = new_value
|
||||
|
||||
return {"component": resources}
|
||||
|
||||
|
|
|
@ -192,3 +192,17 @@ async def test_get_translations_while_loading_components(hass):
|
|||
"component.component1.title": "Component 1",
|
||||
"component.component1.hello": "world",
|
||||
}
|
||||
|
||||
|
||||
async def test_get_translation_categories(hass):
|
||||
"""Test the get translations helper loads config flow translations."""
|
||||
with patch.object(translation, "async_get_config_flows", return_value={"light"}):
|
||||
translations = await translation.async_get_translations(
|
||||
hass, "en", "title", None, True
|
||||
)
|
||||
assert "component.light.title" in translations
|
||||
|
||||
translations = await translation.async_get_translations(
|
||||
hass, "en", "device_automation", None, True
|
||||
)
|
||||
assert "component.light.device_automation.action_type.turn_on" in translations
|
||||
|
|
Loading…
Reference in New Issue