Fix loading translations for embedded platforms (#20122)
* Fix loading translations for embedded platforms * Update doc string * Lint
This commit is contained in:
1 parent
cd6679eb5b
commit
9fd21d20ae
4 files changed
+64
-16
No files matched your search
@@ -40,7 +40,10 @@ def test_flatten():
|
||||
async def test_component_translation_file(hass):
|
||||
"""Test the component translation file function."""
|
||||
assert await async_setup_component(hass, 'switch', {
|
||||
'switch': {'platform': 'test'}
|
||||
'switch': [
|
||||
{'platform': 'test'},
|
||||
{'platform': 'test_embedded'}
|
||||
]
|
||||
})
|
||||
assert await async_setup_component(hass, 'test_standalone', {
|
||||
'test_standalone'
|
||||
@@ -53,6 +56,11 @@ async def test_component_translation_file(hass):
|
||||
hass, 'switch.test', 'en')) == path.normpath(hass.config.path(
|
||||
'custom_components', 'switch', '.translations', 'test.en.json'))
|
||||
|
||||
assert path.normpath(translation.component_translation_file(
|
||||
hass, 'switch.test_embedded', 'en')) == path.normpath(hass.config.path(
|
||||
'custom_components', 'test_embedded', '.translations',
|
||||
'switch.en.json'))
|
||||
|
||||
assert path.normpath(translation.component_translation_file(
|
||||
hass, 'test_standalone', 'en')) == path.normpath(hass.config.path(
|
||||
'custom_components', '.translations', 'test_standalone.en.json'))
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
"""Component with embedded platforms."""
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
"""Mock config."""
|
||||
return True
|
||||
@@ -0,0 +1,7 @@
|
||||
"""Switch platform for the embedded component."""
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities_callback,
|
||||
discovery_info=None):
|
||||
"""Find and return test switches."""
|
||||
pass
|
||||
Reference in new issue
Block a user