Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update l10n related workflows #1140

Merged
merged 11 commits into from
May 26, 2023
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ help:
@echo " tox run tox (in parallel)"

check:
make l10n
make pre-commit
make doc
make test
Expand All @@ -23,7 +24,7 @@ doc:
sphinx-build -E -T -W -b html -D language=en -j auto -q docs/source docs/build

l10n:
scripts/l10n/generate_po_files.py
scripts/l10n/generate_po_files.py 2>/dev/null
scripts/l10n/generate_mo_files.py

package:
Expand Down
24 changes: 12 additions & 12 deletions holidays/countries/argentina.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def _populate(self, year):
def _add_movable(hol_date: date, hol_name: str) -> None:
def add_movable_holiday(dt: date, name: str) -> None:
"""
!!! Movable Holidays Law !!!

Expand All @@ -160,13 +160,13 @@ def _add_movable(hol_date: date, hol_name: str) -> None:
- If THU/FRI - observed on next MON
"""
if self.observed:
if self._is_tuesday(hol_date) or self._is_wednesday(hol_date):
hol_date = _get_nth_weekday_from(-1, MON, hol_date)
hol_name = self.tr("%s (Observado)") % self.tr(hol_name)
elif self._is_thursday(hol_date) or self._is_friday(hol_date):
hol_date = _get_nth_weekday_from(1, MON, hol_date)
hol_name = self.tr("%s (Observado)") % self.tr(hol_name)
self._add_holiday(hol_name, hol_date)
if self._is_tuesday(dt) or self._is_wednesday(dt):
dt = _get_nth_weekday_from(-1, MON, dt)
name = self.tr("%s (Observado)") % self.tr(name)
elif self._is_thursday(dt) or self._is_friday(dt):
dt = _get_nth_weekday_from(1, MON, dt)
name = self.tr("%s (Observado)") % self.tr(name)
self._add_holiday(name, dt)

super()._populate(year)

Expand Down Expand Up @@ -285,7 +285,7 @@ def _add_movable(hol_date: date, hol_name: str) -> None:
if self._is_friday(dt):
self._add_holiday(name, dt)
else:
_add_movable(dt, name)
add_movable_holiday(dt, name)

# Day Pass to the Immortality of General José de San Martin.
# Status: In-Use.
Expand All @@ -304,7 +304,7 @@ def _add_movable(hol_date: date, hol_name: str) -> None:
name, _get_nth_weekday_of_month(3, MON, AUG, year)
)
elif year >= 2012:
_add_movable(date(year, AUG, 17), name)
add_movable_holiday(date(year, AUG, 17), name)

# Respect for Cultural Diversity Day or Columbus Day.
# Status: In-Use.
Expand All @@ -317,7 +317,7 @@ def _add_movable(hol_date: date, hol_name: str) -> None:
if year >= 2010
else tr("Día de la Raza")
)
_add_movable(date(year, OCT, 12), name)
add_movable_holiday(date(year, OCT, 12), name)

# National Sovereignty Day.
# Status: In-Use.
Expand All @@ -333,7 +333,7 @@ def _add_movable(hol_date: date, hol_name: str) -> None:
elif year == 2016:
self._add_holiday(name, NOV, 28)
elif year >= 2010:
_add_movable(date(year, NOV, 20), name)
add_movable_holiday(date(year, NOV, 20), name)


class AR(Argentina):
Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/canada.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Canada(HolidayBase, ChristianHolidays, InternationalHolidays):
"SK",
"YT",
)
supported_languages = ("en", "en_US", "fr", "th")
supported_languages = ("ar", "en", "en_US", "fr", "th")

def __init__(self, *args, **kwargs):
# Default subdivision to ON; prov for backwards compatibility
Expand Down
49 changes: 25 additions & 24 deletions holidays/countries/costa_rica.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,24 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def _populate(self, year):
def _add_movable(hol_name: str, hol_date: date) -> None:
def add_movable_holiday(name: str, dt: date) -> None:
# Law #9875 from 16.07.2020
if self.observed:
if not self._is_monday(hol_date):
hol_name = self.tr("%s (Observado)") % self.tr(hol_name)
if self._is_tuesday(hol_date) or self._is_wednesday(hol_date):
hol_date = _get_nth_weekday_from(-1, MON, hol_date)
if not self._is_monday(dt):
name = self.tr("%s (Observado)") % self.tr(name)

if self._is_tuesday(dt) or self._is_wednesday(dt):
dt = _get_nth_weekday_from(-1, MON, dt)
else:
hol_date = _get_nth_weekday_from(1, MON, hol_date)
self._add_holiday(hol_name, hol_date)
dt = _get_nth_weekday_from(1, MON, dt)
self._add_holiday(name, dt)

def _add_observed(hol_name: str, hol_date: date) -> None:
def add_observed_holiday(name: str, dt: date) -> None:
if self.observed:
if not (
self._is_monday(hol_date) or self._is_weekend(hol_date)
):
hol_date = _get_nth_weekday_from(1, MON, hol_date)
hol_name = self.tr("%s (Observado)") % self.tr(hol_name)
self._add_holiday(hol_name, hol_date)
if not (self._is_monday(dt) or self._is_weekend(dt)):
dt = _get_nth_weekday_from(1, MON, dt)
name = self.tr("%s (Observado)") % self.tr(name)
self._add_holiday(name, dt)

super()._populate(year)

Expand All @@ -71,16 +70,16 @@ def _add_observed(hol_name: str, hol_date: date) -> None:
# Juan Santamaría Day.
name = tr("Día de Juan Santamaría")
if 2006 <= year <= 2010:
_add_observed(name, dt)
add_observed_holiday(name, dt)
elif year in {2023, 2024}:
_add_movable(name, dt)
add_movable_holiday(name, dt)
else:
self._add_holiday(name, dt)

# International Labor Day.
name = tr("Día Internacional del Trabajo")
if year == 2021:
_add_movable(name, date(year, MAY, 1))
add_movable_holiday(name, date(year, MAY, 1))
else:
self._add_labor_day(name)

Expand All @@ -90,9 +89,9 @@ def _add_observed(hol_name: str, hol_date: date) -> None:
# Annexation of the Party of Nicoya to Costa Rica.
name = tr("Anexión del Partido de Nicoya a Costa Rica")
if 2005 <= year <= 2008:
_add_observed(name, dt)
add_observed_holiday(name, dt)
elif 2020 <= year <= 2024:
_add_movable(name, dt)
add_movable_holiday(name, dt)
else:
self._add_holiday(name, dt)

Expand All @@ -109,9 +108,9 @@ def _add_observed(hol_name: str, hol_date: date) -> None:
# Mother's Day.
name = tr("Día de la Madre")
if 2005 <= year <= 2007:
_add_observed(name, dt)
add_observed_holiday(name, dt)
elif year in {2020, 2023, 2024}:
_add_movable(name, dt)
add_movable_holiday(name, dt)
else:
self._add_holiday(name, dt)

Expand All @@ -131,22 +130,24 @@ def _add_observed(hol_name: str, hol_date: date) -> None:
# Independence Day.
name = tr("Día de la Independencia")
if year in {2020, 2021, 2022, 2024}:
_add_movable(name, dt)
add_movable_holiday(name, dt)
else:
self._add_holiday(name, dt)

# Law #9803 from 19.05.2020
if year <= 2019:
# Cultures Day.
_add_observed(tr("Día de las Culturas"), date(year, OCT, 12))
add_observed_holiday(
tr("Día de las Culturas"), date(year, OCT, 12)
)

# Law #9803 from 19.05.2020
if year >= 2020:
dt = date(year, DEC, 1)
# Army Abolition Day.
name = tr("Día de la Abolición del Ejército")
if year in {2020, 2021, 2022}:
_add_movable(name, dt)
add_movable_holiday(name, dt)
else:
self._add_holiday(name, dt)

Expand Down
3 changes: 2 additions & 1 deletion holidays/countries/ethiopia.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class Ethiopia(
):
country = "ET"
default_language = "am"
supported_languages = ("am", "en_US")
estimated_label = tr("%s* (*ግምት)")
supported_languages = ("am", "ar", "en_US")

@staticmethod
def _is_leap_year(year):
Expand Down
1 change: 0 additions & 1 deletion holidays/countries/pakistan.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

class Pakistan(HolidayBase, InternationalHolidays, IslamicHolidays):
country = "PK"
estimated_label = "estimated"

def __init__(self, *args, **kwargs):
InternationalHolidays.__init__(self)
Expand Down
6 changes: 3 additions & 3 deletions holidays/countries/serbia.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def _add_observed_holiday(
self, name: str, *dt: DateLike
) -> Optional[date]:
return self._add_holiday(
self.tr("%s (Слободан дан)") % self.tr(name), *dt
self.tr("%s (слободан дан)") % self.tr(name), *dt
)

def _populate(self, year):
super()._populate(year)

# New Year's Day.
name = self.tr("Нова година")
name = tr("Нова година")
self._add_new_years_day(name)
self._add_new_years_day_two(name)
if self.observed and self._is_weekend(JAN, 1):
Expand All @@ -58,7 +58,7 @@ def _populate(self, year):
self._add_christmas_day(tr("Божић"))

# Statehood Day.
name = self.tr("Дан државности Србије")
name = tr("Дан државности Србије")
self._add_holiday(name, FEB, 15)
self._add_holiday(name, FEB, 16)
if self.observed and self._is_weekend(FEB, 15):
Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/thailand.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def _add_observed(dt: date) -> None:
# This has its own in-lieu trigger.

if year >= 1948:
songkran_festival = self.tr("วันสงกรานต์")
songkran_festival = tr("วันสงกรานต์")
if year <= 1953 or (1957 <= year != 2020):
dt = self._add_holiday(
songkran_festival, APR, 12 if 1989 <= year <= 1997 else 13
Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/ukraine.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Ukraine(HolidayBase, ChristianHolidays, InternationalHolidays):

country = "UA"
default_language = "uk"
supported_languages = ("en_US", "uk")
supported_languages = ("ar", "en_US", "uk")

def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self, JULIAN_CALENDAR)
Expand Down
7 changes: 5 additions & 2 deletions holidays/holiday_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,12 +1064,15 @@ def _add_islamic_calendar_holiday(
holiday date is an estimation.
"""
added_dates = set()
estimated_label = getattr(self, "estimated_label", "estimated")
estimated_label = getattr(self, "estimated_label", "%s* (*estimated)")
for dt, is_estimated in dates:
if days_delta != 0:
dt += td(days=days_delta)

dt = self._add_holiday(
f"{name}* (*{estimated_label})" if is_estimated else name,
f"{self.tr(estimated_label) % self.tr(name)}"
if is_estimated
else name,
dt,
)
if dt:
Expand Down
38 changes: 20 additions & 18 deletions holidays/locale/am/LC_MESSAGES/ET.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Python Holidays 0.20\n"
"Project-Id-Version: Python Holidays 0.26\n"
"POT-Creation-Date: 2023-02-15 14:15-0800\n"
"PO-Revision-Date: 2023-02-16 08:42-0800\n"
"Last-Translator: Arkadii Yakovets <ark@cho.red>\n"
Expand All @@ -15,72 +15,74 @@ msgstr ""
"Generated-By: Lingua 4.15.0\n"
"X-Generator: Poedit 3.2.2\n"

#. Ethiopian New Year.
#: holidays/countries/ethiopia.py:64 holidays/countries/ethiopia.py:67
#: ./holidays/countries/ethiopia.py:74
msgid "አዲስ ዓመት እንቁጣጣሽ"
msgstr ""

#. Finding of True Cross.
#: holidays/countries/ethiopia.py:72 holidays/countries/ethiopia.py:75
#: ./holidays/countries/ethiopia.py:79
msgid "መስቀል"
msgstr ""

#. Orthodox Christmas.
#: holidays/countries/ethiopia.py:78
#: ./holidays/countries/ethiopia.py:83
msgid "ገና"
msgstr ""

#. Orthodox Epiphany.
#: holidays/countries/ethiopia.py:81
#: ./holidays/countries/ethiopia.py:86
msgid "ጥምቀት"
msgstr ""

#. Orthodox Good Friday.
#: holidays/countries/ethiopia.py:85
#: ./holidays/countries/ethiopia.py:89
msgid "ስቅለት"
msgstr ""

#. Orthodox Easter Sunday.
#: holidays/countries/ethiopia.py:88
#: ./holidays/countries/ethiopia.py:92
msgid "ፋሲካ"
msgstr ""

#. Adwa Victory Day.
#: holidays/countries/ethiopia.py:92
#: ./holidays/countries/ethiopia.py:96
msgid "አድዋ"
msgstr ""

#. Labour Day.
#: holidays/countries/ethiopia.py:95
#: ./holidays/countries/ethiopia.py:99
msgid "የሰራተኞች ቀን"
msgstr ""

#. Patriots Day.
#: holidays/countries/ethiopia.py:99
#: ./holidays/countries/ethiopia.py:103
msgid "የአርበኞች ቀን"
msgstr ""

#. Downfall of Dergue Regime Day.
#: holidays/countries/ethiopia.py:103
#: ./holidays/countries/ethiopia.py:107
msgid "ደርግ የወደቀበት ቀን"
msgstr ""

#. Downfall of King Haile Selassie.
#: holidays/countries/ethiopia.py:107
#: ./holidays/countries/ethiopia.py:112
msgid "ደርግ የመጣበት ቀን"
msgstr ""

#. Eid al-Fitr.
#: holidays/countries/ethiopia.py:121
#: ./holidays/countries/ethiopia.py:116
msgid "ኢድ አልፈጥር"
msgstr ""

#. Eid al-Adha.
#: holidays/countries/ethiopia.py:128
#: ./holidays/countries/ethiopia.py:119
msgid "አረፋ"
msgstr ""

#. Prophet Muhammad's Birthday.
#: holidays/countries/ethiopia.py:134
#: ./holidays/countries/ethiopia.py:124
msgid "መውሊድ"
msgstr ""

#: ./holidays/countries/ethiopia.py:39
#, c-format
msgid "%s* (*ግምት)"
msgstr ""
Loading