Commit f2d34097 authored by Jérome Perrin's avatar Jérome Perrin

Substitute the mapping using unicode objects from both the template

string andall mapping values.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5970 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d6fb5b75
......@@ -65,11 +65,15 @@ def Localizer_translate(self, domain, msgid, mapping=None, *args, **kw):
# Map the translated string with given parameters
if type(mapping) is type({}):
if isinstance(translated_str, unicode) :
translated_str = translated_str.encode('utf8')
translated_str = Template(translated_str).substitute(mapping)
unicode_mapping = {}
if not isinstance(translated_str, unicode):
translated_str = translated_str.decode('utf8')
# make sure all values in the mapping are unicode
for k, v in mapping.items():
if isinstance(v, str) :
v = v.decode('utf8')
unicode_mapping[k] = v
translated_str = Template(translated_str).substitute(unicode_mapping)
return translated_str
def GlobalTranslationService_translate(self, domain, msgid, *args, **kw):
......
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