Merge pull request #36519 from ankush/lang_separator
fix: use correct lang separator for frappe
This commit is contained in:
commit
10a2191e3f
@ -6,7 +6,6 @@ import json
|
|||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from babel import Locale
|
|
||||||
from frappe import _, throw
|
from frappe import _, throw
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import formatdate, getdate, today
|
from frappe.utils import formatdate, getdate, today
|
||||||
@ -169,4 +168,6 @@ def is_holiday(holiday_list, date=None):
|
|||||||
|
|
||||||
def local_country_name(country_code: str) -> str:
|
def local_country_name(country_code: str) -> str:
|
||||||
"""Return the localized country name for the given country code."""
|
"""Return the localized country name for the given country code."""
|
||||||
return Locale.parse(frappe.local.lang).territories.get(country_code, country_code)
|
from babel import Locale
|
||||||
|
|
||||||
|
return Locale.parse(frappe.local.lang, sep="-").territories.get(country_code, country_code)
|
||||||
|
@ -8,6 +8,8 @@ from datetime import date, timedelta
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
|
|
||||||
|
from erpnext.setup.doctype.holiday_list.holiday_list import local_country_name
|
||||||
|
|
||||||
|
|
||||||
class TestHolidayList(unittest.TestCase):
|
class TestHolidayList(unittest.TestCase):
|
||||||
def test_holiday_list(self):
|
def test_holiday_list(self):
|
||||||
@ -58,6 +60,16 @@ class TestHolidayList(unittest.TestCase):
|
|||||||
self.assertIn(date(2023, 4, 10), holidays)
|
self.assertIn(date(2023, 4, 10), holidays)
|
||||||
self.assertNotIn(date(2023, 5, 1), 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(
|
def make_holiday_list(
|
||||||
name, from_date=getdate() - timedelta(days=10), to_date=getdate(), holiday_dates=None
|
name, from_date=getdate() - timedelta(days=10), to_date=getdate(), holiday_dates=None
|
||||||
|
Loading…
Reference in New Issue
Block a user