diff --git a/src/data/automation_i18n.ts b/src/data/automation_i18n.ts index 87023c64f5..86f907b7ab 100644 --- a/src/data/automation_i18n.ts +++ b/src/data/automation_i18n.ts @@ -937,32 +937,35 @@ const tryDescribeCondition = ( }` : localizeTimeString(condition.after, hass.locale, hass.config); - let result = "Confirm the "; - if (after || before) { - result += "time is "; - } - if (after) { - result += "after " + after; - } - if (before && after) { - result += " and "; - } - if (before) { - result += "before " + before; - } - if ((after || before) && validWeekdays) { - result += " and the "; - } + let localizedDays: string[] = []; if (validWeekdays) { - const localizedDays = weekdaysArray.map((d) => + localizedDays = weekdaysArray.map((d) => hass.localize( `ui.panel.config.automation.editor.conditions.type.time.weekdays.${d}` ) ); - result += " day is " + formatListWithOrs(hass.locale, localizedDays); } - return result; + let hasTime = ""; + if (after !== undefined && before !== undefined) { + hasTime = "after_before"; + } else if (after !== undefined) { + hasTime = "after"; + } else if (before !== undefined) { + hasTime = "before"; + } + + return hass.localize( + `${conditionsTranslationBaseKey}.time.description.full`, + { + hasTime: hasTime, + hasTimeAndDay: (after || before) && validWeekdays, + hasDay: validWeekdays, + time_before: before, + time_after: after, + day: formatListWithOrs(hass.locale, localizedDays), + } + ); } } diff --git a/src/translations/en.json b/src/translations/en.json index ca3319bf3b..e5f75b58f4 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2663,6 +2663,9 @@ "fri": "Friday", "sat": "Saturday", "sun": "Sunday" + }, + "description": { + "full": "Confirm the {hasTime, select, \n after {time is after {time_after}}\n before {time is before {time_before}}\n after_before {time is after {time_after} and before {time_before}} \n other {}\n }{hasTimeAndDay, select, \n true { and the }\n other {}\n}{hasDay, select, \n true { day is {day}}\n other {}\n}" } }, "trigger": {