mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-10 00:39:22 -06:00
Allow adding translations for nested fields to support home-assistant/frontend#26997 (#6180)
This commit is contained in:
parent
d2ddd9579c
commit
857dae7736
@ -32,6 +32,7 @@ from ..const import (
|
||||
ATTR_DISCOVERY,
|
||||
ATTR_DOCKER_API,
|
||||
ATTR_ENVIRONMENT,
|
||||
ATTR_FIELDS,
|
||||
ATTR_FULL_ACCESS,
|
||||
ATTR_GPIO,
|
||||
ATTR_HASSIO_API,
|
||||
@ -454,6 +455,7 @@ SCHEMA_TRANSLATION_CONFIGURATION = vol.Schema(
|
||||
{
|
||||
vol.Required(ATTR_NAME): str,
|
||||
vol.Optional(ATTR_DESCRIPTON): vol.Maybe(str),
|
||||
vol.Optional(ATTR_FIELDS): {str: vol.Self},
|
||||
},
|
||||
extra=vol.REMOVE_EXTRA,
|
||||
)
|
||||
|
||||
@ -189,6 +189,7 @@ ATTR_EVENT = "event"
|
||||
ATTR_EXCLUDE_DATABASE = "exclude_database"
|
||||
ATTR_EXTRA = "extra"
|
||||
ATTR_FEATURES = "features"
|
||||
ATTR_FIELDS = "fields"
|
||||
ATTR_FILENAME = "filename"
|
||||
ATTR_FLAGS = "flags"
|
||||
ATTR_FOLDERS = "folders"
|
||||
|
||||
@ -20,7 +20,16 @@ def test_loading_traslations(coresys: CoreSys, tmp_path: Path):
|
||||
for file in ("en.json", "es.json"):
|
||||
write_json_or_yaml_file(
|
||||
tmp_path / "translations" / file,
|
||||
{"configuration": {"test": {"name": "test", "test": "test"}}},
|
||||
{
|
||||
"configuration": {
|
||||
"test": {
|
||||
"name": "test",
|
||||
"description": "test",
|
||||
"test": "test",
|
||||
"fields": {"test2": {"name": "test2"}},
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
for file in ("no.yaml", "de.yaml"):
|
||||
@ -39,6 +48,18 @@ def test_loading_traslations(coresys: CoreSys, tmp_path: Path):
|
||||
assert translations["no"]["configuration"]["test"]["name"] == "test"
|
||||
assert translations["de"]["configuration"]["test"]["name"] == "test"
|
||||
|
||||
assert translations["en"]["configuration"]["test"]["description"] == "test"
|
||||
assert translations["es"]["configuration"]["test"]["description"] == "test"
|
||||
|
||||
assert (
|
||||
translations["en"]["configuration"]["test"]["fields"]["test2"]["name"]
|
||||
== "test2"
|
||||
)
|
||||
assert (
|
||||
translations["es"]["configuration"]["test"]["fields"]["test2"]["name"]
|
||||
== "test2"
|
||||
)
|
||||
|
||||
assert "test" not in translations["en"]["configuration"]["test"]
|
||||
|
||||
assert translations["no"]["network"]["80/tcp"] == "Webserver port"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user