Ticket #4734: make-message.2.patch
File make-message.2.patch, 1.7 KB (added by , 17 years ago) |
---|
-
/opt/django-0.97_pre7403/django/bin/make-messages.py
old new 85 85 src = pythonize_re.sub('\n#', src) 86 86 open(os.path.join(dirpath, '%s.py' % file), "wb").write(src) 87 87 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 print cmd 92 msgs = stdout.read() 92 93 errors = stderr.read() 93 94 if errors: 94 95 print "errors happened while running xgettext on %s" % file … … 97 98 old = '#: '+os.path.join(dirpath, thefile)[2:] 98 99 new = '#: '+os.path.join(dirpath, file)[2:] 99 100 msgs = msgs.replace(old, new) 101 if os.path.exists(potfile): 102 # Strip the header! 103 msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) 104 else: 105 msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') 100 106 if msgs: 101 107 open(potfile, 'ab').write(msgs) 102 108 os.unlink(os.path.join(dirpath, thefile))