Commit 75215bfe authored by Jérome Perrin's avatar Jérome Perrin

Monkey patch MessageCatalog.manage_export so that it doesn't fail in exporting

message catalog with unicode strings as keys.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14093 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5654a848
...@@ -100,3 +100,22 @@ try: ...@@ -100,3 +100,22 @@ try:
GlobalTranslationService.translate = GlobalTranslationService_translate GlobalTranslationService.translate = GlobalTranslationService_translate
except ImportError: except ImportError:
pass pass
# Fix MessageCatalog's manage_export that fails with unicode strings
from Products.Localizer.MessageCatalog import MessageCatalog
original_manage_export = MessageCatalog.manage_export
def cleanup_and_export(self, x, REQUEST=None, RESPONSE=None):
"""Path manage_export to cleanup messages whose keys are unicode objects
before exporting.
"""
message_keys = self._messages.keys()
for k in message_keys:
if isinstance(k, unicode):
message = self._messages.get(k.encode('utf8'),
self._messages.get(k))
del self._messages[k]
self._messages[k.encode('utf8')] = message
return original_manage_export(self, x, REQUEST=REQUEST, RESPONSE=RESPONSE)
MessageCatalog.manage_export = cleanup_and_export
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