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

:sparkles: make icuformat a method available to all models

parent 3d2a2e974645
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@
{
'name': 'ICU Format',
'summary': 'Format message using ICU',
'version': '11.0.0.1',
'version': '11.0.1.0',
'category': 'Technical',
'author': 'XCG Consulting',
'website': 'http://odoo.consulting/',
......
......@@ -18,6 +18,8 @@
##############################################################################
from typing import Dict, Union
from odoo.models import BaseModel
from icu import Formattable, Locale, MessageFormat
......@@ -31,3 +33,14 @@
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(
self.env.context.get('lang') or self.env.user.lang,
msg,
args,
)
setattr(BaseModel, 'icuformat', _icuformat)
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