mirror of
https://github.com/home-assistant/core
synced 2024-10-04 07:58:43 +02: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)"),
|
||||
]
|
||||
TIME_UNITS = [
|
||||
selector.SelectOptionDict(value=UnitOfTime.SECONDS, label="s (seconds)"),
|
||||
selector.SelectOptionDict(value=UnitOfTime.MINUTES, label="min (minutes)"),
|
||||
selector.SelectOptionDict(value=UnitOfTime.HOURS, label="h (hours)"),
|
||||
selector.SelectOptionDict(value=UnitOfTime.DAYS, label="d (days)"),
|
||||
UnitOfTime.SECONDS,
|
||||
UnitOfTime.MINUTES,
|
||||
UnitOfTime.HOURS,
|
||||
UnitOfTime.DAYS,
|
||||
]
|
||||
INTEGRATION_METHODS = [
|
||||
selector.SelectOptionDict(value=METHOD_TRAPEZOIDAL, label="Trapezoidal rule"),
|
||||
selector.SelectOptionDict(value=METHOD_LEFT, label="Left Riemann sum"),
|
||||
selector.SelectOptionDict(value=METHOD_RIGHT, label="Right Riemann sum"),
|
||||
METHOD_TRAPEZOIDAL,
|
||||
METHOD_LEFT,
|
||||
METHOD_RIGHT,
|
||||
]
|
||||
|
||||
OPTIONS_SCHEMA = vol.Schema(
|
||||
@ -61,7 +61,9 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
selector.EntitySelectorConfig(domain=SENSOR_DOMAIN)
|
||||
),
|
||||
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(
|
||||
selector.NumberSelectorConfig(
|
||||
@ -76,7 +78,9 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
),
|
||||
vol.Required(CONF_UNIT_TIME, default=UnitOfTime.HOURS): selector.SelectSelector(
|
||||
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…
Reference in New Issue
Block a user