Skip to content

Commit

Permalink
Add Vietnames translation of Viet Holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
vunhatchuong committed Sep 27, 2024
1 parent ba4ed6f commit adf6637
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 30 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,4 @@ Victor Luna
Victor Miti
Ville Skyttä
Youhei Sakurai
Vu Nhat Chuong
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ All other default values are highlighted with bold:
* - Vietnam
- VN
-
-
- en_US, **vi**
-
* - Virgin Islands (U.S.)
- VI
Expand Down
31 changes: 18 additions & 13 deletions holidays/countries/vietnam.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)

from gettext import gettext as tr

from holidays.groups import ChineseCalendarHolidays, InternationalHolidays
from holidays.observed_holiday_base import ObservedHolidayBase, SAT_SUN_TO_NEXT_WORKDAY
from holidays.observed_holiday_base import SAT_SUN_TO_NEXT_WORKDAY, ObservedHolidayBase


class Vietnam(ObservedHolidayBase, ChineseCalendarHolidays, InternationalHolidays):
Expand All @@ -22,7 +24,10 @@ class Vietnam(ObservedHolidayBase, ChineseCalendarHolidays, InternationalHoliday
"""

country = "VN"
observed_label = "%s (observed)"
# %s (observed).
observed_label = tr("%s (nghỉ bù)")
default_language = "vi"
supported_languages = ("en_US", "vi")

def __init__(self, *args, **kwargs):
ChineseCalendarHolidays.__init__(self)
Expand All @@ -34,29 +39,29 @@ def _populate_public_holidays(self):
dts_observed = set()

# New Year's Day
dts_observed.add(self._add_new_years_day("International New Year's Day"))
dts_observed.add(self._add_new_years_day(tr("Tết Dương lịch")))

# Lunar New Year
self._add_chinese_new_years_eve("Vietnamese New Year's Eve")
self._add_chinese_new_years_day("Vietnamese New Year")
self._add_chinese_new_years_day_two("The second day of Tet Holiday")
self._add_chinese_new_years_day_three("The third day of Tet Holiday")
self._add_chinese_new_years_day_four("The forth day of Tet Holiday")
self._add_chinese_new_years_day_five("The fifth day of Tet Holiday")
self._add_chinese_new_years_eve(tr("Giao thừa"))
self._add_chinese_new_years_day(tr("Tết Nguyên Đán"))
self._add_chinese_new_years_day_two(tr("Mùng hai Tết Nguyên Đán"))
self._add_chinese_new_years_day_three(tr("Mùng ba Tết Nguyên Đán"))
self._add_chinese_new_years_day_four(tr("Mùng bốn Tết Nguyên Đán"))
self._add_chinese_new_years_day_five(tr("Mùng năm Tết Nguyên Đán"))

# Vietnamese Kings' Commemoration Day
# https://en.wikipedia.org/wiki/H%C3%B9ng_Kings%27_Festival
if self._year >= 2007:
dts_observed.add(self._add_hung_kings_day("Hung Kings Commemoration Day"))
dts_observed.add(self._add_hung_kings_day(tr("Giỗ Tổ Hùng Vương")))

# Liberation Day/Reunification Day
dts_observed.add(self._add_holiday_apr_30("Liberation Day/Reunification Day"))
dts_observed.add(self._add_holiday_apr_30(tr("Ngày Chiến thắng")))

# International Labor Day
dts_observed.add(self._add_labor_day("International Labor Day"))
dts_observed.add(self._add_labor_day(tr("Ngày Quốc tế lao động")))

# Independence Day
dts_observed.add(self._add_holiday_sep_2("Independence Day"))
dts_observed.add(self._add_holiday_sep_2(tr("Ngày Quốc khánh")))

if self.observed:
self._populate_observed(dts_observed)
Expand Down
77 changes: 77 additions & 0 deletions holidays/locale/en_US/LC_MESSAGES/VN.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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 <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)
# 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: vunhatchuong <ronnyvu321@gmail.com> (c) 2024
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)
#
# Vietnam holidays en_US localization.
msgid ""
msgstr ""
"Project-Id-Version: Python Holidays 0.58\n"
"POT-Creation-Date: 2024-09-27 15:50+0700\n"
"PO-Revision-Date: 2024-09-27 15:50+0700\n"
"Last-Translator: Vu Nhat Chuong <ronnyvu321@gmail.com>\n"
"Language-Team: Python Holidays Localization Team\n"
"Language: vi\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Lingva 5.0.4\n"

#. %s (observed).
#, c-format
msgid "%s (nghỉ bù)"
msgstr "%s (observed)"

#. New Year's Day
msgid "Tết Dương lịch"
msgstr "International New Year's Day"

#. Lunar New Year
msgid "Giao thừa"
msgstr "Vietnamese New Year's Eve"

msgid "Tết Nguyên Đán"
msgstr "Vietnamese New Year"

msgid "Mùng hai Tết Nguyên Đán"
msgstr "The second day of Tet Holiday"

msgid "Mùng ba Tết Nguyên Đán"
msgstr "The third day of Tet Holiday"

msgid "Mùng bốn Tết Nguyên Đán"
msgstr "The forth day of Tet Holiday"

msgid "Mùng năm Tết Nguyên Đán"
msgstr "The fifth day of Tet Holiday"

msgid "Giỗ Tổ Hùng Vương"
msgstr "Hung Kings Commemoration Day"

#. Liberation Day/Reunification Day
msgid "Ngày Chiến thắng"
msgstr "Liberation Day/Reunification Day"

#. International Labor Day
msgid "Ngày Quốc tế lao động"
msgstr "International Labor Day"

#. Independence Day
msgid "Ngày Quốc khánh"
msgstr "Independence Day"
77 changes: 77 additions & 0 deletions holidays/locale/vi/LC_MESSAGES/VN.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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 <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)
# 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: vunhatchuong <ronnyvu321@gmail.com> (c) 2024
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)
#
# Vietnam holidays.
msgid ""
msgstr ""
"Project-Id-Version: Python Holidays 0.58\n"
"POT-Creation-Date: 2024-09-27 15:50+0700\n"
"PO-Revision-Date: 2024-09-27 15:50+0700\n"
"Last-Translator: Vu Nhat Chuong <ronnyvu321@gmail.com>\n"
"Language-Team: Python Holidays Localization Team\n"
"Language: vi\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Lingva 5.0.4\n"

#. %s (observed).
#, c-format
msgid "%s (nghỉ bù)"
msgstr ""

#. New Year's Day
msgid "Tết Dương lịch"
msgstr ""

#. Lunar New Year
msgid "Giao thừa"
msgstr ""

msgid "Tết Nguyên Đán"
msgstr ""

msgid "Mùng hai Tết Nguyên Đán"
msgstr ""

msgid "Mùng ba Tết Nguyên Đán"
msgstr ""

msgid "Mùng bốn Tết Nguyên Đán"
msgstr ""

msgid "Mùng năm Tết Nguyên Đán"
msgstr ""

msgid "Giỗ Tổ Hùng Vương"
msgstr ""

#. Liberation Day/Reunification Day
msgid "Ngày Chiến thắng"
msgstr ""

#. International Labor Day
msgid "Ngày Quốc tế lao động"
msgstr ""

#. Independence Day
msgid "Ngày Quốc khánh"
msgstr ""
67 changes: 51 additions & 16 deletions tests/countries/test_vietnam.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ def test_country_aliases(self):

def test_common(self):
self.assertHolidayName(
"International New Year's Day",
"Tết Dương lịch",
"2020-01-01",
)

def test_first_day_of_january(self):
self.assertHolidayName(
"International New Year's Day", (f"{year}-01-01" for year in range(1979, 2050))
)
self.assertHolidayName("Tết Dương lịch", (f"{year}-01-01" for year in range(1979, 2050)))

def test_lunar_new_year(self):
for dts in (
Expand All @@ -57,33 +55,31 @@ def test_lunar_new_year(self):
(2022, 2, 1),
):
dt = date(*dts)
self.assertHolidayName("Vietnamese New Year's Eve", _timedelta(dt, -1))
self.assertHolidayName("Vietnamese New Year", dt)
self.assertHolidayName("The second day of Tet Holiday", _timedelta(dt, +1))
self.assertHolidayName("The third day of Tet Holiday", _timedelta(dt, +2))
self.assertHolidayName("The forth day of Tet Holiday", _timedelta(dt, +3))
self.assertHolidayName("The fifth day of Tet Holiday", _timedelta(dt, +4))
self.assertHolidayName("Giao thừa", _timedelta(dt, -1))
self.assertHolidayName("Tết Nguyên Đán", dt)
self.assertHolidayName("Mùng hai Tết Nguyên Đán", _timedelta(dt, +1))
self.assertHolidayName("Mùng ba Tết Nguyên Đán", _timedelta(dt, +2))
self.assertHolidayName("Mùng bốn Tết Nguyên Đán", _timedelta(dt, +3))
self.assertHolidayName("Mùng năm Tết Nguyên Đán", _timedelta(dt, +4))

def test_king_hung_day(self):
self.assertHolidayName(
"Hung Kings Commemoration Day",
"Giỗ Tổ Hùng Vương",
"2020-04-02",
"2021-04-21",
"2022-04-10",
)

def test_liberation_day(self):
self.assertHolidayName(
"Liberation Day/Reunification Day", (f"{year}-04-30" for year in range(1979, 2050))
)
self.assertHolidayName("Ngày Chiến thắng", (f"{year}-04-30" for year in range(1979, 2050)))

def test_international_labor_day(self):
self.assertHolidayName(
"International Labor Day", (f"{year}-05-01" for year in range(1979, 2050))
"Ngày Quốc tế lao động", (f"{year}-05-01" for year in range(1979, 2050))
)

def test_independence_day(self):
self.assertHolidayName("Independence Day", (f"{year}-09-02" for year in range(1979, 2050)))
self.assertHolidayName("Ngày Quốc khánh", (f"{year}-09-02" for year in range(1979, 2050)))

def test_observed(self):
observed_holidays = (
Expand Down Expand Up @@ -116,3 +112,42 @@ def test_observed(self):
)
self.assertHoliday(observed_holidays)
self.assertNoNonObservedHoliday(observed_holidays)

def test_l10n_default(self):
self.assertLocalizedHolidays(
("2022-01-01", "Tết Dương lịch"),
("2022-01-03", "Tết Dương lịch (nghỉ bù)"),
("2022-01-31", "Giao thừa"),
("2022-02-01", "Tết Nguyên Đán"),
("2022-02-02", "Mùng hai Tết Nguyên Đán"),
("2022-02-03", "Mùng ba Tết Nguyên Đán"),
("2022-02-04", "Mùng bốn Tết Nguyên Đán"),
("2022-02-05", "Mùng năm Tết Nguyên Đán"),
("2022-04-10", "Giỗ Tổ Hùng Vương"),
("2022-04-11", "Giỗ Tổ Hùng Vương (nghỉ bù)"),
("2022-04-30", "Ngày Chiến thắng"),
("2022-05-01", "Ngày Quốc tế lao động"),
("2022-05-02", "Ngày Chiến thắng (nghỉ bù)"),
("2022-05-03", "Ngày Quốc tế lao động (nghỉ bù)"),
("2022-09-02", "Ngày Quốc khánh"),
)

def test_l10n_en_us(self):
self.assertLocalizedHolidays(
"en_US",
("2022-01-01", "International New Year's Day"),
("2022-01-03", "International New Year's Day (observed)"),
("2022-01-31", "Vietnamese New Year's Eve"),
("2022-02-01", "Vietnamese New Year"),
("2022-02-02", "The second day of Tet Holiday"),
("2022-02-03", "The third day of Tet Holiday"),
("2022-02-04", "The forth day of Tet Holiday"),
("2022-02-05", "The fifth day of Tet Holiday"),
("2022-04-10", "Hung Kings Commemoration Day"),
("2022-04-11", "Hung Kings Commemoration Day (observed)"),
("2022-04-30", "Liberation Day/Reunification Day"),
("2022-05-01", "International Labor Day"),
("2022-05-02", "Liberation Day/Reunification Day (observed)"),
("2022-05-03", "International Labor Day (observed)"),
("2022-09-02", "Independence Day"),
)

0 comments on commit adf6637

Please sign in to comment.