Localize ZHA visualization text (#25543)

pull/25556/head
Petar Petrov 2025-05-21 15:54:38 +03:00 committed by GitHub
parent 87bd039239
commit 754829a836
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 37 additions and 13 deletions

View File

@ -33,7 +33,11 @@ export class ZHANetworkVisualizationPage extends LitElement {
@property({ attribute: "is-wide", type: Boolean }) public isWide = false; @property({ attribute: "is-wide", type: Boolean }) public isWide = false;
@state() @state()
private _networkData?: NetworkData; private _networkData: NetworkData = {
nodes: [],
links: [],
categories: [],
};
@state() @state()
private _devices: ZHADevice[] = []; private _devices: ZHADevice[] = [];
@ -85,15 +89,15 @@ export class ZHANetworkVisualizationPage extends LitElement {
const { dataType, data, name } = params as CallbackDataParams; const { dataType, data, name } = params as CallbackDataParams;
if (dataType === "edge") { if (dataType === "edge") {
const { source, target, value } = data as any; const { source, target, value } = data as any;
const targetName = this._networkData!.nodes.find( const targetName = this._networkData.nodes.find(
(node) => node.id === target (node) => node.id === target
)!.name; )!.name;
const sourceName = this._networkData!.nodes.find( const sourceName = this._networkData.nodes.find(
(node) => node.id === source (node) => node.id === source
)!.name; )!.name;
const tooltipText = `${sourceName}${targetName}${value ? ` <b>LQI:</b> ${value}` : ""}`; const tooltipText = `${sourceName}${targetName}${value ? ` <b>LQI:</b> ${value}` : ""}`;
const reverseValue = this._networkData!.links.find( const reverseValue = this._networkData.links.find(
(link) => link.source === source && link.target === target (link) => link.source === source && link.target === target
)?.reverseValue; )?.reverseValue;
if (reverseValue) { if (reverseValue) {
@ -106,19 +110,19 @@ export class ZHANetworkVisualizationPage extends LitElement {
return name; return name;
} }
let label = `<b>IEEE: </b>${device.ieee}`; let label = `<b>IEEE: </b>${device.ieee}`;
label += `<br><b>Device Type: </b>${device.device_type.replace("_", " ")}`; label += `<br><b>${this.hass.localize("ui.panel.config.zha.visualization.device_type")}: </b>${device.device_type.replace("_", " ")}`;
if (device.nwk != null) { if (device.nwk != null) {
label += `<br><b>NWK: </b>${formatAsPaddedHex(device.nwk)}`; label += `<br><b>NWK: </b>${formatAsPaddedHex(device.nwk)}`;
} }
if (device.manufacturer != null && device.model != null) { if (device.manufacturer != null && device.model != null) {
label += `<br><b>Device: </b>${device.manufacturer} ${device.model}`; label += `<br><b>${this.hass.localize("ui.panel.config.zha.visualization.device")}: </b>${device.manufacturer} ${device.model}`;
} else { } else {
label += "<br><b>Device is not in <i>'zigbee.db'</i></b>"; label += `<br><b>${this.hass.localize("ui.panel.config.zha.visualization.device_not_in_db")}</b>`;
} }
if (device.area_id) { if (device.area_id) {
const area = this.hass.areas[device.area_id]; const area = this.hass.areas[device.area_id];
if (area) { if (area) {
label += `<br><b>Area: </b>${area.name}`; label += `<br><b>${this.hass.localize("ui.panel.config.zha.visualization.area")}: </b>${area.name}`;
} }
} }
return label; return label;
@ -161,17 +165,29 @@ export class ZHANetworkVisualizationPage extends LitElement {
const links: NetworkLink[] = []; const links: NetworkLink[] = [];
const categories = [ const categories = [
{ {
name: "Coordinator", name: this.hass.localize(
"ui.panel.config.zha.visualization.coordinator"
),
symbol: "roundRect", symbol: "roundRect",
itemStyle: { color: primaryColor }, itemStyle: { color: primaryColor },
}, },
{ name: "Router", symbol: "circle", itemStyle: { color: routerColor } },
{ {
name: "End Device", name: this.hass.localize("ui.panel.config.zha.visualization.router"),
symbol: "circle",
itemStyle: { color: routerColor },
},
{
name: this.hass.localize(
"ui.panel.config.zha.visualization.end_device"
),
symbol: "circle", symbol: "circle",
itemStyle: { color: endDeviceColor }, itemStyle: { color: endDeviceColor },
}, },
{ name: "Offline", symbol: "circle", itemStyle: { color: offlineColor } }, {
name: this.hass.localize("ui.panel.config.zha.visualization.offline"),
symbol: "circle",
itemStyle: { color: offlineColor },
},
]; ];
// Create all the nodes and links // Create all the nodes and links

View File

@ -5705,7 +5705,15 @@
"visualization": { "visualization": {
"header": "Network visualization", "header": "Network visualization",
"caption": "Visualization", "caption": "Visualization",
"refresh_topology": "Refresh topology" "refresh_topology": "Refresh topology",
"device": "Device",
"device_type": "Device type",
"device_not_in_db": "Device is not in 'zigbee.db'",
"area": "Area",
"coordinator": "Coordinator",
"router": "Router",
"end_device": "End device",
"offline": "Offline"
}, },
"device_binding": { "device_binding": {
"bind": "Bind", "bind": "Bind",