diff --git a/src/panels/lovelace/common/compute-tooltip.ts b/src/panels/lovelace/common/compute-tooltip.ts index 87f921319d..f3e77143f2 100644 --- a/src/panels/lovelace/common/compute-tooltip.ts +++ b/src/panels/lovelace/common/compute-tooltip.ts @@ -11,6 +11,10 @@ interface Config extends LovelaceElementConfig { } export const computeTooltip = (hass: HomeAssistant, config: Config): string => { + if (config.title === null) { + return ""; + } + if (config.title) { return config.title; } @@ -26,10 +30,10 @@ export const computeTooltip = (hass: HomeAssistant, config: Config): string => { } const tapTooltip = config.tap_action - ? computeActionTooltip(stateName, config.tap_action, false) + ? computeActionTooltip(hass, stateName, config.tap_action, false) : ""; const holdTooltip = config.hold_action - ? computeActionTooltip(stateName, config.hold_action, true) + ? computeActionTooltip(hass, stateName, config.hold_action, true) : ""; const newline = tapTooltip && holdTooltip ? "\n" : ""; @@ -40,6 +44,7 @@ export const computeTooltip = (hass: HomeAssistant, config: Config): string => { }; function computeActionTooltip( + hass: HomeAssistant, state: string, config: ActionConfig, isHold: boolean @@ -48,20 +53,39 @@ function computeActionTooltip( return ""; } - let tooltip = isHold ? "Hold: " : "Tap: "; + let tooltip = + (isHold + ? hass.localize("ui.panel.lovelace.cards.picture-elements.hold") + : hass.localize("ui.panel.lovelace.cards.picture-elements.tap")) + " "; switch (config.action) { case "navigate": - tooltip += `Navigate to ${config.navigation_path}`; + tooltip += `${hass.localize( + "ui.panel.lovelace.cards.picture-elements.navigate_to", + "location", + config.navigation_path + )}`; break; case "toggle": - tooltip += `Toggle ${state}`; + tooltip += `${hass.localize( + "ui.panel.lovelace.cards.picture-elements.toggle", + "name", + state + )}`; break; case "call-service": - tooltip += `Call service ${config.service}`; + tooltip += `${hass.localize( + "ui.panel.lovelace.cards.picture-elements.call_service", + "name", + config.service + )}`; break; case "more-info": - tooltip += `Show more-info: ${state}`; + tooltip += `${hass.localize( + "ui.panel.lovelace.cards.picture-elements.more_info", + "name", + state + )}`; break; } diff --git a/src/translations/en.json b/src/translations/en.json index 477b3e9f62..fe58a46fdc 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -916,6 +916,14 @@ "checked_items": "Checked items", "clear_items": "Clear checked items", "add_item": "Add item" + }, + "picture-elements": { + "hold": "Hold:", + "tap": "Tap:", + "navigate_to": "Navigate to {location}", + "toggle": "Toggle {name}", + "call_service": "Call service {name}", + "more_info": "Show more-info: {name}" } }, "menu": {