refactor(i18n): drop the vestigial descriptor name field
Since entity.py started routing named descriptors through the catalog under desc.key, SamsungEntityDescription.name has been read for its value nowhere -- only twice as a flag, to decide whether an entity was translated at all. That left 148 English names duplicated between Python and translations/en.json with nothing keeping them honest: six had already drifted, invisibly, because editing the Python side changes nothing a user sees. So the field is gone, and translation_key defaults to desc.key. A descriptor now sets translation_key only to share one catalog entry across descriptors or to point at a differently-named one, and the catalog is the only place an entity name exists. Every descriptor resolves to exactly the translation key, icon, entity category, enabled-default and gating it did before -- with one deliberate exception: the hood fan, previously the sole descriptor with no key at all, now resolves to 'fan'. That is inert, because fan.py sets _attr_name = None so the entity presents as the device itself. The three helpers that forwarded a name into a descriptor (laundry.bool_option_switch, washer._bool_option_switch, air_purifier's sensor table) lose that parameter. test_translations.py now requires a catalog entry for every descriptor rather than only translated ones. Claude-Session: https://claude.ai/code/session_01GiibJZZLWVvyxq7mc7EDNp
This commit is contained in:
1 parent
6281b40549
commit
10c850f2b9
20 files changed
+241
-267
No files matched your search
@@ -20,9 +20,13 @@ def _make_entity(desc, href='/x/vs/0', key_override=None, instance='', instance_
|
||||
return LocalThingsEntity(_FakeCoordinator(), bound)
|
||||
|
||||
|
||||
def test_explicit_fallback_name_uses_translation_instead_of_attr_name():
|
||||
"""An _attr_name would take precedence over HA's translation catalog."""
|
||||
desc = BinarySensorDesc(key='enabled', name='Explicit name')
|
||||
def test_descriptor_key_is_the_default_translation_key():
|
||||
"""A descriptor names itself through the catalog, keyed by its own key.
|
||||
|
||||
Nothing sets _attr_name: that would take precedence over HA's
|
||||
translation catalog and make the entity untranslatable.
|
||||
"""
|
||||
desc = BinarySensorDesc(key='enabled')
|
||||
entity = _make_entity(desc, instance_name='Cubed Ice')
|
||||
assert entity.translation_key == 'enabled'
|
||||
assert not hasattr(entity, '_attr_name')
|
||||
|
||||
Reference in new issue
Block a user