1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-27 12:14:35 +01:00

Add support for placeholders in entity name translations (#104453)

* add placeholder support to entity name translation

* add negativ tests

* make property also available via description

* fix doc string in translation_placeholders()

* fix detection of placeholder

* validate placeholders for localized strings

* add test

* Cache translation_placeholders property

* Make translation_placeholders uncondotionally return dict

* Fall back to unsubstituted name in case of mismatch

* Only replace failing translations with English

* Update snapshots

* Blow up on non stable releases

* Fix test

* Update entity.py

---------

Co-authored-by: Erik <erik@montnemery.com>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
Michael
2024-01-03 17:34:47 +01:00
committed by GitHub
parent d071299233
commit eb01998395
8 changed files with 425 additions and 24 deletions

View File

@@ -0,0 +1,10 @@
{
"entity": {
"switch": {
"other1": { "name": "Anderes 1" },
"other2": { "name": "Anderes 2 {placeholder}" },
"other3": { "name": "" },
"outlet": { "name": "Steckdose {something}" }
}
}
}

View File

@@ -0,0 +1,11 @@
{
"entity": {
"switch": {
"other1": { "name": "Other 1" },
"other2": { "name": "Other 2" },
"other3": { "name": "Other 3" },
"other4": { "name": "Other 4" },
"outlet": { "name": "Outlet {placeholder}" }
}
}
}

View File

@@ -0,0 +1,11 @@
{
"entity": {
"switch": {
"other1": { "name": "Otra 1" },
"other2": { "name": "Otra 2" },
"other3": { "name": "Otra 3" },
"other4": { "name": "Otra 4" },
"outlet": { "name": "Enchufe {placeholder}" }
}
}
}