Commit 088be37b authored by Ivan Tyagov's avatar Ivan Tyagov

Merge branch 'master' into ivan

parents 1574192a f49d7b7c
...@@ -31,7 +31,7 @@ from ZPublisher.BeforeTraverse import registerBeforeTraverse, \ ...@@ -31,7 +31,7 @@ from ZPublisher.BeforeTraverse import registerBeforeTraverse, \
# Import Localizer modules # Import Localizer modules
from interfaces import ILocalizer from interfaces import ILocalizer
from LocalFiles import LocalDTMLFile from LocalFiles import LocalDTMLFile
from MessageCatalog import MessageCatalog from MessageCatalog import MessageCatalog, to_unicode
from utils import lang_negotiator from utils import lang_negotiator
from LanguageManager import LanguageManager from LanguageManager import LanguageManager
...@@ -243,7 +243,7 @@ class Localizer(LanguageManager, Folder): ...@@ -243,7 +243,7 @@ class Localizer(LanguageManager, Folder):
assert not args assert not args
if lang is not None: if lang is not None:
kw['target_language'] = lang kw['target_language'] = lang
return translate(msgid, domain=domain, **kw) return translate(to_unicode(msgid), domain=domain, **kw)
InitializeClass(Localizer) InitializeClass(Localizer)
......
...@@ -76,7 +76,7 @@ def to_str(x): ...@@ -76,7 +76,7 @@ def to_str(x):
"""Make sure we have an (utf-8 encoded) string""" """Make sure we have an (utf-8 encoded) string"""
if isinstance(x, str): if isinstance(x, str):
return x return x
x.encode('utf-8') return x.encode('utf-8')
def message_encode(message): def message_encode(message):
"""Encodes a message to an ASCII string. """Encodes a message to an ASCII string.
...@@ -230,12 +230,17 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem): ...@@ -230,12 +230,17 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem):
security.declarePublic('message_exists') security.declarePublic('message_exists')
def message_exists(self, message): def message_exists(self, message):
""" """ """ """
return self._messages.has_key(message) # BBB call get_message_key to support both (old) str key and
# (new) unicode key.
return bool(self.get_message_key(message))
security.declareProtected('Manage messages', 'message_edit') security.declareProtected('Manage messages', 'message_edit')
def message_edit(self, message, language, translation, note): def message_edit(self, message, language, translation, note):
""" """ """ """
# BBB call get_message_key to support both (old) str key and
# (new) unicode key.
message = self.get_message_key(message) or message
self._messages[message][language] = translation self._messages[message][language] = translation
self._messages[message]['note'] = note self._messages[message]['note'] = note
...@@ -243,6 +248,9 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem): ...@@ -243,6 +248,9 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem):
security.declareProtected('Manage messages', 'message_del') security.declareProtected('Manage messages', 'message_del')
def message_del(self, message): def message_del(self, message):
""" """ """ """
# BBB call get_message_key to support both (old) str key and
# (new) unicode key.
message = self.get_message_key(message) or message
del self._messages[message] del self._messages[message]
...@@ -262,6 +270,10 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem): ...@@ -262,6 +270,10 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem):
if default is None: if default is None:
default = message default = message
# BBB call get_message_key to support both (old) str key and
# (new) unicode key.
message = self.get_message_key(message) or to_unicode(message)
# Add it if it's not in the dictionary # Add it if it's not in the dictionary
if add and not self._messages.has_key(message) and message: if add and not self._messages.has_key(message) and message:
self._messages[message] = PersistentMapping() self._messages[message] = PersistentMapping()
...@@ -606,7 +618,7 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem): ...@@ -606,7 +618,7 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem):
RESPONSE.setHeader('Content-Disposition', RESPONSE.setHeader('Content-Disposition',
'inline;filename=%s' % filename) 'inline;filename=%s' % filename)
return '\n'.join(r2) return '\n'.join(r)
security.declareProtected('Manage messages', 'po_import') security.declareProtected('Manage messages', 'po_import')
......
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