Skip to content

Commit

Permalink
fix: use correct lang separator for frappe
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Aug 7, 2023
1 parent 5435c64 commit 0218ca5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion erpnext/setup/doctype/holiday_list/holiday_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@ def is_holiday(holiday_list, date=None):

def local_country_name(country_code: str) -> str:
"""Return the localized country name for the given country code."""
return Locale.parse(frappe.local.lang).territories.get(country_code, country_code)
return Locale.parse(frappe.local.lang, sep="-").territories.get(country_code, country_code)
12 changes: 12 additions & 0 deletions erpnext/setup/doctype/holiday_list/test_holiday_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import frappe
from frappe.utils import getdate

from erpnext.setup.doctype.holiday_list.holiday_list import local_country_name


class TestHolidayList(unittest.TestCase):
def test_holiday_list(self):
Expand Down Expand Up @@ -58,6 +60,16 @@ def test_local_holidays(self):
self.assertIn(date(2023, 4, 10), holidays)
self.assertNotIn(date(2023, 5, 1), holidays)

def test_localized_country_names(self):
lang = frappe.local.lang
frappe.local.lang = "en-gb"
self.assertEqual(local_country_name("IN"), "India")
self.assertEqual(local_country_name("DE"), "Germany")

frappe.local.lang = "de"
self.assertEqual(local_country_name("DE"), "Deutschland")
frappe.local.lang = lang


def make_holiday_list(
name, from_date=getdate() - timedelta(days=10), to_date=getdate(), holiday_dates=None
Expand Down

0 comments on commit 0218ca5

Please sign in to comment.