mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 00:36:34 +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);
|
: localizeTimeString(condition.after, hass.locale, hass.config);
|
||||||
|
|
||||||
let result = "Confirm the ";
|
let localizedDays: string[] = [];
|
||||||
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 ";
|
|
||||||
}
|
|
||||||
if (validWeekdays) {
|
if (validWeekdays) {
|
||||||
const localizedDays = weekdaysArray.map((d) =>
|
localizedDays = weekdaysArray.map((d) =>
|
||||||
hass.localize(
|
hass.localize(
|
||||||
`ui.panel.config.automation.editor.conditions.type.time.weekdays.${d}`
|
`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",
|
"fri": "Friday",
|
||||||
"sat": "Saturday",
|
"sat": "Saturday",
|
||||||
"sun": "Sunday"
|
"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": {
|
"trigger": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user