Ticket #3344: temporary-fix-until-full-unicode.patch

File temporary-fix-until-full-unicode.patch, 1.1 KB (added by Øyvind Saltvik <oyvind@…>, 17 years ago)

temporary solution for utf-8 gettext translations with newforms, encodes as xmlcharrefs

  • django/newforms/util.py

     
    1212        s = unicode(s, settings.DEFAULT_CHARSET)
    1313    return s
    1414
     15def charrefs(s):
     16    s = s.decode('utf-8').encode('ascii', 'xmlcharrefreplace')
     17    return s
     18
    1519class StrAndUnicode(object):
    1620    """
    1721    A class whose __str__ returns its __unicode__ as a bytestring
     
    5761    def __init__(self, message):
    5862        "ValidationError can be passed a string or a list."
    5963        if isinstance(message, list):
    60             self.messages = ErrorList([smart_unicode(msg) for msg in message])
     64            self.messages = ErrorList([smart_unicode(charrefs(msg)) for msg in message])
    6165        else:
    6266            assert isinstance(message, basestring), ("%s should be a basestring" % repr(message))
    63             message = smart_unicode(message)
     67            message = smart_unicode(charrefs(message))
    6468            self.messages = ErrorList([message])
    6569
    6670    def __str__(self):
Back to Top