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

Localizer: py3

parent 4a4eda58
......@@ -106,15 +106,11 @@ def message_decode(message):
To be used in the user interface, to avoid problems with the
encodings, HTML entities, etc..
"""
message = decodebytes(message)
message = decodebytes(message.encode())
encoding = HTTPRequest.default_encoding
return six.text_type(message, encoding)
def filter_sort(x, y):
return cmp(to_unicode(x), to_unicode(y))
def get_url(url, batch_start, batch_size, regex, lang, empty, **kw):
params = []
for key, value in six.iteritems(kw):
......@@ -396,7 +392,7 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem):
for m, t in six.iteritems(self._messages):
if query.search(m) and (not empty or not t.get(lang, '').strip()):
messages.append(m)
messages.sort(filter_sort)
messages.sort(key=lambda m: to_unicode(m))
# How many messages
n = len(messages)
namespace['n_messages'] = n
......@@ -664,6 +660,10 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem):
messages = self._messages
# Load the data
if isinstance(data, bytes): # six.PY2
pass
elif isinstance(data, bytes): # six.PY3
data = data.decode()
po = polib.pofile(data)
encoding = to_str(po.encoding)
for entry in po:
......
......@@ -23,9 +23,7 @@ from App.ImageFile import ImageFile
from DocumentTemplate.DT_String import String
# Import from Localizer
import six
if six.PY2:
from . import patches as _
from . import patches as _
from . import Localizer, MessageCatalog
from .LocalFiles import LocalDTMLFile
......
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