Skip to content

Commit

Permalink
Update Singapore holidays: add en_SG, en_US, th localization (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
PPsyrius authored Oct 3, 2024
1 parent 112b043 commit 4232fcb
Show file tree
Hide file tree
Showing 7 changed files with 763 additions and 398 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ All other default values are highlighted with bold:
* - Singapore
- SG
-
-
- **en_SG**, en_US, th
-
* - Slovakia
- SK
Expand Down
94 changes: 53 additions & 41 deletions holidays/countries/singapore.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)

from gettext import gettext as tr

from holidays.calendars import (
_CustomBuddhistHolidays,
_CustomChineseHolidays,
Expand Down Expand Up @@ -40,7 +42,10 @@ class Singapore(
StaticHolidays,
):
country = "SG"
observed_label = "%s (observed)"
default_language = "en_SG"
# %s (observed).
observed_label = tr("%s (observed)")
supported_languages = ("en_SG", "en_US", "th")

def __init__(self, *args, **kwargs):
"""
Expand Down Expand Up @@ -94,50 +99,51 @@ def __init__(self, *args, **kwargs):
def _populate_public_holidays(self) -> None:
dts_observed = set()

# New Year's Day
dts_observed.add(self._add_new_years_day("New Year's Day"))
# New Year's Day.
dts_observed.add(self._add_new_years_day(tr("New Year's Day")))

# Chinese New Year (two days)
name = "Chinese New Year"
# Chinese New Year.
name = tr("Chinese New Year")
dts_observed.add(self._add_chinese_new_years_day(name)) # type: ignore[arg-type]
dts_observed.add(self._add_chinese_new_years_day_two(name)) # type: ignore[arg-type]

# Hari Raya Puasa (Eid al-Fitr)
dts_observed.update(self._add_eid_al_fitr_day("Hari Raya Puasa"))
# Eid al-Fitr.
dts_observed.update(self._add_eid_al_fitr_day(tr("Hari Raya Puasa")))
if self._year <= 1968:
self._add_eid_al_fitr_day_two("Second day of Hari Raya Puasa")
# Second Day of Eid al-Fitr.
self._add_eid_al_fitr_day_two(tr("Second Day of Hari Raya Puasa"))

# Hari Raya Haji (Eid al-Adha)
dts_observed.update(self._add_eid_al_adha_day("Hari Raya Haji"))
# Eid al-Adha.
dts_observed.update(self._add_eid_al_adha_day(tr("Hari Raya Haji")))

# Good Friday
self._add_good_friday("Good Friday")
# Good Friday.
self._add_good_friday(tr("Good Friday"))

if self._year <= 1968:
# Holy Saturday
self._add_holy_saturday("Holy Saturday")
# Holy Saturday.
self._add_holy_saturday(tr("Holy Saturday"))

# Easter Monday
self._add_easter_monday("Easter Monday")
# Easter Monday.
self._add_easter_monday(tr("Easter Monday"))

# Labour Day
dts_observed.add(self._add_labor_day("Labour Day"))
# Labor Day.
dts_observed.add(self._add_labor_day(tr("Labour Day")))

# Vesak Day
dts_observed.add(self._add_vesak("Vesak Day")) # type: ignore[arg-type]
# Vesak Day.
dts_observed.add(self._add_vesak(tr("Vesak Day"))) # type: ignore[arg-type]

# National Day
dts_observed.add(self._add_holiday_aug_9("National Day"))
# National Day.
dts_observed.add(self._add_holiday_aug_9(tr("National Day")))

# Deepavali (Diwali)
dts_observed.add(self._add_diwali("Deepavali")) # type: ignore[arg-type]
# Deepavali.
dts_observed.add(self._add_diwali(tr("Deepavali"))) # type: ignore[arg-type]

# Christmas Day
dts_observed.add(self._add_christmas_day("Christmas Day"))
# Christmas Day.
dts_observed.add(self._add_christmas_day(tr("Christmas Day")))

# Boxing day (up to and including 1968)
if self._year <= 1968:
self._add_christmas_day_two("Boxing Day")
# Boxing day.
self._add_christmas_day_two(tr("Boxing Day"))

if self.observed:
self._populate_observed(dts_observed)
Expand Down Expand Up @@ -303,23 +309,29 @@ class SingaporeIslamicHolidays(_CustomIslamicHolidays):


class SingaporeStaticHolidays:
"""
References
- https://www.mom.gov.sg/newsroom/press-releases/2015/sg50-public-holiday-on-7-august-2015
- https://www.straitstimes.com/singapore/politics/singapore-presidential-election-2023-polling-day-on-sept-1-nomination-day-on-aug-22
"""

# Polling Day.
polling_day_name = tr("Polling Day")

special_public_holidays = {
2001: (NOV, 3, "Polling Day"),
2006: (MAY, 6, "Polling Day"),
2011: (MAY, 7, "Polling Day"),
2001: (NOV, 3, polling_day_name),
2006: (MAY, 6, polling_day_name),
2011: (MAY, 7, polling_day_name),
2015: (
# SG50 Public holiday
# Announced on 14 March 2015
# https://www.mom.gov.sg/newsroom/press-releases/2015/sg50-public-holiday-on-7-august-2015
(AUG, 7, "SG50 Public Holiday"),
(SEP, 11, "Polling Day"),
# SG50 Public Holiday.
(AUG, 7, tr("SG50 Public Holiday")),
(SEP, 11, polling_day_name),
),
2020: (JUL, 10, "Polling Day"),
# Announced in state-associated press on 12 August 2023
# https://www.straitstimes.com/singapore/politics/singapore-presidential-election-2023-polling-day-on-sept-1-nomination-day-on-aug-22
2023: (SEP, 1, "Polling Day"),
2020: (JUL, 10, polling_day_name),
2023: (SEP, 1, polling_day_name),
}

special_public_holidays_observed = {
2007: (JAN, 2, "Hari Raya Haji"),
# Eid al-Adha.
2007: (JAN, 2, tr("Hari Raya Haji")),
}
98 changes: 98 additions & 0 deletions holidays/locale/en_SG/LC_MESSAGES/SG.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# holidays
# --------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: Vacanza Team and individual contributors (see AUTHORS file)
# dr-prodigy <[email protected]> (c) 2017-2023
# ryanss <[email protected]> (c) 2014-2017
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)
#
# Singapore holidays.
#
msgid ""
msgstr ""
"Project-Id-Version: Python Holidays 0.58\n"
"POT-Creation-Date: 2024-10-02 15:30+0700\n"
"PO-Revision-Date: 2024-10-02 15:54+0700\n"
"Last-Translator: PPsyrius <[email protected]>\n"
"Language-Team: Python Holidays Localization Team\n"
"Language: en_SG\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Lingva 5.0.3\n"
"X-Generator: Poedit 3.5\n"

#. %s (observed).
#, c-format
msgid "%s (observed)"
msgstr ""

#. New Year's Day.
msgid "New Year's Day"
msgstr ""

#. Chinese New Year.
msgid "Chinese New Year"
msgstr ""

#. Eid al-Fitr.
msgid "Hari Raya Puasa"
msgstr ""

#. Second Day of Eid al-Fitr.
msgid "Second Day of Hari Raya Puasa"
msgstr ""

#. Eid al-Adha.
msgid "Hari Raya Haji"
msgstr ""

#. Good Friday.
msgid "Good Friday"
msgstr ""

#. Holy Saturday.
msgid "Holy Saturday"
msgstr ""

#. Easter Monday.
msgid "Easter Monday"
msgstr ""

#. Labor Day.
msgid "Labour Day"
msgstr ""

#. Vesak Day.
#. type: ignore[arg-type]
msgid "Vesak Day"
msgstr ""

#. National Day.
msgid "National Day"
msgstr ""

#. Deepavali.
#. type: ignore[arg-type]
msgid "Deepavali"
msgstr ""

#. Christmas Day.
msgid "Christmas Day"
msgstr ""

#. Boxing day.
msgid "Boxing Day"
msgstr ""

#. Polling Day.
msgid "Polling Day"
msgstr ""

#. SG50 Public Holiday.
msgid "SG50 Public Holiday"
msgstr ""
98 changes: 98 additions & 0 deletions holidays/locale/en_US/LC_MESSAGES/SG.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# holidays
# --------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: Vacanza Team and individual contributors (see AUTHORS file)
# dr-prodigy <[email protected]> (c) 2017-2023
# ryanss <[email protected]> (c) 2014-2017
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)
#
# Singapore holidays en_US localization.
#
msgid ""
msgstr ""
"Project-Id-Version: Python Holidays 0.58\n"
"POT-Creation-Date: 2024-10-02 15:30+0700\n"
"PO-Revision-Date: 2024-10-02 15:54+0700\n"
"Last-Translator: PPsyrius <[email protected]>\n"
"Language-Team: Python Holidays Localization Team\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Lingva 5.0.3\n"
"X-Generator: Poedit 3.5\n"

#. %s (observed).
#, c-format
msgid "%s (observed)"
msgstr "%s (observed)"

#. New Year's Day.
msgid "New Year's Day"
msgstr "New Year's Day"

#. Chinese New Year.
msgid "Chinese New Year"
msgstr "Chinese New Year"

#. Eid al-Fitr.
msgid "Hari Raya Puasa"
msgstr "Eid al-Fitr"

#. Second Day of Eid al-Fitr.
msgid "Second Day of Hari Raya Puasa"
msgstr "Second Day of Eid al-Fitr"

#. Eid al-Adha.
msgid "Hari Raya Haji"
msgstr "Eid al-Adha"

#. Good Friday.
msgid "Good Friday"
msgstr "Good Friday"

#. Holy Saturday.
msgid "Holy Saturday"
msgstr "Holy Saturday"

#. Easter Monday.
msgid "Easter Monday"
msgstr "Easter Monday"

#. Labor Day.
msgid "Labour Day"
msgstr "Labor Day"

#. Vesak Day.
#. type: ignore[arg-type]
msgid "Vesak Day"
msgstr "Vesak Day"

#. National Day.
msgid "National Day"
msgstr "National Day"

#. Deepavali.
#. type: ignore[arg-type]
msgid "Deepavali"
msgstr "Deepavali"

#. Christmas Day.
msgid "Christmas Day"
msgstr "Christmas Day"

#. Boxing day.
msgid "Boxing Day"
msgstr "Boxing Day"

#. Polling Day.
msgid "Polling Day"
msgstr "Polling Day"

#. SG50 Public Holiday.
msgid "SG50 Public Holiday"
msgstr "SG50 Public Holiday"
Loading

0 comments on commit 4232fcb

Please sign in to comment.