Ticket #7030: make-message.patch

File make-message.patch, 1.7 KB (added by anonymous, 16 years ago)

make-messages.py patch to deal with JS files as .html files (no use of omit-header) and stripping header if .pot file exists

  • /opt/django-0.97_pre7403/django/bin/make-messages.py

    old new  
    8585                src = pythonize_re.sub('\n#', src)
    8686                open(os.path.join(dirpath, '%s.py' % file), "wb").write(src)
    8787                thefile = '%s.py' % file
    88                 cmd = 'xgettext %s -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
    89                     os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
    90                 (stdin, stdout, stderr) = os.popen3(cmd, 't')
    91                 msgs = stdout.read()
     88                cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
     89                    domain, os.path.join(dirpath, thefile))
     90                (stdin, stdout, stderr) = os.popen3(cmd, 't')
     91                msgs = stdout.read()
    9292                errors = stderr.read()
    9393                if errors:
    9494                    print "errors happened while running xgettext on %s" % file
     
    9797                old = '#: '+os.path.join(dirpath, thefile)[2:]
    9898                new = '#: '+os.path.join(dirpath, file)[2:]
    9999                msgs = msgs.replace(old, new)
     100                if os.path.exists(potfile):
     101                    # Strip the header!
     102                    msgs = '\n'.join(dropwhile(len, msgs.split('\n')))
     103                else:
     104                    msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8')
    100105                if msgs:
    101106                    open(potfile, 'ab').write(msgs)
    102107                os.unlink(os.path.join(dirpath, thefile))
Back to Top