Commit a36c868e authored by Vincent Pelletier's avatar Vincent Pelletier

Translation service raises if it receives a non-ascii string.

As ERP5 decided to only contain UTF-8 strings, it is responsible for decoding
them before handing them out to translation service.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45333 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cbd12b5f
......@@ -146,10 +146,18 @@ class Message(Persistent):
from Products.ERP5.ERP5Site import getSite
request = Globals.get_request()
translation_service = getGlobalTranslationService()
if self.mapping:
unicode_mapping = {}
for k, v in self.mapping.iteritems():
if isinstance(v, str):
v = v.decode('utf-8')
unicode_mapping[k] = v
else:
unicode_mapping = self.mapping
translated_message = translation_service.translate(
self.domain,
message,
mapping=self.mapping,
mapping=unicode_mapping,
context=getSite(request),
default=self.default)
if translated_message is not None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment