From df1d703e4e731db5c1a4bd25f11cf4e4cce6a7d9 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Sat, 29 Jan 2022 09:46:32 +0100 Subject: [PATCH] Adjust device translations to handle device vs service consistently (#11472) --- src/data/device_registry.ts | 8 +- .../config/areas/ha-config-area-page.ts | 6 +- .../device-detail/ha-device-info-card.ts | 10 ++- .../dialog-device-registry-detail.ts | 16 +++- .../config/devices/ha-config-device-page.ts | 76 ++++++++++++++++--- src/translations/en.json | 41 +++++----- 6 files changed, 125 insertions(+), 32 deletions(-) diff --git a/src/data/device_registry.ts b/src/data/device_registry.ts index b2610c109c..65c0bcec56 100644 --- a/src/data/device_registry.ts +++ b/src/data/device_registry.ts @@ -55,7 +55,13 @@ export const computeDeviceName = ( device.name_by_user || device.name || (entities && fallbackDeviceName(hass, entities)) || - hass.localize("ui.panel.config.devices.unnamed_device"); + hass.localize( + "ui.panel.config.devices.unnamed_device", + "type", + hass.localize( + `ui.panel.config.devices.type.${device.entry_type || "device"}` + ) + ); export const devicesInArea = (devices: DeviceRegistryEntry[], areaId: string) => devices.filter((device) => device.area_id === areaId); diff --git a/src/panels/config/areas/ha-config-area-page.ts b/src/panels/config/areas/ha-config-area-page.ts index 0a971181cb..dfb038e375 100644 --- a/src/panels/config/areas/ha-config-area-page.ts +++ b/src/panels/config/areas/ha-config-area-page.ts @@ -315,7 +315,7 @@ class HaConfigAreaPage extends LitElement { ? html` ${groupedAutomations?.length @@ -362,7 +362,7 @@ class HaConfigAreaPage extends LitElement { ? html` ${groupedScenes?.length @@ -401,7 +401,7 @@ class HaConfigAreaPage extends LitElement { ? html` ${groupedScripts?.length diff --git a/src/panels/config/devices/device-detail/ha-device-info-card.ts b/src/panels/config/devices/device-detail/ha-device-info-card.ts index c2541397a3..19176d0fbe 100644 --- a/src/panels/config/devices/device-detail/ha-device-info-card.ts +++ b/src/panels/config/devices/device-detail/ha-device-info-card.ts @@ -23,7 +23,15 @@ export class HaDeviceCard extends LitElement { protected render(): TemplateResult { return html`
${this.device.model diff --git a/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts b/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts index 8ad148eef4..677820ce12 100644 --- a/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts +++ b/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts @@ -82,12 +82,26 @@ class DialogDeviceRegistryDetail extends LitElement {
- ${this.hass.localize("ui.panel.config.devices.enabled_label")} + ${this.hass.localize( + "ui.panel.config.devices.enabled_label", + "type", + this.hass.localize( + `ui.panel.config.devices.type.${ + device.entry_type || "device" + }` + ) + )}
${this._disabledBy && this._disabledBy !== "user" ? this.hass.localize( "ui.panel.config.devices.enabled_cause", + "type", + this.hass.localize( + `ui.panel.config.devices.type.${ + device.entry_type || "device" + }` + ), "cause", this.hass.localize( `config_entry.disabled_by.${this._disabledBy}` diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts index 935c305cc7..9d2d4bfcdd 100644 --- a/src/panels/config/devices/ha-config-device-page.ts +++ b/src/panels/config/devices/ha-config-device-page.ts @@ -296,6 +296,10 @@ export class HaConfigDevicePage extends LitElement { ${this.hass.localize( "ui.panel.config.devices.enabled_cause", + "type", + this.hass.localize( + `ui.panel.config.devices.type.${device.entry_type || "device"}` + ), "cause", this.hass.localize( `ui.panel.config.devices.disabled_by.${device.disabled_by}` @@ -485,17 +489,29 @@ export class HaConfigDevicePage extends LitElement {

${this.hass.localize( - "ui.panel.config.devices.automation.automations" + "ui.panel.config.devices.automation.automations_heading" )} @@ -547,6 +563,12 @@ export class HaConfigDevicePage extends LitElement { "name", this.hass.localize( "ui.panel.config.devices.automation.automations" + ), + "type", + this.hass.localize( + `ui.panel.config.devices.type.${ + device.entry_type || "device" + }` ) )}

@@ -561,7 +583,7 @@ export class HaConfigDevicePage extends LitElement {

${this.hass.localize( - "ui.panel.config.devices.scene.scenes" + "ui.panel.config.devices.scene.scenes_heading" )} @@ -627,6 +661,12 @@ export class HaConfigDevicePage extends LitElement { "name", this.hass.localize( "ui.panel.config.devices.scene.scenes" + ), + "type", + this.hass.localize( + `ui.panel.config.devices.type.${ + device.entry_type || "device" + }` ) )}

@@ -641,17 +681,29 @@ export class HaConfigDevicePage extends LitElement {

${this.hass.localize( - "ui.panel.config.devices.script.scripts" + "ui.panel.config.devices.script.scripts_heading" )} @@ -685,6 +737,12 @@ export class HaConfigDevicePage extends LitElement { "name", this.hass.localize( "ui.panel.config.devices.script.scripts" + ), + "type", + this.hass.localize( + `ui.panel.config.devices.type.${ + device.entry_type || "device" + }` ) )}

diff --git a/src/translations/en.json b/src/translations/en.json index 1e40968ce6..b5963241f0 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2207,18 +2207,18 @@ } }, "devices": { - "add_prompt": "No {name} have been added using this device yet. You can add one by clicking the + button above.", + "add_prompt": "No {name} have been added using this {type} yet. You can add one by clicking the + button above.", "caption": "Devices", "description": "Manage configured devices", - "device_info": "Device info", + "device_info": "{type} info", "edit_settings": "Edit settings", - "unnamed_device": "Unnamed device", + "unnamed_device": "Unnamed {type}", "unknown_error": "Unknown error", "name": "Name", "update": "Update", "no_devices": "No devices", - "enabled_label": "Enable device", - "enabled_cause": "The device is disabled by {cause}.", + "enabled_label": "Enable {type}", + "enabled_cause": "The {type} is disabled by {cause}.", "disabled_by": { "user": "User", "integration": "Integration", @@ -2228,12 +2228,19 @@ "open_configuration_url_device": "Visit device", "open_configuration_url_service": "Visit service", "download_diagnostics": "Download diagnostics", + "type": { + "device_heading": "Device", + "device": "device", + "service_heading": "Service", + "service": "service" + }, "automation": { - "automations": "Automations", + "automations_heading": "Automations", + "automations": "automations", "no_automations": "No automations", "unknown_automation": "Unknown automation", - "create": "Create automation with device", - "create_disable": "Can't create automation with disabled device", + "create": "Create automation with {type}", + "create_disable": "Can't create automation with disabled {type}", "triggers": { "caption": "Do something when…", "no_triggers": "No triggers", @@ -2252,19 +2259,21 @@ "no_device_automations": "There are no automations available for this device." }, "script": { - "scripts": "Scripts", + "scripts_heading": "Scripts", + "scripts": "scripts", "no_scripts": "No scripts", - "create": "Create script with device", - "create_disable": "Can't create script with disabled device" + "create": "Create script with {type}", + "create_disable": "Can't create script with disabled {type}" }, "scene": { - "scenes": "Scenes", + "scenes_heading": "Scenes", + "scenes": "scenes", "no_scenes": "No scenes", - "create": "Create scene with device", - "create_disable": "Can't create scene with disabled device" + "create": "Create scene with {type}", + "create_disable": "Can't create scene with disabled {type}" }, "cant_edit": "You can only edit items that are created in the UI.", - "device_not_found": "Device not found.", + "device_not_found": "Device / service not found.", "entities": { "entities": "Entities", "control": "Controls", @@ -2276,8 +2285,6 @@ "hide_disabled": "Hide disabled", "disabled_entities": "+{count} {count, plural,\n one {disabled entity}\n other {disabled entities}\n}" }, - "scripts": "Scripts", - "scenes": "Scenes", "confirm_rename_entity_ids": "Do you also want to rename the entity IDs of your entities?", "confirm_rename_entity_ids_warning": "This will not change any configuration (like automations, scripts, scenes, dashboards) that is currently using these entities! You will have to update them yourself to use the new entity IDs!", "confirm_disable_config_entry": "There are no more devices for the config entry {entry_name}, do you want to instead disable the config entry?",