mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Make some conditions translatable (#17234)
This commit is contained in:
parent
67441a63b4
commit
3f05712c18
@ -26,6 +26,8 @@ import { FrontendLocaleData } from "./translation";
|
|||||||
|
|
||||||
const triggerTranslationBaseKey =
|
const triggerTranslationBaseKey =
|
||||||
"ui.panel.config.automation.editor.triggers.type";
|
"ui.panel.config.automation.editor.triggers.type";
|
||||||
|
const conditionsTranslationBaseKey =
|
||||||
|
"ui.panel.config.automation.editor.conditions.type";
|
||||||
|
|
||||||
const describeDuration = (forTime: number | string | ForDict) => {
|
const describeDuration = (forTime: number | string | ForDict) => {
|
||||||
let duration: string | null;
|
let duration: string | null;
|
||||||
@ -714,34 +716,53 @@ const tryDescribeCondition = (
|
|||||||
const conditions = ensureArray(condition.conditions);
|
const conditions = ensureArray(condition.conditions);
|
||||||
|
|
||||||
if (!conditions || conditions.length === 0) {
|
if (!conditions || conditions.length === 0) {
|
||||||
return "Test if any condition matches";
|
return hass.localize(
|
||||||
|
`${conditionsTranslationBaseKey}.or.description.no_conditions`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const count = conditions.length;
|
const count = conditions.length;
|
||||||
return `Test if any of ${count} condition${count === 1 ? "" : "s"} matches`;
|
return hass.localize(
|
||||||
|
`${conditionsTranslationBaseKey}.or.description.full`,
|
||||||
|
{
|
||||||
|
count: count,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (condition.condition === "and") {
|
if (condition.condition === "and") {
|
||||||
const conditions = ensureArray(condition.conditions);
|
const conditions = ensureArray(condition.conditions);
|
||||||
|
|
||||||
if (!conditions || conditions.length === 0) {
|
if (!conditions || conditions.length === 0) {
|
||||||
return "Test if multiple conditions match";
|
return hass.localize(
|
||||||
|
`${conditionsTranslationBaseKey}.and.description.no_conditions`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const count = conditions.length;
|
const count = conditions.length;
|
||||||
return `Test if ${count} condition${count === 1 ? "" : "s"} match${
|
return hass.localize(
|
||||||
count === 1 ? "es" : ""
|
`${conditionsTranslationBaseKey}.and.description.full`,
|
||||||
}`;
|
{
|
||||||
|
count: count,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (condition.condition === "not") {
|
if (condition.condition === "not") {
|
||||||
const conditions = ensureArray(condition.conditions);
|
const conditions = ensureArray(condition.conditions);
|
||||||
|
|
||||||
if (!conditions || conditions.length === 0) {
|
if (!conditions || conditions.length === 0) {
|
||||||
return "Test if no condition matches";
|
return hass.localize(
|
||||||
|
`${conditionsTranslationBaseKey}.not.description.no_conditions`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (conditions.length === 1) {
|
if (conditions.length === 1) {
|
||||||
return "Test if 1 condition does not match";
|
return hass.localize(
|
||||||
|
`${conditionsTranslationBaseKey}.not.description.one_condition`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return `Test if none of ${conditions.length} conditions match`;
|
return hass.localize(
|
||||||
|
`${conditionsTranslationBaseKey}.not.description.full`,
|
||||||
|
{ count: conditions.length }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// State Condition
|
// State Condition
|
||||||
@ -1018,9 +1039,15 @@ const tryDescribeCondition = (
|
|||||||
|
|
||||||
const entitiesString = disjunctionFormatter.format(entities);
|
const entitiesString = disjunctionFormatter.format(entities);
|
||||||
const zonesString = disjunctionFormatter.format(zones);
|
const zonesString = disjunctionFormatter.format(zones);
|
||||||
return `Confirm ${entitiesString} ${
|
return hass.localize(
|
||||||
entities.length > 1 ? "are" : "is"
|
`${conditionsTranslationBaseKey}.zone.description.full`,
|
||||||
} in ${zonesString} ${zones.length > 1 ? "zones" : "zone"}`;
|
{
|
||||||
|
entity: entitiesString,
|
||||||
|
numberOfEntities: entities.length,
|
||||||
|
zone: zonesString,
|
||||||
|
numberOfZones: zones.length,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (condition.condition === "device") {
|
if (condition.condition === "device") {
|
||||||
|
@ -2504,7 +2504,11 @@
|
|||||||
"type_select": "Condition type",
|
"type_select": "Condition type",
|
||||||
"type": {
|
"type": {
|
||||||
"and": {
|
"and": {
|
||||||
"label": "And"
|
"label": "And",
|
||||||
|
"description": {
|
||||||
|
"no_conditions": "Test if multiple conditions match",
|
||||||
|
"full": "Test if any of {count} {count, plural,\n one {condition match}\n other {conditions matches}\n}"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"device": {
|
"device": {
|
||||||
"label": "Device",
|
"label": "Device",
|
||||||
@ -2518,7 +2522,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"not": {
|
"not": {
|
||||||
"label": "Not"
|
"label": "Not",
|
||||||
|
"description": {
|
||||||
|
"no_conditions": "Test if no condition matches",
|
||||||
|
"one_condition": "Test if 1 condition does not match",
|
||||||
|
"full": "Test if none of {count} conditions match"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"numeric_state": {
|
"numeric_state": {
|
||||||
"type_value": "[%key:ui::panel::config::automation::editor::triggers::type::numeric_state::type_value%]",
|
"type_value": "[%key:ui::panel::config::automation::editor::triggers::type::numeric_state::type_value%]",
|
||||||
@ -2531,7 +2540,11 @@
|
|||||||
"value_template": "[%key:ui::panel::config::automation::editor::triggers::type::numeric_state::value_template%]"
|
"value_template": "[%key:ui::panel::config::automation::editor::triggers::type::numeric_state::value_template%]"
|
||||||
},
|
},
|
||||||
"or": {
|
"or": {
|
||||||
"label": "Or"
|
"label": "Or",
|
||||||
|
"description": {
|
||||||
|
"no_conditions": "Test if any condition matches",
|
||||||
|
"full": "Test if any of {count} {count, plural,\n one {condition}\n other {conditions}\n} matches"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
"label": "[%key:ui::panel::config::automation::editor::triggers::type::state::label%]",
|
"label": "[%key:ui::panel::config::automation::editor::triggers::type::state::label%]",
|
||||||
@ -2577,7 +2590,10 @@
|
|||||||
"zone": {
|
"zone": {
|
||||||
"label": "[%key:ui::panel::config::automation::editor::triggers::type::zone::label%]",
|
"label": "[%key:ui::panel::config::automation::editor::triggers::type::zone::label%]",
|
||||||
"entity": "[%key:ui::panel::config::automation::editor::triggers::type::zone::entity%]",
|
"entity": "[%key:ui::panel::config::automation::editor::triggers::type::zone::entity%]",
|
||||||
"zone": "[%key:ui::panel::config::automation::editor::triggers::type::zone::label%]"
|
"zone": "[%key:ui::panel::config::automation::editor::triggers::type::zone::label%]",
|
||||||
|
"description": {
|
||||||
|
"full": "Confirm {entity} {numberOfEntities, plural,\n one {is}\n other {are}\n} in {zone} {numberOfZones, plural,\n one {zone} \n other {zones}\n} "
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user