Commit c319dc11 authored by Alexandre Boeglin's avatar Alexandre Boeglin

Base_translateString: do not try to encode if encoding is None or an empty...

Base_translateString: do not try to encode if encoding is None or an empty string (still defaults to 'utf8')

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20036 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c9b5e8aa
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<string>Products.PythonScripts.PythonScript</string> <tuple/>
<string>PythonScript</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
...@@ -78,6 +75,8 @@ from Products.CMFCore.utils import getToolByName\n ...@@ -78,6 +75,8 @@ from Products.CMFCore.utils import getToolByName\n
translation_service = getToolByName(context, \'Localizer\', None)\n translation_service = getToolByName(context, \'Localizer\', None)\n
if translation_service is not None :\n if translation_service is not None :\n
try:\n try:\n
if not encoding:\n
return translation_service.translate(catalog, msg, lang=lang, **kw)\n
return translation_service.translate(catalog, msg, lang=lang, **kw).encode(encoding)\n return translation_service.translate(catalog, msg, lang=lang, **kw).encode(encoding)\n
except AttributeError: # This happens in unit testing, because it is not able to find something with get_context()\n except AttributeError: # This happens in unit testing, because it is not able to find something with get_context()\n
pass\n pass\n
...@@ -140,8 +139,8 @@ return msg\n ...@@ -140,8 +139,8 @@ return msg\n
<string>context</string> <string>context</string>
<string>None</string> <string>None</string>
<string>translation_service</string> <string>translation_service</string>
<string>_getattr_</string>
<string>_apply_</string> <string>_apply_</string>
<string>_getattr_</string>
<string>AttributeError</string> <string>AttributeError</string>
</tuple> </tuple>
</value> </value>
......
754 755
\ No newline at end of file \ No newline at end of file
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