Ticket #4734: make-messages.py.2.patch
File make-messages.py.2.patch, 2.1 KB (added by , 17 years ago) |
---|
-
make-messages.py
old new 103 103 open(os.path.join(dirpath, '%s.py' % file), "wb").write(templatize(src)) 104 104 thefile = '%s.py' % file 105 105 if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 106 cmd = 'xgettext %s-d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy --from-code UTF-8 -o - "%s"' % (107 os.path.exists(potfile) and '--omit-header' or '',domain, os.path.join(dirpath, thefile))106 cmd = 'xgettext -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy --from-code UTF-8 -o - "%s"' % ( 107 domain, os.path.join(dirpath, thefile)) 108 108 (stdin, stdout, stderr) = os.popen3(cmd, 'b') 109 109 msgs = stdout.read() 110 110 errors = stderr.read() … … 116 116 old = '#: '+os.path.join(dirpath, thefile)[2:] 117 117 new = '#: '+os.path.join(dirpath, file)[2:] 118 118 msgs = msgs.replace(old, new) 119 if os.path.exists(potfile): 120 # Strip the header! 121 tmpmsg = msgs.split('\n')[17:] 122 msgs = '\n'.join(tmpmsg) 123 else: 124 msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') 119 125 if msgs: 120 126 open(potfile, 'ab').write(msgs) 121 127 if thefile != file: 122 128 os.unlink(os.path.join(dirpath, thefile)) 123 129 124 130 if os.path.exists(potfile): 125 (stdin, stdout, stderr) = os.popen3('msguniq "%s"' % potfile, 'b')131 (stdin, stdout, stderr) = os.popen3('msguniq --to-code=utf-8 "%s"' % potfile, 'b') 126 132 msgs = stdout.read() 127 133 errors = stderr.read() 128 134 if errors: