mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 00:06:35 +00:00
Make time condition translatable (#18298)
This commit is contained in:
parent
82a464f50f
commit
0ff5bffd0c
@ -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),
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user