Skip to content

Commit

Permalink
Add Vietnamese translation of VietNam holidays (#2025)
Browse files Browse the repository at this point in the history
Co-authored-by: Arkadii Yakovets <[email protected]>
  • Loading branch information
vunhatchuong and arkid15r authored Oct 3, 2024
1 parent 4232fcb commit 8890983
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 36 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,5 @@ Tudor Văran
Victor Luna
Victor Miti
Ville Skyttä
Vu Nhat Chuong
Youhei Sakurai
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
46 changes: 30 additions & 16 deletions holidays/countries/vietnam.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.groups import ChineseCalendarHolidays, InternationalHolidays
from holidays.observed_holiday_base import ObservedHolidayBase, SAT_SUN_TO_NEXT_WORKDAY

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,38 @@ 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's Eve
self._add_chinese_new_years_eve(tr("Giao thừa Tết Nguyên Đán"))

# 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")

# Vietnamese Kings' Commemoration Day
# https://en.wikipedia.org/wiki/H%C3%B9ng_Kings%27_Festival
self._add_chinese_new_years_day(tr("Tết Nguyên Đán"))

# Second Day of Lunar New Year
self._add_chinese_new_years_day_two(tr("Mùng hai Tết Nguyên Đán"))

# Third Day of Lunar New Year
self._add_chinese_new_years_day_three(tr("Mùng ba Tết Nguyên Đán"))

# Fourth Day of Lunar New Year
self._add_chinese_new_years_day_four(tr("Mùng bốn Tết Nguyên Đán"))

# Fifth Day of Lunar New Year
self._add_chinese_new_years_day_five(tr("Mùng năm Tết Nguyên Đán"))

if self._year >= 2007:
dts_observed.add(self._add_hung_kings_day("Hung Kings Commemoration Day"))
# Hung Kings' Commemoration Day
dts_observed.add(self._add_hung_kings_day(tr("Ngày 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"))
# National Day
dts_observed.add(self._add_holiday_sep_2(tr("Quốc khánh")))

if self.observed:
self._populate_observed(dts_observed)
Expand Down
75 changes: 75 additions & 0 deletions holidays/locale/en_US/LC_MESSAGES/VN.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# 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)
#
# 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 <[email protected]>\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 "New Year's Day"

#. Lunar New Year's Eve
msgid "Giao thừa Tết Nguyên Đán"
msgstr "Lunar New Year's Eve"

#. Lunar New Year
msgid "Tết Nguyên Đán"
msgstr "Lunar New Year"

#. Second Day of Lunar New Year
msgid "Mùng hai Tết Nguyên Đán"
msgstr "The second day of Tet Holiday"

#. Third Day of Lunar New Year
msgid "Mùng ba Tết Nguyên Đán"
msgstr "The third day of Tet Holiday"

#. Fourth Day of Lunar New Year
msgid "Mùng bốn Tết Nguyên Đán"
msgstr "The fourth day of Tet Holiday"

#. Fifth Day of Lunar New Year
msgid "Mùng năm Tết Nguyên Đán"
msgstr "The fifth day of Tet Holiday"

#. Hung Kings' Commemoration Day
msgid "Ngày 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"

#. National Day
msgid "Quốc khánh"
msgstr "National Day"
75 changes: 75 additions & 0 deletions holidays/locale/vi/LC_MESSAGES/VN.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# 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)
#
# 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 <[email protected]>\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's Eve
msgid "Giao thừa Tết Nguyên Đán"
msgstr ""

#. Lunar New Year
msgid "Tết Nguyên Đán"
msgstr ""

#. Second Day of Lunar New Year
msgid "Mùng hai Tết Nguyên Đán"
msgstr ""

#. Third Day of Lunar New Year
msgid "Mùng ba Tết Nguyên Đán"
msgstr ""

#. Fourth Day of Lunar New Year
msgid "Mùng bốn Tết Nguyên Đán"
msgstr ""

#. Fifth Day of Lunar New Year
msgid "Mùng năm Tết Nguyên Đán"
msgstr ""

#. Hung Kings' Commemoration Day
msgid "Ngày 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 ""

#. National Day
msgid "Quốc khánh"
msgstr ""
73 changes: 54 additions & 19 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,41 +55,39 @@ 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 Tết Nguyên Đán", _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",
"Ngày 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("Quốc khánh", (f"{year}-09-02" for year in range(1979, 2050)))

def test_observed(self):
observed_holidays = (
# International New Year's Day.
# New Year's Day.
"2012-01-02",
"2017-01-02",
"2022-01-03",
# Hung Kings Commemoration Day.
# Hung Kings' Commemoration Day.
"2012-04-02",
"2016-04-18",
"2019-04-15",
Expand All @@ -108,11 +104,50 @@ def test_observed(self):
"2016-05-03",
"2021-05-03",
"2022-05-03",
# Independence Day.
# National Day.
"2012-09-03",
"2017-09-04",
"2018-09-03",
"2023-09-04",
)
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 Tết Nguyên Đán"),
("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", "Ngày Giỗ Tổ Hùng Vương"),
("2022-04-11", "Ngày 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", "Quốc khánh"),
)

def test_l10n_en_us(self):
self.assertLocalizedHolidays(
"en_US",
("2022-01-01", "New Year's Day"),
("2022-01-03", "New Year's Day (observed)"),
("2022-01-31", "Lunar New Year's Eve"),
("2022-02-01", "Lunar New Year"),
("2022-02-02", "The second day of Tet Holiday"),
("2022-02-03", "The third day of Tet Holiday"),
("2022-02-04", "The fourth 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", "National Day"),
)

0 comments on commit 8890983

Please sign in to comment.