diff --git a/report_py3o/README.rst b/report_py3o/README.rst index 11d1a5f4..0803f7ce 100644 --- a/report_py3o/README.rst +++ b/report_py3o/README.rst @@ -167,7 +167,7 @@ display_address(partner) formatLang(value, digits=None, date=False, date_time=False, grouping=True, monetary=False, dp=False, currency_obj=False) Return a formatted numeric, monetary, date or time value according to the context language and timezone (old implementation kept for compatibility and ease migration) -o_format_lang(value, digits=None, grouping=True, monetary=False, dp=False, currency_obj=False, no_break_space=True) +o_format_lang(value, lang_code=False, digits=None, grouping=True, monetary=False, dp=False, currency_obj=False, no_break_space=True) Return a formatted numeric or monetary value according to the context language and timezone o_format_date(value, lang_code=False, date_format=False) Return a formatted date or time value according to the context language and timezone diff --git a/report_py3o/models/_py3o_parser_context.py b/report_py3o/models/_py3o_parser_context.py index 2d60b6d7..c5b55951 100644 --- a/report_py3o/models/_py3o_parser_context.py +++ b/report_py3o/models/_py3o_parser_context.py @@ -49,11 +49,15 @@ class Py3oParserContext(object): 'b64decode': b64decode, } - def _format_lang(self, value, digits=None, grouping=True, + def _format_lang(self, value, lang_code=False, digits=None, grouping=True, monetary=False, dp=False, currency_obj=False, no_break_space=True): + env = self._env + if lang_code: + context = dict(env.context, lang=lang_code) + env = env(context=context) formatted_value = misc.formatLang( - self._env, value, digits=digits, grouping=grouping, + env, value, digits=digits, grouping=grouping, monetary=monetary, dp=dp, currency_obj=currency_obj) if currency_obj and currency_obj.symbol and no_break_space: parts = []