From 8890983e4cc56ed1298a2bad135977ee8e1ea349 Mon Sep 17 00:00:00 2001 From: Vu Nhat Chuong Date: Fri, 4 Oct 2024 00:07:24 +0700 Subject: [PATCH] Add Vietnamese translation of VietNam holidays (#2025) Co-authored-by: Arkadii Yakovets --- AUTHORS | 1 + README.rst | 2 +- holidays/countries/vietnam.py | 46 +++++++++------ holidays/locale/en_US/LC_MESSAGES/VN.po | 75 +++++++++++++++++++++++++ holidays/locale/vi/LC_MESSAGES/VN.po | 75 +++++++++++++++++++++++++ tests/countries/test_vietnam.py | 73 +++++++++++++++++------- 6 files changed, 236 insertions(+), 36 deletions(-) create mode 100644 holidays/locale/en_US/LC_MESSAGES/VN.po create mode 100644 holidays/locale/vi/LC_MESSAGES/VN.po diff --git a/AUTHORS b/AUTHORS index 8b3f50ac3..d953d5be4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -139,4 +139,5 @@ Tudor Văran Victor Luna Victor Miti Ville Skyttä +Vu Nhat Chuong Youhei Sakurai diff --git a/README.rst b/README.rst index 9aefd8b66..3ba8704aa 100644 --- a/README.rst +++ b/README.rst @@ -933,7 +933,7 @@ All other default values are highlighted with bold: * - Vietnam - VN - - - + - en_US, **vi** - * - Virgin Islands (U.S.) - VI diff --git a/holidays/countries/vietnam.py b/holidays/countries/vietnam.py index fe2583f9d..fb69207d6 100644 --- a/holidays/countries/vietnam.py +++ b/holidays/countries/vietnam.py @@ -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 @@ -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) @@ -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) diff --git a/holidays/locale/en_US/LC_MESSAGES/VN.po b/holidays/locale/en_US/LC_MESSAGES/VN.po new file mode 100644 index 000000000..eee784a26 --- /dev/null +++ b/holidays/locale/en_US/LC_MESSAGES/VN.po @@ -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 (c) 2017-2023 +# ryanss (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 \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" diff --git a/holidays/locale/vi/LC_MESSAGES/VN.po b/holidays/locale/vi/LC_MESSAGES/VN.po new file mode 100644 index 000000000..b06a231a3 --- /dev/null +++ b/holidays/locale/vi/LC_MESSAGES/VN.po @@ -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 (c) 2017-2023 +# ryanss (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 \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 "" diff --git a/tests/countries/test_vietnam.py b/tests/countries/test_vietnam.py index e8fe354fd..b88a78eec 100644 --- a/tests/countries/test_vietnam.py +++ b/tests/countries/test_vietnam.py @@ -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 ( @@ -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", @@ -108,7 +104,7 @@ 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", @@ -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 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"), + )