Skip to content
Snippets Groups Projects
Commit 2651c5a8904d authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

:shirt: black

parent 4c6bf2470d3e
No related branches found
No related tags found
No related merge requests found
......@@ -18,20 +18,14 @@
##############################################################################
{
'name': 'ICU Format',
'summary': 'Format message using ICU',
'version': '11.0.1.0',
'category': 'Technical',
'author': 'XCG Consulting',
'website': 'http://odoo.consulting/',
'license': 'AGPL-3',
'depends': [
'base',
],
'external_dependencies': {
'python': [
'PyICU',
],
},
'installable': True,
"name": "ICU Format",
"summary": "Format message using ICU",
"version": "11.0.1.0",
"category": "Technical",
"author": "XCG Consulting",
"website": "http://odoo.consulting/",
"license": "AGPL-3",
"depends": ["base"],
"external_dependencies": {"python": ["PyICU"]},
"installable": True,
}
......@@ -30,10 +30,10 @@
key_list.append(key)
value_list.append(Formattable(value))
if not lang:
lang = 'en'
lang = "en"
locale = Locale(lang)
return MessageFormat(msg, locale).format(key_list, value_list)
def _icuformat(self, msg: str, args: Dict[str, Union[int, str]]) -> str:
return icuformat(
......@@ -34,12 +34,10 @@
locale = Locale(lang)
return MessageFormat(msg, locale).format(key_list, value_list)
def _icuformat(self, msg: str, args: Dict[str, Union[int, str]]) -> str:
return icuformat(
self.env.context.get('lang') or self.env.user.lang,
msg,
args,
self.env.context.get("lang") or self.env.user.lang, msg, args
)
......@@ -43,4 +41,4 @@
)
setattr(BaseModel, 'icuformat', _icuformat)
setattr(BaseModel, "icuformat", _icuformat)
......@@ -24,9 +24,9 @@
class Test(tests.TransactionCase):
def test_simple(self):
msg = '{test}'
d = {'test': 'foobar'}
expected = 'foobar'
self.assertEqual(expected, icuformat('en', msg, d))
msg = "{test}"
d = {"test": "foobar"}
expected = "foobar"
self.assertEqual(expected, icuformat("en", msg, d))
def test_nothing_to_format(self):
......@@ -31,4 +31,4 @@
def test_nothing_to_format(self):
msg = 'test'
msg = "test"
d = dict()
......@@ -34,5 +34,5 @@
d = dict()
self.assertEqual(msg, icuformat('en', msg, d))
self.assertEqual(msg, icuformat("en", msg, d))
def test_nested_plural_select(self):
msg = (
......@@ -58,5 +58,5 @@
"}}}"
)
d = dict(
gender_of_host='female',
gender_of_host="female",
num_guests=1005,
......@@ -62,4 +62,5 @@
num_guests=1005,
host='Ms. Marple',
guest='Robert')
host="Ms. Marple",
guest="Robert",
)
expected = (
......@@ -65,3 +66,3 @@
expected = (
'Ms. Marple invites Robert and 1,004 other people to her party.'
"Ms. Marple invites Robert and 1,004 other people to her party."
)
......@@ -67,2 +68,2 @@
)
self.assertEqual(expected, icuformat('en', msg, d))
self.assertEqual(expected, icuformat("en", msg, d))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment