Add translation support to Config Entry errors (#106305)

* Config Entry error translation

* split key and placeholders

* Fix config entries tests

* translation optional

* Mods
This commit is contained in:
G Johansson
2024-03-28 10:52:21 +01:00
committed by GitHub
parent aa9d58df67
commit fc4d960d17
3 changed files with 122 additions and 4 deletions
@@ -131,6 +131,8 @@ async def test_get_entries(hass: HomeAssistant, client, clear_handlers) -> None:
"pref_disable_polling": False,
"disabled_by": None,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
},
{
"domain": "comp2",
@@ -145,6 +147,8 @@ async def test_get_entries(hass: HomeAssistant, client, clear_handlers) -> None:
"pref_disable_polling": False,
"disabled_by": None,
"reason": "Unsupported API",
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
},
{
"domain": "comp3",
@@ -159,6 +163,8 @@ async def test_get_entries(hass: HomeAssistant, client, clear_handlers) -> None:
"pref_disable_polling": False,
"disabled_by": core_ce.ConfigEntryDisabler.USER,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
},
{
"domain": "comp4",
@@ -173,6 +179,8 @@ async def test_get_entries(hass: HomeAssistant, client, clear_handlers) -> None:
"pref_disable_polling": False,
"disabled_by": None,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
},
{
"domain": "comp5",
@@ -187,6 +195,8 @@ async def test_get_entries(hass: HomeAssistant, client, clear_handlers) -> None:
"pref_disable_polling": False,
"disabled_by": None,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
},
]
@@ -536,6 +546,8 @@ async def test_create_account(
"pref_disable_polling": False,
"title": "Test Entry",
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
},
"description": None,
"description_placeholders": None,
@@ -615,6 +627,8 @@ async def test_two_step_flow(
"pref_disable_polling": False,
"title": "user-title",
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
},
"description": None,
"description_placeholders": None,
@@ -1058,6 +1072,8 @@ async def test_get_single(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "user",
"state": "loaded",
"supports_reconfigure": False,
@@ -1393,6 +1409,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1408,6 +1426,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": "Unsupported API",
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla2",
"state": "setup_error",
"supports_reconfigure": False,
@@ -1423,6 +1443,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla3",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1438,6 +1460,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla4",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1453,6 +1477,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla5",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1479,6 +1505,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1504,6 +1532,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla4",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1519,6 +1549,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla5",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1544,6 +1576,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1559,6 +1593,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla3",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1590,6 +1626,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1605,6 +1643,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": "Unsupported API",
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla2",
"state": "setup_error",
"supports_reconfigure": False,
@@ -1620,6 +1660,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla3",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1635,6 +1677,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla4",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1650,6 +1694,8 @@ async def test_get_matching_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla5",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1749,6 +1795,8 @@ async def test_subscribe_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1767,6 +1815,8 @@ async def test_subscribe_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": "Unsupported API",
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla2",
"state": "setup_error",
"supports_reconfigure": False,
@@ -1785,6 +1835,8 @@ async def test_subscribe_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla3",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1807,6 +1859,8 @@ async def test_subscribe_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1830,6 +1884,8 @@ async def test_subscribe_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1853,6 +1909,8 @@ async def test_subscribe_entries_ws(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1935,6 +1993,8 @@ async def test_subscribe_entries_ws_filtered(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1953,6 +2013,8 @@ async def test_subscribe_entries_ws_filtered(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla3",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1977,6 +2039,8 @@ async def test_subscribe_entries_ws_filtered(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -1999,6 +2063,8 @@ async def test_subscribe_entries_ws_filtered(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla3",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -2023,6 +2089,8 @@ async def test_subscribe_entries_ws_filtered(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -2046,6 +2114,8 @@ async def test_subscribe_entries_ws_filtered(
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
"source": "bla",
"state": "not_loaded",
"supports_reconfigure": False,
@@ -2225,6 +2295,8 @@ async def test_supports_reconfigure(
"pref_disable_polling": False,
"title": "Test Entry",
"reason": None,
"error_reason_translation_key": None,
"error_reason_translation_placeholders": None,
},
"description": None,
"description_placeholders": None,
+2
View File
@@ -821,6 +821,8 @@ async def test_as_dict(snapshot: SnapshotAssertion) -> None:
"_setup_lock",
"update_listeners",
"reason",
"error_reason_translation_key",
"error_reason_translation_placeholders",
"_async_cancel_retry_setup",
"_on_unload",
"reload_lock",