Adjust device translations to handle device vs service consistently (#11472)

This commit is contained in:
Philip Allgaier 2022-01-29 09:46:32 +01:00 committed by GitHub
parent ce0ced0b6a
commit df1d703e4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 125 additions and 32 deletions

View File

@ -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);

View File

@ -315,7 +315,7 @@ class HaConfigAreaPage extends LitElement {
? html`
<ha-card
.header=${this.hass.localize(
"ui.panel.config.devices.automation.automations"
"ui.panel.config.devices.automation.automations_heading"
)}
>
${groupedAutomations?.length
@ -362,7 +362,7 @@ class HaConfigAreaPage extends LitElement {
? html`
<ha-card
.header=${this.hass.localize(
"ui.panel.config.devices.scene.scenes"
"ui.panel.config.devices.scene.scenes_heading"
)}
>
${groupedScenes?.length
@ -401,7 +401,7 @@ class HaConfigAreaPage extends LitElement {
? html`
<ha-card
.header=${this.hass.localize(
"ui.panel.config.devices.script.scripts"
"ui.panel.config.devices.script.scripts_heading"
)}
>
${groupedScripts?.length

View File

@ -23,7 +23,15 @@ export class HaDeviceCard extends LitElement {
protected render(): TemplateResult {
return html`
<ha-card
.header=${this.hass.localize("ui.panel.config.devices.device_info")}
.header=${this.hass.localize(
"ui.panel.config.devices.device_info",
"type",
this.hass.localize(
`ui.panel.config.devices.type.${
this.device.entry_type || "device"
}_heading`
)
)}
>
<div class="card-content">
${this.device.model

View File

@ -82,12 +82,26 @@ class DialogDeviceRegistryDetail extends LitElement {
</ha-switch>
<div>
<div>
${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"
}`
)
)}
</div>
<div class="secondary">
${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}`

View File

@ -296,6 +296,10 @@ export class HaConfigDevicePage extends LitElement {
<ha-alert alert-type="warning">
${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 {
<ha-card>
<h1 class="card-header">
${this.hass.localize(
"ui.panel.config.devices.automation.automations"
"ui.panel.config.devices.automation.automations_heading"
)}
<ha-icon-button
@click=${this._showAutomationDialog}
.disabled=${device.disabled_by}
.label=${device.disabled_by
? this.hass.localize(
"ui.panel.config.devices.automation.create_disabled"
"ui.panel.config.devices.automation.create_disabled",
"type",
this.hass.localize(
`ui.panel.config.devices.type.${
device.entry_type || "device"
}`
)
)
: this.hass.localize(
"ui.panel.config.devices.automation.create"
"ui.panel.config.devices.automation.create",
"type",
this.hass.localize(
`ui.panel.config.devices.type.${
device.entry_type || "device"
}`
)
)}
.path=${mdiPlusCircle}
></ha-icon-button>
@ -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"
}`
)
)}
</div>
@ -561,7 +583,7 @@ export class HaConfigDevicePage extends LitElement {
<ha-card>
<h1 class="card-header">
${this.hass.localize(
"ui.panel.config.devices.scene.scenes"
"ui.panel.config.devices.scene.scenes_heading"
)}
<ha-icon-button
@ -569,10 +591,22 @@ export class HaConfigDevicePage extends LitElement {
.disabled=${device.disabled_by}
.label=${device.disabled_by
? this.hass.localize(
"ui.panel.config.devices.scene.create_disabled"
"ui.panel.config.devices.scene.create_disabled",
"type",
this.hass.localize(
`ui.panel.config.devices.type.${
device.entry_type || "device"
}`
)
)
: this.hass.localize(
"ui.panel.config.devices.scene.create"
"ui.panel.config.devices.scene.create",
"type",
this.hass.localize(
`ui.panel.config.devices.type.${
device.entry_type || "device"
}`
)
)}
.path=${mdiPlusCircle}
></ha-icon-button>
@ -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"
}`
)
)}
</div>
@ -641,17 +681,29 @@ export class HaConfigDevicePage extends LitElement {
<ha-card>
<h1 class="card-header">
${this.hass.localize(
"ui.panel.config.devices.script.scripts"
"ui.panel.config.devices.script.scripts_heading"
)}
<ha-icon-button
@click=${this._showScriptDialog}
.disabled=${device.disabled_by}
.label=${device.disabled_by
? this.hass.localize(
"ui.panel.config.devices.script.create_disabled"
"ui.panel.config.devices.script.create_disabled",
"type",
this.hass.localize(
`ui.panel.config.devices.type.${
device.entry_type || "device"
}`
)
)
: this.hass.localize(
"ui.panel.config.devices.script.create"
"ui.panel.config.devices.script.create",
"type",
this.hass.localize(
`ui.panel.config.devices.type.${
device.entry_type || "device"
}`
)
)}
.path=${mdiPlusCircle}
></ha-icon-button>
@ -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"
}`
)
)}
</div>

View File

@ -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?",