Anonymous committed ebf6d4f

[soc2009/i18n] Refs #10891, fixed bug on blocktrans, that skipped translations of texts containing mac or dos end of lines.

Comments (0)

Files changed (2)


     translation object to use. If no current translation is activated, the
     message will be run through the default translation object.
+    eol_message = message.replace('\r\n', '\n').replace('\r', '\n')
     global _default, _active
     t = _active.get(currentThread(), None)
     if t is not None:
-        result = getattr(t, translation_function)(message)
+        result = getattr(t, translation_function)(eol_message)
         if _default is None:
             from django.conf import settings
             _default = translation(settings.LANGUAGE_CODE)
-        result = getattr(_default, translation_function)(message)
+        result = getattr(_default, translation_function)(eol_message)
     if isinstance(message, SafeData):
         return mark_safe(result)
     return result


 >>> print s
+Translations on files with mac or dos end of lines will be converted
+to unix eof in .po catalogs, and they have to match when retrieved
+>>> from django.utils.translation.trans_real import translation
+>>> ca_translation = translation('ca')
+>>> ca_translation._catalog[u'Mac\nEOF\n'] = u'Catalan Mac\nEOF\n'
+>>> ca_translation._catalog[u'Win\nEOF\n'] = u'Catalan Win\nEOF\n'
+>>> activate('ca')
+>>> ugettext(u'Mac\rEOF\r')
+u'Catalan Mac\nEOF\n'
+>>> ugettext(u'Win\r\nEOF\r\n')
+u'Catalan Win\nEOF\n'
+>>> deactivate()
 Localization of dates and numbers
 >>> import datetime