mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Prevent leading and trailing spaces in translation values (#126427)
* Prevent leading and trailing spaces in translation values * Adjust components * Tests
This commit is contained in:
parent
90957dfedb
commit
7c5dc29981
@ -275,7 +275,7 @@
|
||||
"name": "Relative self consumption"
|
||||
},
|
||||
"capacity_maximum": {
|
||||
"name": "Maximum capacity "
|
||||
"name": "Maximum capacity"
|
||||
},
|
||||
"capacity_designed": {
|
||||
"name": "Designed capacity"
|
||||
|
@ -21,7 +21,7 @@
|
||||
"data": {
|
||||
"device_name": "Device Name"
|
||||
},
|
||||
"description": "Enter your Hive configuration ",
|
||||
"description": "Enter your Hive configuration",
|
||||
"title": "Hive Configuration."
|
||||
},
|
||||
"reauth": {
|
||||
|
@ -55,7 +55,7 @@
|
||||
"name": "Cutting height"
|
||||
},
|
||||
"my_lawn_cutting_height": {
|
||||
"name": "My lawn cutting height "
|
||||
"name": "My lawn cutting height"
|
||||
},
|
||||
"work_area_cutting_height": {
|
||||
"name": "{work_area} cutting height"
|
||||
|
@ -3,7 +3,7 @@
|
||||
"step": {
|
||||
"user": {
|
||||
"title": "Setup madVR Envy",
|
||||
"description": "Your device needs to be on in order to add the integation. ",
|
||||
"description": "Your device needs to be on in order to add the integation.",
|
||||
"data": {
|
||||
"host": "[%key:common::config_flow::data::host%]",
|
||||
"port": "[%key:common::config_flow::data::port%]"
|
||||
@ -15,7 +15,7 @@
|
||||
},
|
||||
"reconfigure": {
|
||||
"title": "Reconfigure madVR Envy",
|
||||
"description": "Your device needs to be on in order to reconfigure the integation. ",
|
||||
"description": "Your device needs to be on in order to reconfigure the integation.",
|
||||
"data": {
|
||||
"host": "[%key:common::config_flow::data::host%]",
|
||||
"port": "[%key:common::config_flow::data::port%]"
|
||||
|
@ -100,7 +100,7 @@
|
||||
},
|
||||
"avoid_subscription_roads": {
|
||||
"name": "[%key:component::waze_travel_time::options::step::init::data::avoid_subscription_roads%]",
|
||||
"description": "Whether to avoid subscription roads. "
|
||||
"description": "Whether to avoid subscription roads."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,11 +131,13 @@ def translation_value_validator(value: Any) -> str:
|
||||
- prevents strings with single quoted placeholders
|
||||
- prevents combined translations
|
||||
"""
|
||||
value = cv.string_with_no_html(value)
|
||||
value = string_no_single_quoted_placeholders(value)
|
||||
if RE_COMBINED_REFERENCE.search(value):
|
||||
string_value = cv.string_with_no_html(value)
|
||||
string_value = string_no_single_quoted_placeholders(string_value)
|
||||
if RE_COMBINED_REFERENCE.search(string_value):
|
||||
raise vol.Invalid("the string should not contain combined translations")
|
||||
return str(value)
|
||||
if string_value != string_value.strip(" "):
|
||||
raise vol.Invalid("the string should not contain leading or trailing spaces")
|
||||
return string_value
|
||||
|
||||
|
||||
def string_no_single_quoted_placeholders(value: str) -> str:
|
||||
|
@ -195,7 +195,7 @@
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'My lawn cutting height ',
|
||||
'original_name': 'My lawn cutting height',
|
||||
'platform': 'husqvarna_automower',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
@ -207,7 +207,7 @@
|
||||
# name: test_number_snapshot[number.test_mower_1_my_lawn_cutting_height-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'Test Mower 1 My lawn cutting height ',
|
||||
'friendly_name': 'Test Mower 1 My lawn cutting height',
|
||||
'max': 100.0,
|
||||
'min': 0.0,
|
||||
'mode': <NumberMode.AUTO: 'auto'>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user