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

Introduce observed_estimated_label #1633

Merged
merged 6 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion holidays/countries/azerbaijan.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ class Azerbaijan(ObservedHolidayBase, InternationalHolidays, IslamicHolidays, St

country = "AZ"
default_language = "az"
# Estimated label.
# %s (estimated).
estimated_label = tr("%s (təxmini)")
# %s (observed).
observed_label = tr("%s (müşahidə olunur)")
# %s (observed, estimated).
observed_estimated_label = tr("%s (müşahidə olunur, təxmini)")
supported_categories = (PUBLIC, WORKDAY)
supported_languages = ("az", "en_US", "uk")

Expand Down
4 changes: 4 additions & 0 deletions holidays/countries/brunei.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ class Brunei(

country = "BN"
default_language = "ms"
# %s (estimated).
estimated_label = tr("%s (anggaran)")
# %s (observed).
observed_label = tr("%s (diperhatikan)")
# %s (observed, estimated).
observed_estimated_label = tr("%s (diperhatikan, anggaran")
arkid15r marked this conversation as resolved.
Show resolved Hide resolved
supported_languages = ("en_US", "ms", "th")

def __init__(self, *args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions holidays/countries/saudi_arabia.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class SaudiArabia(ObservedHolidayBase, IslamicHolidays, StaticHolidays):
estimated_label = tr("(تقدير) %s")
# %s (observed).
observed_label = tr("(ملاحظة) %s")
# %s (observed, estimated).
observed_estimated_label = tr("(تقدير ملاحظة) %s")
supported_languages = ("ar", "en_US")

def __init__(self, *args, **kwargs):
Expand Down
6 changes: 4 additions & 2 deletions holidays/countries/uzbekistan.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ class Uzbekistan(ObservedHolidayBase, InternationalHolidays, IslamicHolidays, St

country = "UZ"
default_language = "uz"
# Estimated label.
# %s (estimated).
estimated_label = tr("%s (taxminiy)")
# %s (Observed).
# %s (observed).
observed_label = tr("%s (ko‘chirilgan)")
# %s (observed, estimated).
observed_estimated_label = tr("%s (ko‘chirilgan, taxminiy)")
supported_languages = ("en_US", "uk", "uz")

def __init__(self, *args, **kwargs):
Expand Down
7 changes: 6 additions & 1 deletion holidays/locale/ar/LC_MESSAGES/SA.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.30\n"
"Project-Id-Version: Python Holidays 0.41\n"
"POT-Creation-Date: 2023-08-04 20:02+0300\n"
"PO-Revision-Date: 2023-08-04 20:05+0300\n"
"Last-Translator: ~Jhellico <[email protected]>\n"
Expand Down Expand Up @@ -49,3 +49,8 @@ msgstr ""
#. Founding Day
msgid "يوم التأسيسي"
msgstr ""

#. %s (observed, estimated).
#, c-format
msgid "(تقدير ملاحظة) %s"
msgstr ""
9 changes: 7 additions & 2 deletions holidays/locale/az/LC_MESSAGES/AZ.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.39\n"
"Project-Id-Version: Python Holidays 0.41\n"
"POT-Creation-Date: 2023-11-15 20:42+0200\n"
"PO-Revision-Date: 2023-11-15 20:47+0200\n"
"Last-Translator: ~Jhellico <[email protected]>\n"
Expand All @@ -16,7 +16,7 @@ msgstr ""
"Generated-By: Lingua 4.15.0\n"
"X-Generator: Poedit 3.4\n"

#. Estimated label.
#. %s (estimated).
#, c-format
msgid "%s (təxmini)"
msgstr ""
Expand Down Expand Up @@ -118,3 +118,8 @@ msgstr ""
#, c-format
msgid "İstirahət günü (%s ilə əvəz edilmişdir)"
msgstr ""

#. %s (observed, estimated).
#, c-format
msgid "%s (müşahidə olunur, təxmini)"
msgstr ""
9 changes: 7 additions & 2 deletions holidays/locale/en_US/LC_MESSAGES/AZ.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.39\n"
"Project-Id-Version: Python Holidays 0.41\n"
"POT-Creation-Date: 2023-11-15 20:42+0200\n"
"PO-Revision-Date: 2023-11-15 20:52+0200\n"
"Last-Translator: ~Jhellico <[email protected]>\n"
Expand All @@ -16,7 +16,7 @@ msgstr ""
"Generated-By: Lingua 4.15.0\n"
"X-Generator: Poedit 3.4\n"

#. Estimated label.
#. %s (estimated).
#, c-format
msgid "%s (təxmini)"
msgstr "%s (estimated)"
Expand Down Expand Up @@ -118,3 +118,8 @@ msgstr "%m/%d/%Y"
#, c-format
msgid "İstirahət günü (%s ilə əvəz edilmişdir)"
msgstr "Day off (substituted from %s)"

#. %s (observed, estimated).
#, c-format
msgid "%s (müşahidə olunur, təxmini)"
msgstr "%s (observed, estimated)"
7 changes: 7 additions & 0 deletions holidays/locale/en_US/LC_MESSAGES/BN.po
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ msgstr ""
msgid "Jubli Emas Sultan Hassanal Bolkiah"
msgstr "Sultan Hassanal Bolkiah's Golden Jubilee"

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

#. %s (observed).
#, c-format
msgid "%s (diperhatikan)"
msgstr "%s (observed)"
Expand Down Expand Up @@ -78,3 +80,8 @@ msgstr "Islamic New Year"
#. Birth of the Prophet
msgid "Maulidur Rasul"
msgstr "Birth of the Prophet"

#. %s (observed, estimated).
#, c-format
msgid "%s (diperhatikan, anggaran"
arkid15r marked this conversation as resolved.
Show resolved Hide resolved
msgstr "%s (observed, estimated)"
7 changes: 6 additions & 1 deletion holidays/locale/en_US/LC_MESSAGES/SA.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.30\n"
"Project-Id-Version: Python Holidays 0.41\n"
"POT-Creation-Date: 2023-08-04 20:02+0300\n"
"PO-Revision-Date: 2023-08-04 20:03+0300\n"
"Last-Translator: ~Jhellico <[email protected]>\n"
Expand Down Expand Up @@ -49,3 +49,8 @@ msgstr "National Day Holiday"
#. Founding Day
msgid "يوم التأسيسي"
msgstr "Founding Day Holiday"

#. %s (observed, estimated).
#, c-format
msgid "(تقدير ملاحظة) %s"
msgstr "%s (observed, estimated)"
11 changes: 8 additions & 3 deletions holidays/locale/en_US/LC_MESSAGES/UZ.po
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ msgstr "Eid al-Fitr"
msgid "Qurbon hayit"
msgstr "Eid al-Adha"

#. Estimated label.
#. %s (estimated).
#, c-format
msgid "%s (taxminiy)"
msgstr "%s (estimated)"

#. %s (Observed).
#. %s (observed).
#, c-format
msgid "%s (ko‘chirilgan)"
msgstr "%s (Observed)"
msgstr "%s (observed)"

#. Date format (see strftime() Format Codes)
msgid "%d/%m %Y"
Expand All @@ -78,3 +78,8 @@ msgstr "Day off (substituted from %s)"
#. Additional day off by Presidential decree.
msgid "Prezidentining farmoni bilan qo‘shimcha dam olish kuni"
msgstr "Additional day off by Presidential decree"

#. %s (observed, estimated).
#, c-format
msgid "%s (ko‘chirilgan, taxminiy)"
msgstr "%s (observed, estimated)"
7 changes: 7 additions & 0 deletions holidays/locale/ms/LC_MESSAGES/BN.po
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ msgstr ""
msgid "Jubli Emas Sultan Hassanal Bolkiah"
msgstr ""

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

#. %s (observed).
#, c-format
msgid "%s (diperhatikan)"
msgstr ""
Expand Down Expand Up @@ -78,3 +80,8 @@ msgstr ""
#. Birth of the Prophet
msgid "Maulidur Rasul"
msgstr ""

#. %s (observed, estimated).
#, c-format
msgid "%s (diperhatikan, anggaran"
arkid15r marked this conversation as resolved.
Show resolved Hide resolved
msgstr ""
7 changes: 7 additions & 0 deletions holidays/locale/th/LC_MESSAGES/BN.po
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ msgstr ""
msgid "Jubli Emas Sultan Hassanal Bolkiah"
msgstr "พระราชพิธีกาญจนาภิเษกสมเด็จพระราชาธิบดีสุลต่านฮัสซานัล โบลเกียห์"

#. %s (estimated).
#, c-format
msgid "%s (anggaran)"
msgstr "%s (โดยประมาณ)"

#. %s (observed).
#, c-format
msgid "%s (diperhatikan)"
msgstr "ชดเชย%s"
Expand Down Expand Up @@ -78,3 +80,8 @@ msgstr "วันขึ้นปีใหม่อิสลาม"
#. Birth of the Prophet
msgid "Maulidur Rasul"
msgstr "วันเมาลิดนบี"

#. %s (observed, estimated).
#, c-format
msgid "%s (diperhatikan, anggaran"
msgstr "%ชดเชย%s, โดยประมาณ"
arkid15r marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 7 additions & 2 deletions holidays/locale/uk/LC_MESSAGES/AZ.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.39\n"
"Project-Id-Version: Python Holidays 0.41\n"
"POT-Creation-Date: 2023-11-15 20:42+0200\n"
"PO-Revision-Date: 2023-11-15 20:55+0200\n"
"Last-Translator: ~Jhellico <[email protected]>\n"
Expand All @@ -16,7 +16,7 @@ msgstr ""
"Generated-By: Lingua 4.15.0\n"
"X-Generator: Poedit 3.4\n"

#. Estimated label.
#. %s (estimated).
#, c-format
msgid "%s (təxmini)"
msgstr "%s (приблизна дата)"
Expand Down Expand Up @@ -118,3 +118,8 @@ msgstr "%d.%m.%Y"
#, c-format
msgid "İstirahət günü (%s ilə əvəz edilmişdir)"
msgstr "Вихідний день (перенесено з %s)"

#. %s (observed, estimated).
#, c-format
msgid "%s (müşahidə olunur, təxmini)"
msgstr "%s (вихідний, приблизна дата)"
9 changes: 7 additions & 2 deletions holidays/locale/uk/LC_MESSAGES/UZ.po
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ msgstr "Рамазан-байрам"
msgid "Qurbon hayit"
msgstr "Курбан-байрам"

#. Estimated label.
#. %s (estimated).
#, c-format
msgid "%s (taxminiy)"
msgstr "%s (приблизна дата)"

#. %s (Observed).
#. %s (observed).
#, c-format
msgid "%s (ko‘chirilgan)"
msgstr "%s (вихідний)"
Expand All @@ -78,3 +78,8 @@ msgstr "Вихідний день (перенесено з %s)"
#. Additional day off by Presidential decree.
msgid "Prezidentining farmoni bilan qo‘shimcha dam olish kuni"
msgstr "Додатковий вихідний згідно указу Президента"

#. %s (observed, estimated).
#, c-format
msgid "%s (ko‘chirilgan, taxminiy)"
msgstr "%s (вихідний, приблизна дата)"
9 changes: 7 additions & 2 deletions holidays/locale/uz/LC_MESSAGES/UZ.po
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ msgstr ""
msgid "Qurbon hayit"
msgstr ""

#. Estimated label.
#. %s (estimated).
#, c-format
msgid "%s (taxminiy)"
msgstr ""

#. %s (Observed).
#. %s (observed).
#, c-format
msgid "%s (ko‘chirilgan)"
msgstr ""
Expand All @@ -78,3 +78,8 @@ msgstr ""
#. Additional day off by Presidential decree.
msgid "Prezidentining farmoni bilan qo‘shimcha dam olish kuni"
msgstr ""

#. %s (observed, estimated).
#, c-format
msgid "%s (ko‘chirilgan, taxminiy)"
msgstr ""
25 changes: 20 additions & 5 deletions holidays/observed_holiday_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,28 @@ def _add_observed(
if dt_observed == dt:
return False, dt

observed_label = getattr(
self,
"observed_label_before" if dt_observed < dt else "observed_label",
self.observed_label,
estimated_label = self.tr(getattr(self, "estimated_label", ""))
observed_label = self.tr(
getattr(
self,
"observed_label_before" if dt_observed < dt else "observed_label",
self.observed_label,
)
)

estimated_label_text = estimated_label.strip("%s ()")
# Use observed_estimated_label instead of observed_label for estimated dates.
for name in (name,) if name else self.get_list(dt):
super()._add_holiday(self.tr(observed_label) % self.tr(name), dt_observed)
holiday_name = self.tr(name)
observed_estimated_label = None
if len(estimated_label_text) > 0 and estimated_label_text in holiday_name:
holiday_name = holiday_name.replace(f"({estimated_label_text})", "").strip()
observed_estimated_label = self.tr(getattr(self, "observed_estimated_label"))

super()._add_holiday(
(observed_estimated_label or observed_label) % holiday_name, dt_observed
)

return True, dt_observed

def _move_holiday(self, dt: date, rule: Optional[ObservedRule] = None) -> Tuple[bool, date]:
Expand Down
Loading