From f92e732f271d1e5365c5a8db281be3699a1353cd Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 27 Dec 2023 09:01:53 +0100 Subject: [PATCH] Use translation placeholders in Swiss public transport (#106416) --- .../components/swiss_public_transport/config_flow.py | 7 +++++-- .../components/swiss_public_transport/const.py | 6 ++++++ .../components/swiss_public_transport/sensor.py | 5 +++-- .../components/swiss_public_transport/strings.json | 10 +++++----- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/swiss_public_transport/config_flow.py b/homeassistant/components/swiss_public_transport/config_flow.py index 534099f09e6..63eca1efe96 100644 --- a/homeassistant/components/swiss_public_transport/config_flow.py +++ b/homeassistant/components/swiss_public_transport/config_flow.py @@ -15,7 +15,7 @@ from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -from .const import CONF_DESTINATION, CONF_START, DOMAIN +from .const import CONF_DESTINATION, CONF_START, DOMAIN, PLACEHOLDERS DATA_SCHEMA = vol.Schema( { @@ -65,7 +65,10 @@ class SwissPublicTransportConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) return self.async_show_form( - step_id="user", data_schema=DATA_SCHEMA, errors=errors + step_id="user", + data_schema=DATA_SCHEMA, + errors=errors, + description_placeholders=PLACEHOLDERS, ) async def async_step_import(self, import_input: dict[str, Any]) -> FlowResult: diff --git a/homeassistant/components/swiss_public_transport/const.py b/homeassistant/components/swiss_public_transport/const.py index 3ce351498ee..d14a77feb2a 100644 --- a/homeassistant/components/swiss_public_transport/const.py +++ b/homeassistant/components/swiss_public_transport/const.py @@ -7,3 +7,9 @@ CONF_DESTINATION = "to" CONF_START = "from" DEFAULT_NAME = "Next Destination" + + +PLACEHOLDERS = { + "stationboard_url": "http://transport.opendata.ch/examples/stationboard.html", + "opendata_url": "http://transport.opendata.ch", +} diff --git a/homeassistant/components/swiss_public_transport/sensor.py b/homeassistant/components/swiss_public_transport/sensor.py index 0a69cf12085..bc03b8d61e1 100644 --- a/homeassistant/components/swiss_public_transport/sensor.py +++ b/homeassistant/components/swiss_public_transport/sensor.py @@ -22,7 +22,7 @@ from homeassistant.helpers.issue_registry import IssueSeverity, async_create_iss from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType import homeassistant.util.dt as dt_util -from .const import CONF_DESTINATION, CONF_START, DEFAULT_NAME, DOMAIN +from .const import CONF_DESTINATION, CONF_START, DEFAULT_NAME, DOMAIN, PLACEHOLDERS _LOGGER = logging.getLogger(__name__) @@ -104,11 +104,12 @@ async def async_setup_platform( issue_domain=DOMAIN, severity=IssueSeverity.WARNING, translation_key=f"deprecated_yaml_import_issue_${result['reason']}", + translation_placeholders=PLACEHOLDERS, ) class SwissPublicTransportSensor(SensorEntity): - """Implementation of an Swiss public transport sensor.""" + """Implementation of a Swiss public transport sensor.""" _attr_attribution = "Data provided by transport.opendata.ch" _attr_icon = "mdi:bus" diff --git a/homeassistant/components/swiss_public_transport/strings.json b/homeassistant/components/swiss_public_transport/strings.json index 097252634ea..01736beba78 100644 --- a/homeassistant/components/swiss_public_transport/strings.json +++ b/homeassistant/components/swiss_public_transport/strings.json @@ -2,13 +2,13 @@ "config": { "error": { "cannot_connect": "Cannot connect to server", - "bad_config": "Request failed due to bad config: Check at [stationboard](http://transport.opendata.ch/examples/stationboard.html) if your station names are valid", + "bad_config": "Request failed due to bad config: Check at [stationboard]({stationboard_url}) if your station names are valid", "unknown": "An unknown error was raised by python-opendata-transport" }, "abort": { "already_configured": "[%key:common::config_flow::abort::already_configured_service%]", "cannot_connect": "Cannot connect to server", - "bad_config": "Request failed due to bad config: Check at [stationboard](http://transport.opendata.ch/examples/stationboard.html) if your station names are valid", + "bad_config": "Request failed due to bad config: Check the [stationboard]({stationboard_url}) for valid stations.", "unknown": "An unknown error was raised by python-opendata-transport" }, "step": { @@ -17,7 +17,7 @@ "from": "Start station", "to": "End station" }, - "description": "Provide start and end station for your connection\n\nCheck here for valid stations: [stationboard](http://transport.opendata.ch/examples/stationboard.html)", + "description": "Provide start and end station for your connection\n\nCheck the [stationboard]({stationboard_url}) for valid stations.", "title": "Swiss Public Transport" } } @@ -25,11 +25,11 @@ "issues": { "deprecated_yaml_import_issue_cannot_connect": { "title": "The swiss public transport YAML configuration import cannot connect to server", - "description": "Configuring swiss public transport using YAML is being removed but there was an connection error importing your YAML configuration.\n\nMake sure your home assistant can reach the [opendata server](http://transport.opendata.ch). In case the server is down, try again later." + "description": "Configuring swiss public transport using YAML is being removed but there was an connection error importing your YAML configuration.\n\nMake sure your home assistant can reach the [opendata server]({opendata_url}). In case the server is down, try again later." }, "deprecated_yaml_import_issue_bad_config": { "title": "The swiss public transport YAML configuration import request failed due to bad config", - "description": "Configuring swiss public transport using YAML is being removed but there was bad config imported in your YAML configuration..\n\nCheck here for valid stations: [stationboard](http://transport.opendata.ch/examples/stationboard.html)" + "description": "Configuring swiss public transport using YAML is being removed but there was bad config imported in your YAML configuration.\n\nCheck the [stationboard]({stationboard_url}) for valid stations." }, "deprecated_yaml_import_issue_unknown": { "title": "The swiss public transport YAML configuration import failed with unknown error raised by python-opendata-transport",