diff --git a/custom_components/irm_kmi/config_flow.py b/custom_components/irm_kmi/config_flow.py index 9320ab8..9a95d7f 100644 --- a/custom_components/irm_kmi/config_flow.py +++ b/custom_components/irm_kmi/config_flow.py @@ -33,6 +33,7 @@ async def async_step_user(self, user_input: dict | None = None) -> FlowResult: return self.async_show_form( step_id="user", data_schema=vol.Schema({ - vol.Required(CONF_ZONE): EntitySelector(EntitySelectorConfig(domain=ZONE_DOMAIN)), + vol.Required(CONF_ZONE, description="Zone to use for weather forecast"): + EntitySelector(EntitySelectorConfig(domain=ZONE_DOMAIN)), }) ) diff --git a/custom_components/irm_kmi/const.py b/custom_components/irm_kmi/const.py index f5d8771..28c1886 100644 --- a/custom_components/irm_kmi/const.py +++ b/custom_components/irm_kmi/const.py @@ -19,6 +19,7 @@ "Hors de Belgique (Bxl)", "Outside the Benelux (Brussels)", "Buiten de Benelux (Brussel)"] +LANGS = ['en', 'fr', 'nl', 'de'] # map ('ww', 'dayNight') tuple from IRM KMI to HA conditions IRM_KMI_TO_HA_CONDITION_MAP = { diff --git a/custom_components/irm_kmi/coordinator.py b/custom_components/irm_kmi/coordinator.py index 4a7fd39..e9f71f7 100644 --- a/custom_components/irm_kmi/coordinator.py +++ b/custom_components/irm_kmi/coordinator.py @@ -17,7 +17,7 @@ from PIL import Image, ImageDraw, ImageFont from .api import IrmKmiApiClient, IrmKmiApiError -from .const import IRM_KMI_TO_HA_CONDITION_MAP as CDT_MAP +from .const import IRM_KMI_TO_HA_CONDITION_MAP as CDT_MAP, LANGS from .const import OUT_OF_BENELUX from .data import (AnimationFrameData, CurrentWeatherData, IrmKmiForecast, ProcessedCoordinatorData, RadarAnimationData) @@ -88,8 +88,9 @@ async def _async_animation_data(self, api_data: dict) -> RadarAnimationData: images_from_api = images_from_api[1:] radar_animation = await self.merge_frames_from_api(animation_data, country, images_from_api, localisation) - # TODO support translation here - radar_animation['hint'] = api_data.get('animation', {}).get('sequenceHint', {}).get('en') + + lang = self.hass.config.language if self.hass.config.language in LANGS else 'en' + radar_animation['hint'] = api_data.get('animation', {}).get('sequenceHint', {}).get(lang) return radar_animation async def process_api_data(self, api_data: dict) -> ProcessedCoordinatorData: diff --git a/custom_components/irm_kmi/translations/en.json b/custom_components/irm_kmi/translations/en.json new file mode 100644 index 0000000..79033c2 --- /dev/null +++ b/custom_components/irm_kmi/translations/en.json @@ -0,0 +1,17 @@ +{ + "title": "Royal Meteorological Institute of Belgium", + "config": { + "step": { + "user": { + "title": "Select a zone", + "data" : { + "zone": "Zone" + } + } + }, + "abort": { + "already_configured": "Weather for this zone is already configured", + "unknown": "Unknown error occurred" + } + } +} \ No newline at end of file diff --git a/custom_components/irm_kmi/translations/fr.json b/custom_components/irm_kmi/translations/fr.json new file mode 100644 index 0000000..876a6a6 --- /dev/null +++ b/custom_components/irm_kmi/translations/fr.json @@ -0,0 +1,17 @@ +{ + "title": "Institut royal météorologique de Belgique", + "config": { + "step": { + "user": { + "title": "Choisissez une zone", + "data" : { + "zone": "Zone" + } + } + }, + "abort": { + "already_configured": "La météo pour cette zone est déjà configurée", + "unknown": "Une erreur inconnue est survenue" + } + } +} \ No newline at end of file