mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Fix translations merging (#34417)
Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
e5a861dc90
commit
d10f5a48d4
@ -104,12 +104,15 @@ def build_resources(
|
|||||||
domain_resources.update(translation_cache[component])
|
domain_resources.update(translation_cache[component])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if category not in translation_cache[component]:
|
new_value = translation_cache[component].get(category)
|
||||||
|
|
||||||
|
if new_value is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
domain_resources.setdefault(category, {}).update(
|
if isinstance(new_value, dict):
|
||||||
translation_cache[component][category]
|
domain_resources.setdefault(category, {}).update(new_value)
|
||||||
)
|
else:
|
||||||
|
domain_resources[category] = new_value
|
||||||
|
|
||||||
return {"component": resources}
|
return {"component": resources}
|
||||||
|
|
||||||
|
@ -192,3 +192,17 @@ async def test_get_translations_while_loading_components(hass):
|
|||||||
"component.component1.title": "Component 1",
|
"component.component1.title": "Component 1",
|
||||||
"component.component1.hello": "world",
|
"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…
x
Reference in New Issue
Block a user