1. Simon Meers
  2. django-dbgettext


Simon Meers  committed 39ce11b

Remove all xgettext-unfriendly escape sequences.

  • Participants
  • Parent commits ea153a9
  • Branches default

Comments (0)

Files changed (1)

File dbgettext/management/commands/dbgettext_export.py

View file
 from django.conf import settings
 from django.core.management.base import NoArgsCommand, CommandError
+import os
+import re
 from shutil import rmtree
-import os
 from dbgettext.registry import registry
 from dbgettext.parser import parsed_gettext
+INVALID_ESCAPE_SEQUENCES = re.compile(r'[\a\b\f\r\v]')
+# (see xgettext's write-po.c)
 def recursive_getattr(obj, attr, default=None, separator='__'):
     """ Allows getattr(obj, 'related_class__property__subproperty__etc') """
 def sanitise_message(message):
     """ Prepare message for storage in .po file. """
-    # carriage returns are forbidden in po files, but seem to be ignored
-    # during lookups, so it should be safe to remove them
-    return message.replace('\r', '')
+    return INVALID_ESCAPE_SEQUENCES.sub('', message)
 class Command(NoArgsCommand):
     """ dbgettext_export management command """