From a37f8b1f4ec9318eeda368b427de7c938c12874a Mon Sep 17 00:00:00 2001 From: Tsvi Mostovicz Date: Fri, 9 May 2025 01:00:28 +0300 Subject: [PATCH] Jewish calendar entity translations (#144414) * Move strings from entity descriptions to strings.json * Use the original name values * Fix casing * Use "real" english names as well as transliterated names --- .../jewish_calendar/binary_sensor.py | 6 +- .../components/jewish_calendar/sensor.py | 47 +++++----- .../components/jewish_calendar/strings.json | 78 +++++++++++++++ .../components/jewish_calendar/test_sensor.py | 94 +++++++++---------- 4 files changed, 151 insertions(+), 74 deletions(-) diff --git a/homeassistant/components/jewish_calendar/binary_sensor.py b/homeassistant/components/jewish_calendar/binary_sensor.py index d8672e8a4a3..8d06526c322 100644 --- a/homeassistant/components/jewish_calendar/binary_sensor.py +++ b/homeassistant/components/jewish_calendar/binary_sensor.py @@ -38,19 +38,19 @@ class JewishCalendarBinarySensorEntityDescription( BINARY_SENSORS: tuple[JewishCalendarBinarySensorEntityDescription, ...] = ( JewishCalendarBinarySensorEntityDescription( key="issur_melacha_in_effect", - name="Issur Melacha in Effect", + translation_key="issur_melacha_in_effect", icon="mdi:power-plug-off", is_on=lambda state, now: bool(state.issur_melacha_in_effect(now)), ), JewishCalendarBinarySensorEntityDescription( key="erev_shabbat_hag", - name="Erev Shabbat/Hag", + translation_key="erev_shabbat_hag", is_on=lambda state, now: bool(state.erev_shabbat_chag(now)), entity_registry_enabled_default=False, ), JewishCalendarBinarySensorEntityDescription( key="motzei_shabbat_hag", - name="Motzei Shabbat/Hag", + translation_key="motzei_shabbat_hag", is_on=lambda state, now: bool(state.motzei_shabbat_chag(now)), entity_registry_enabled_default=False, ), diff --git a/homeassistant/components/jewish_calendar/sensor.py b/homeassistant/components/jewish_calendar/sensor.py index f6c1978be21..deaae64547a 100644 --- a/homeassistant/components/jewish_calendar/sensor.py +++ b/homeassistant/components/jewish_calendar/sensor.py @@ -28,31 +28,30 @@ _LOGGER = logging.getLogger(__name__) INFO_SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="date", - name="Date", - icon="mdi:star-david", translation_key="hebrew_date", + icon="mdi:star-david", ), SensorEntityDescription( key="weekly_portion", - name="Parshat Hashavua", + translation_key="weekly_portion", icon="mdi:book-open-variant", device_class=SensorDeviceClass.ENUM, ), SensorEntityDescription( key="holiday", - name="Holiday", + translation_key="holiday", icon="mdi:calendar-star", device_class=SensorDeviceClass.ENUM, ), SensorEntityDescription( key="omer_count", - name="Day of the Omer", + translation_key="omer_count", icon="mdi:counter", entity_registry_enabled_default=False, ), SensorEntityDescription( key="daf_yomi", - name="Daf Yomi", + translation_key="daf_yomi", icon="mdi:book-open-variant", entity_registry_enabled_default=False, ), @@ -61,106 +60,106 @@ INFO_SENSORS: tuple[SensorEntityDescription, ...] = ( TIME_SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="alot_hashachar", - name="Alot Hashachar", # codespell:ignore alot + translation_key="alot_hashachar", icon="mdi:weather-sunset-up", entity_registry_enabled_default=False, ), SensorEntityDescription( key="talit_and_tefillin", - name="Talit and Tefillin", + translation_key="talit_and_tefillin", icon="mdi:calendar-clock", entity_registry_enabled_default=False, ), SensorEntityDescription( key="netz_hachama", - name="Hanetz Hachama", + translation_key="netz_hachama", icon="mdi:calendar-clock", ), SensorEntityDescription( key="sof_zman_shema_gra", - name='Latest time for Shma Gr"a', + translation_key="sof_zman_shema_gra", icon="mdi:calendar-clock", entity_registry_enabled_default=False, ), SensorEntityDescription( key="sof_zman_shema_mga", - name='Latest time for Shma MG"A', + translation_key="sof_zman_shema_mga", icon="mdi:calendar-clock", entity_registry_enabled_default=False, ), SensorEntityDescription( key="sof_zman_tfilla_gra", - name='Latest time for Tefilla Gr"a', + translation_key="sof_zman_tfilla_gra", icon="mdi:calendar-clock", entity_registry_enabled_default=False, ), SensorEntityDescription( key="sof_zman_tfilla_mga", - name='Latest time for Tefilla MG"A', + translation_key="sof_zman_tfilla_mga", icon="mdi:calendar-clock", entity_registry_enabled_default=False, ), SensorEntityDescription( key="chatzot_hayom", - name="Chatzot Hayom", + translation_key="chatzot_hayom", icon="mdi:calendar-clock", entity_registry_enabled_default=False, ), SensorEntityDescription( key="mincha_gedola", - name="Mincha Gedola", + translation_key="mincha_gedola", icon="mdi:calendar-clock", entity_registry_enabled_default=False, ), SensorEntityDescription( key="mincha_ketana", - name="Mincha Ketana", + translation_key="mincha_ketana", icon="mdi:calendar-clock", entity_registry_enabled_default=False, ), SensorEntityDescription( key="plag_hamincha", - name="Plag Hamincha", + translation_key="plag_hamincha", icon="mdi:weather-sunset-down", entity_registry_enabled_default=False, ), SensorEntityDescription( key="shkia", - name="Shkia", + translation_key="shkia", icon="mdi:weather-sunset", ), SensorEntityDescription( key="tset_hakohavim_tsom", - name="T'set Hakochavim", + translation_key="tset_hakohavim_tsom", icon="mdi:weather-night", entity_registry_enabled_default=False, ), SensorEntityDescription( key="tset_hakohavim_shabbat", - name="T'set Hakochavim, 3 stars", + translation_key="tset_hakohavim_shabbat", icon="mdi:weather-night", entity_registry_enabled_default=False, ), SensorEntityDescription( key="upcoming_shabbat_candle_lighting", - name="Upcoming Shabbat Candle Lighting", + translation_key="upcoming_shabbat_candle_lighting", icon="mdi:candle", entity_registry_enabled_default=False, ), SensorEntityDescription( key="upcoming_shabbat_havdalah", - name="Upcoming Shabbat Havdalah", + translation_key="upcoming_shabbat_havdalah", icon="mdi:weather-night", entity_registry_enabled_default=False, ), SensorEntityDescription( key="upcoming_candle_lighting", - name="Upcoming Candle Lighting", + translation_key="upcoming_candle_lighting", icon="mdi:candle", ), SensorEntityDescription( key="upcoming_havdalah", - name="Upcoming Havdalah", + translation_key="upcoming_havdalah", icon="mdi:weather-night", ), ) diff --git a/homeassistant/components/jewish_calendar/strings.json b/homeassistant/components/jewish_calendar/strings.json index dcdfb05f10c..33d58ea3487 100644 --- a/homeassistant/components/jewish_calendar/strings.json +++ b/homeassistant/components/jewish_calendar/strings.json @@ -1,12 +1,90 @@ { "entity": { + "binary_sensor": { + "issur_melacha_in_effect": { + "name": "Issur Melacha in effect" + }, + "erev_shabbat_hag": { + "name": "Erev Shabbat/Hag" + }, + "motzei_shabbat_hag": { + "name": "Motzei Shabbat/Hag" + } + }, "sensor": { "hebrew_date": { + "name": "Date", "state_attributes": { "hebrew_year": { "name": "Hebrew year" }, "hebrew_month_name": { "name": "Hebrew month name" }, "hebrew_day": { "name": "Hebrew day" } } + }, + "weekly_portion": { + "name": "Weekly Torah portion" + }, + "holiday": { + "name": "Holiday" + }, + "omer_count": { + "name": "Day of the Omer" + }, + "daf_yomi": { + "name": "Daf Yomi" + }, + "alot_hashachar": { + "name": "Halachic dawn (Alot Hashachar)" + }, + "talit_and_tefillin": { + "name": "Earliest time for Talit and Tefillin" + }, + "netz_hachama": { + "name": "Halachic sunrise (Netz Hachama)" + }, + "sof_zman_shema_gra": { + "name": "Latest time for Shma Gr\"a" + }, + "sof_zman_shema_mga": { + "name": "Latest time for Shma MG\"A" + }, + "sof_zman_tfilla_gra": { + "name": "Latest time for Tefilla Gr\"a" + }, + "sof_zman_tfilla_mga": { + "name": "Latest time for Tefilla MG\"A" + }, + "chatzot_hayom": { + "name": "Halachic midday (Chatzot Hayom)" + }, + "mincha_gedola": { + "name": "Mincha Gedola" + }, + "mincha_ketana": { + "name": "Mincha Ketana" + }, + "plag_hamincha": { + "name": "Plag Hamincha" + }, + "shkia": { + "name": "Sunset (Shkia)" + }, + "tset_hakohavim_tsom": { + "name": "Nightfall (T'set Hakochavim)" + }, + "tset_hakohavim_shabbat": { + "name": "Nightfall (T'set Hakochavim, 3 stars)" + }, + "upcoming_shabbat_candle_lighting": { + "name": "Upcoming Shabbat candle lighting" + }, + "upcoming_shabbat_havdalah": { + "name": "Upcoming Shabbat Havdalah" + }, + "upcoming_candle_lighting": { + "name": "Upcoming candle lighting" + }, + "upcoming_havdalah": { + "name": "Upcoming Havdalah" } } }, diff --git a/tests/components/jewish_calendar/test_sensor.py b/tests/components/jewish_calendar/test_sensor.py index d38d20ab4d6..b33d8f3e84b 100644 --- a/tests/components/jewish_calendar/test_sensor.py +++ b/tests/components/jewish_calendar/test_sensor.py @@ -94,21 +94,21 @@ TEST_PARAMS = [ "state": "נצבים", "attr": { "device_class": "enum", - "friendly_name": "Jewish Calendar Parshat Hashavua", + "friendly_name": "Jewish Calendar Weekly Torah portion", "icon": "mdi:book-open-variant", "options": list(Parasha), }, }, "he", - "parshat_hashavua", - id="torah_reading", + "weekly_torah_portion", + id="torah_portion", ), pytest.param( "New York", dt(2018, 9, 8), {"state": dt(2018, 9, 8, 19, 47)}, "he", - "t_set_hakochavim", + "nightfall_t_set_hakochavim", id="first_stars_ny", ), pytest.param( @@ -116,7 +116,7 @@ TEST_PARAMS = [ dt(2018, 9, 8), {"state": dt(2018, 9, 8, 19, 21)}, "he", - "t_set_hakochavim", + "nightfall_t_set_hakochavim", id="first_stars_jerusalem", ), pytest.param( @@ -124,8 +124,8 @@ TEST_PARAMS = [ dt(2018, 10, 14), {"state": "לך לך"}, "he", - "parshat_hashavua", - id="torah_reading_weekday", + "weekly_torah_portion", + id="torah_portion_weekday", ), pytest.param( "Jerusalem", @@ -185,8 +185,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 9, 1, 20, 10), "en_upcoming_shabbat_candle_lighting": dt(2018, 8, 31, 19, 12), "en_upcoming_shabbat_havdalah": dt(2018, 9, 1, 20, 10), - "en_parshat_hashavua": "Ki Tavo", - "he_parshat_hashavua": "כי תבוא", + "en_weekly_torah_portion": "Ki Tavo", + "he_weekly_torah_portion": "כי תבוא", }, None, id="currently_first_shabbat", @@ -199,8 +199,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 9, 1, 20, 18), "en_upcoming_shabbat_candle_lighting": dt(2018, 8, 31, 19, 12), "en_upcoming_shabbat_havdalah": dt(2018, 9, 1, 20, 18), - "en_parshat_hashavua": "Ki Tavo", - "he_parshat_hashavua": "כי תבוא", + "en_weekly_torah_portion": "Ki Tavo", + "he_weekly_torah_portion": "כי תבוא", }, 50, # Havdalah offset id="currently_first_shabbat_with_havdalah_offset", @@ -213,8 +213,8 @@ SHABBAT_PARAMS = [ "en_upcoming_shabbat_havdalah": dt(2018, 9, 1, 20, 10), "en_upcoming_candle_lighting": dt(2018, 8, 31, 19, 12), "en_upcoming_havdalah": dt(2018, 9, 1, 20, 10), - "en_parshat_hashavua": "Ki Tavo", - "he_parshat_hashavua": "כי תבוא", + "en_weekly_torah_portion": "Ki Tavo", + "he_weekly_torah_portion": "כי תבוא", }, None, id="currently_first_shabbat_bein_hashmashot_lagging_date", @@ -227,8 +227,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 9, 8, 19, 58), "en_upcoming_shabbat_candle_lighting": dt(2018, 9, 7, 19), "en_upcoming_shabbat_havdalah": dt(2018, 9, 8, 19, 58), - "en_parshat_hashavua": "Nitzavim", - "he_parshat_hashavua": "נצבים", + "en_weekly_torah_portion": "Nitzavim", + "he_weekly_torah_portion": "נצבים", }, None, id="after_first_shabbat", @@ -241,8 +241,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 9, 8, 19, 58), "en_upcoming_shabbat_candle_lighting": dt(2018, 9, 7, 19), "en_upcoming_shabbat_havdalah": dt(2018, 9, 8, 19, 58), - "en_parshat_hashavua": "Nitzavim", - "he_parshat_hashavua": "נצבים", + "en_weekly_torah_portion": "Nitzavim", + "he_weekly_torah_portion": "נצבים", }, None, id="friday_upcoming_shabbat", @@ -255,8 +255,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 9, 11, 19, 53), "en_upcoming_shabbat_candle_lighting": dt(2018, 9, 14, 18, 48), "en_upcoming_shabbat_havdalah": dt(2018, 9, 15, 19, 46), - "en_parshat_hashavua": "Vayeilech", - "he_parshat_hashavua": "וילך", + "en_weekly_torah_portion": "Vayeilech", + "he_weekly_torah_portion": "וילך", "en_holiday": "Erev Rosh Hashana", "he_holiday": "ערב ראש השנה", }, @@ -271,8 +271,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 9, 11, 19, 53), "en_upcoming_shabbat_candle_lighting": dt(2018, 9, 14, 18, 48), "en_upcoming_shabbat_havdalah": dt(2018, 9, 15, 19, 46), - "en_parshat_hashavua": "Vayeilech", - "he_parshat_hashavua": "וילך", + "en_weekly_torah_portion": "Vayeilech", + "he_weekly_torah_portion": "וילך", "en_holiday": "Rosh Hashana I", "he_holiday": "א' ראש השנה", }, @@ -287,8 +287,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 9, 11, 19, 53), "en_upcoming_shabbat_candle_lighting": dt(2018, 9, 14, 18, 48), "en_upcoming_shabbat_havdalah": dt(2018, 9, 15, 19, 46), - "en_parshat_hashavua": "Vayeilech", - "he_parshat_hashavua": "וילך", + "en_weekly_torah_portion": "Vayeilech", + "he_weekly_torah_portion": "וילך", "en_holiday": "Rosh Hashana II", "he_holiday": "ב' ראש השנה", }, @@ -303,8 +303,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 9, 29, 19, 22), "en_upcoming_shabbat_candle_lighting": dt(2018, 9, 28, 18, 25), "en_upcoming_shabbat_havdalah": dt(2018, 9, 29, 19, 22), - "en_parshat_hashavua": "none", - "he_parshat_hashavua": "none", + "en_weekly_torah_portion": "none", + "he_weekly_torah_portion": "none", }, None, id="currently_shabbat_chol_hamoed", @@ -317,8 +317,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 10, 2, 19, 17), "en_upcoming_shabbat_candle_lighting": dt(2018, 10, 5, 18, 13), "en_upcoming_shabbat_havdalah": dt(2018, 10, 6, 19, 11), - "en_parshat_hashavua": "Bereshit", - "he_parshat_hashavua": "בראשית", + "en_weekly_torah_portion": "Bereshit", + "he_weekly_torah_portion": "בראשית", "en_holiday": "Hoshana Raba", "he_holiday": "הושענא רבה", }, @@ -333,8 +333,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 10, 2, 19, 17), "en_upcoming_shabbat_candle_lighting": dt(2018, 10, 5, 18, 13), "en_upcoming_shabbat_havdalah": dt(2018, 10, 6, 19, 11), - "en_parshat_hashavua": "Bereshit", - "he_parshat_hashavua": "בראשית", + "en_weekly_torah_portion": "Bereshit", + "he_weekly_torah_portion": "בראשית", "en_holiday": "Shmini Atzeret", "he_holiday": "שמיני עצרת", }, @@ -349,8 +349,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 10, 2, 19, 17), "en_upcoming_shabbat_candle_lighting": dt(2018, 10, 5, 18, 13), "en_upcoming_shabbat_havdalah": dt(2018, 10, 6, 19, 11), - "en_parshat_hashavua": "Bereshit", - "he_parshat_hashavua": "בראשית", + "en_weekly_torah_portion": "Bereshit", + "he_weekly_torah_portion": "בראשית", "en_holiday": "Simchat Torah", "he_holiday": "שמחת תורה", }, @@ -365,8 +365,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 10, 1, 19, 1), "en_upcoming_shabbat_candle_lighting": dt(2018, 10, 5, 17, 39), "en_upcoming_shabbat_havdalah": dt(2018, 10, 6, 18, 54), - "en_parshat_hashavua": "Bereshit", - "he_parshat_hashavua": "בראשית", + "en_weekly_torah_portion": "Bereshit", + "he_weekly_torah_portion": "בראשית", "en_holiday": "Hoshana Raba", "he_holiday": "הושענא רבה", }, @@ -381,8 +381,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 10, 1, 19, 1), "en_upcoming_shabbat_candle_lighting": dt(2018, 10, 5, 17, 39), "en_upcoming_shabbat_havdalah": dt(2018, 10, 6, 18, 54), - "en_parshat_hashavua": "Bereshit", - "he_parshat_hashavua": "בראשית", + "en_weekly_torah_portion": "Bereshit", + "he_weekly_torah_portion": "בראשית", "en_holiday": "Shmini Atzeret, Simchat Torah", "he_holiday": "שמיני עצרת, שמחת תורה", }, @@ -397,8 +397,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2018, 10, 6, 18, 54), "en_upcoming_shabbat_candle_lighting": dt(2018, 10, 5, 17, 39), "en_upcoming_shabbat_havdalah": dt(2018, 10, 6, 18, 54), - "en_parshat_hashavua": "Bereshit", - "he_parshat_hashavua": "בראשית", + "en_weekly_torah_portion": "Bereshit", + "he_weekly_torah_portion": "בראשית", }, None, id="after_one_day_yom_tov_in_israel", @@ -411,8 +411,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2016, 6, 13, 21, 19), "en_upcoming_shabbat_candle_lighting": dt(2016, 6, 10, 20, 9), "en_upcoming_shabbat_havdalah": "unknown", - "en_parshat_hashavua": "Bamidbar", - "he_parshat_hashavua": "במדבר", + "en_weekly_torah_portion": "Bamidbar", + "he_weekly_torah_portion": "במדבר", "en_holiday": "Erev Shavuot", "he_holiday": "ערב שבועות", }, @@ -427,8 +427,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2016, 6, 13, 21, 19), "en_upcoming_shabbat_candle_lighting": dt(2016, 6, 17, 20, 12), "en_upcoming_shabbat_havdalah": dt(2016, 6, 18, 21, 21), - "en_parshat_hashavua": "Nasso", - "he_parshat_hashavua": "נשא", + "en_weekly_torah_portion": "Nasso", + "he_weekly_torah_portion": "נשא", "en_holiday": "Shavuot", "he_holiday": "שבועות", }, @@ -443,8 +443,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2017, 9, 23, 19, 11), "en_upcoming_shabbat_candle_lighting": dt(2017, 9, 22, 17, 56), "en_upcoming_shabbat_havdalah": dt(2017, 9, 23, 19, 11), - "en_parshat_hashavua": "Ha'Azinu", - "he_parshat_hashavua": "האזינו", + "en_weekly_torah_portion": "Ha'Azinu", + "he_weekly_torah_portion": "האזינו", "en_holiday": "Rosh Hashana I", "he_holiday": "א' ראש השנה", }, @@ -459,8 +459,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2017, 9, 23, 19, 11), "en_upcoming_shabbat_candle_lighting": dt(2017, 9, 22, 17, 56), "en_upcoming_shabbat_havdalah": dt(2017, 9, 23, 19, 11), - "en_parshat_hashavua": "Ha'Azinu", - "he_parshat_hashavua": "האזינו", + "en_weekly_torah_portion": "Ha'Azinu", + "he_weekly_torah_portion": "האזינו", "en_holiday": "Rosh Hashana II", "he_holiday": "ב' ראש השנה", }, @@ -475,8 +475,8 @@ SHABBAT_PARAMS = [ "en_upcoming_havdalah": dt(2017, 9, 23, 19, 11), "en_upcoming_shabbat_candle_lighting": dt(2017, 9, 22, 17, 56), "en_upcoming_shabbat_havdalah": dt(2017, 9, 23, 19, 11), - "en_parshat_hashavua": "Ha'Azinu", - "he_parshat_hashavua": "האזינו", + "en_weekly_torah_portion": "Ha'Azinu", + "he_weekly_torah_portion": "האזינו", "en_holiday": "", "he_holiday": "", },