mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Add translation support for select selectors of integration integration
config flow (#86212)
* Translation support method * Translation support time unit * Remove redundant labels
This commit is contained in:
parent
1b4fda2321
commit
1b1f8a1d61
@ -33,15 +33,15 @@ UNIT_PREFIXES = [
|
|||||||
selector.SelectOptionDict(value="T", label="T (tera)"),
|
selector.SelectOptionDict(value="T", label="T (tera)"),
|
||||||
]
|
]
|
||||||
TIME_UNITS = [
|
TIME_UNITS = [
|
||||||
selector.SelectOptionDict(value=UnitOfTime.SECONDS, label="s (seconds)"),
|
UnitOfTime.SECONDS,
|
||||||
selector.SelectOptionDict(value=UnitOfTime.MINUTES, label="min (minutes)"),
|
UnitOfTime.MINUTES,
|
||||||
selector.SelectOptionDict(value=UnitOfTime.HOURS, label="h (hours)"),
|
UnitOfTime.HOURS,
|
||||||
selector.SelectOptionDict(value=UnitOfTime.DAYS, label="d (days)"),
|
UnitOfTime.DAYS,
|
||||||
]
|
]
|
||||||
INTEGRATION_METHODS = [
|
INTEGRATION_METHODS = [
|
||||||
selector.SelectOptionDict(value=METHOD_TRAPEZOIDAL, label="Trapezoidal rule"),
|
METHOD_TRAPEZOIDAL,
|
||||||
selector.SelectOptionDict(value=METHOD_LEFT, label="Left Riemann sum"),
|
METHOD_LEFT,
|
||||||
selector.SelectOptionDict(value=METHOD_RIGHT, label="Right Riemann sum"),
|
METHOD_RIGHT,
|
||||||
]
|
]
|
||||||
|
|
||||||
OPTIONS_SCHEMA = vol.Schema(
|
OPTIONS_SCHEMA = vol.Schema(
|
||||||
@ -61,7 +61,9 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
selector.EntitySelectorConfig(domain=SENSOR_DOMAIN)
|
selector.EntitySelectorConfig(domain=SENSOR_DOMAIN)
|
||||||
),
|
),
|
||||||
vol.Required(CONF_METHOD, default=METHOD_TRAPEZOIDAL): selector.SelectSelector(
|
vol.Required(CONF_METHOD, default=METHOD_TRAPEZOIDAL): selector.SelectSelector(
|
||||||
selector.SelectSelectorConfig(options=INTEGRATION_METHODS),
|
selector.SelectSelectorConfig(
|
||||||
|
options=INTEGRATION_METHODS, translation_key=CONF_METHOD
|
||||||
|
),
|
||||||
),
|
),
|
||||||
vol.Required(CONF_ROUND_DIGITS, default=2): selector.NumberSelector(
|
vol.Required(CONF_ROUND_DIGITS, default=2): selector.NumberSelector(
|
||||||
selector.NumberSelectorConfig(
|
selector.NumberSelectorConfig(
|
||||||
@ -76,7 +78,9 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
),
|
),
|
||||||
vol.Required(CONF_UNIT_TIME, default=UnitOfTime.HOURS): selector.SelectSelector(
|
vol.Required(CONF_UNIT_TIME, default=UnitOfTime.HOURS): selector.SelectSelector(
|
||||||
selector.SelectSelectorConfig(
|
selector.SelectSelectorConfig(
|
||||||
options=TIME_UNITS, mode=selector.SelectSelectorMode.DROPDOWN
|
options=TIME_UNITS,
|
||||||
|
mode=selector.SelectSelectorMode.DROPDOWN,
|
||||||
|
translation_key=CONF_UNIT_TIME,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -32,5 +32,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"selector": {
|
||||||
|
"method": {
|
||||||
|
"options": {
|
||||||
|
"trapezoidal": "Trapezoidal rule",
|
||||||
|
"left": "Left Riemann sum",
|
||||||
|
"right": "Right Riemann sum"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"unit_time": {
|
||||||
|
"options": {
|
||||||
|
"s": "Seconds",
|
||||||
|
"min": "Minutes",
|
||||||
|
"h": "Hours",
|
||||||
|
"d": "Days"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,5 +32,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"title": "Integration - Riemann sum integral sensor"
|
"title": "Integration - Riemann sum integral sensor",
|
||||||
|
"selector": {
|
||||||
|
"method": {
|
||||||
|
"options": {
|
||||||
|
"trapezoidal": "Trapezoidal rule",
|
||||||
|
"left": "Left Riemann sum",
|
||||||
|
"right": "Right Riemann sum"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"unit_time": {
|
||||||
|
"options": {
|
||||||
|
"s": "Seconds",
|
||||||
|
"min": "Minutes",
|
||||||
|
"h": "Hours",
|
||||||
|
"d": "Days"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user