Ticket #8536: t8536-r8534.diff
File t8536-r8534.diff, 4.1 KB (added by , 16 years ago) |
---|
-
django/core/management/commands/makemessages.py
106 106 msgs = stdout.read() 107 107 errors = stderr.read() 108 108 if errors: 109 os.unlink(os.path.join(dirpath, thefile)) 110 if os.path.exists(potfile): 111 os.unlink(potfile) 109 112 raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors)) 110 old = '#: '+os.path.join(dirpath, thefile)[2:]111 new = '#: '+os.path.join(dirpath, file)[2:]112 msgs = msgs.replace(old, new)113 if os.path.exists(potfile):114 # Strip the header115 msgs = '\n'.join(dropwhile(len, msgs.split('\n')))116 else:117 msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8')118 113 if msgs: 114 old = '#: '+os.path.join(dirpath, thefile)[2:] 115 new = '#: '+os.path.join(dirpath, file)[2:] 116 msgs = msgs.replace(old, new) 117 if os.path.exists(potfile): 118 # Strip the header 119 msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) 120 else: 121 msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') 119 122 open(potfile, 'ab').write(msgs) 120 123 os.unlink(os.path.join(dirpath, thefile)) 121 124 elif domain == 'django' and (file_ext == '.py' or file_ext in extensions): … … 132 135 msgs = stdout.read() 133 136 errors = stderr.read() 134 137 if errors: 138 if thefile != file: 139 os.unlink(os.path.join(dirpath, thefile)) 140 if os.path.exists(potfile): 141 os.unlink(potfile) 135 142 raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors)) 136 if thefile != file:137 old = '#: '+os.path.join(dirpath, thefile)[2:]138 new = '#: '+os.path.join(dirpath, file)[2:]139 msgs = msgs.replace(old, new)140 if os.path.exists(potfile):141 # Strip the header142 msgs = '\n'.join(dropwhile(len, msgs.split('\n')))143 else:144 msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8')145 143 if msgs: 144 if thefile != file: 145 old = '#: '+os.path.join(dirpath, thefile)[2:] 146 new = '#: '+os.path.join(dirpath, file)[2:] 147 msgs = msgs.replace(old, new) 148 if os.path.exists(potfile): 149 # Strip the header 150 msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) 151 else: 152 msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') 146 153 open(potfile, 'ab').write(msgs) 147 154 if thefile != file: 148 155 os.unlink(os.path.join(dirpath, thefile)) … … 152 159 msgs = stdout.read() 153 160 errors = stderr.read() 154 161 if errors: 162 os.unlink(potfile) 155 163 raise CommandError("errors happened while running msguniq\n%s" % errors) 156 open(potfile, 'w').write(msgs)157 164 if os.path.exists(pofile): 165 open(potfile, 'w').write(msgs) 158 166 (stdin, stdout, stderr) = os.popen3('msgmerge -q "%s" "%s"' % (pofile, potfile), 'b') 159 167 msgs = stdout.read() 160 168 errors = stderr.read() 161 169 if errors: 170 os.unlink(potfile) 162 171 raise CommandError("errors happened while running msgmerge\n%s" % errors) 163 172 open(pofile, 'wb').write(msgs) 164 173 os.unlink(potfile)