diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
a
|
b
|
|
90 | 90 | xversion = (int(match.group('major')), int(match.group('minor'))) |
91 | 91 | if xversion < (0, 15): |
92 | 92 | xgettext_reencodes_utf8 = True |
93 | | |
| 93 | |
94 | 94 | languages = [] |
95 | 95 | if locale is not None: |
96 | 96 | languages.append(locale) |
… |
… |
|
128 | 128 | msgs = stdout.read() |
129 | 129 | errors = stderr.read() |
130 | 130 | if errors: |
| 131 | os.unlink(os.path.join(dirpath, thefile)) |
| 132 | if os.path.exists(potfile): |
| 133 | os.unlink(potfile) |
131 | 134 | raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors)) |
132 | | old = '#: '+os.path.join(dirpath, thefile)[2:] |
133 | | new = '#: '+os.path.join(dirpath, file)[2:] |
134 | | msgs = msgs.replace(old, new) |
135 | | if os.path.exists(potfile): |
136 | | # Strip the header |
137 | | msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) |
138 | | else: |
139 | | msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') |
140 | 135 | if msgs: |
| 136 | old = '#: '+os.path.join(dirpath, thefile)[2:] |
| 137 | new = '#: '+os.path.join(dirpath, file)[2:] |
| 138 | msgs = msgs.replace(old, new) |
| 139 | if os.path.exists(potfile): |
| 140 | # Strip the header |
| 141 | msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) |
| 142 | else: |
| 143 | msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') |
141 | 144 | open(potfile, 'ab').write(msgs) |
142 | 145 | os.unlink(os.path.join(dirpath, thefile)) |
143 | 146 | elif domain == 'django' and (file_ext == '.py' or file_ext in extensions): |
… |
… |
|
154 | 157 | msgs = stdout.read() |
155 | 158 | errors = stderr.read() |
156 | 159 | if errors: |
| 160 | if thefile != file: |
| 161 | os.unlink(os.path.join(dirpath, thefile)) |
| 162 | if os.path.exists(potfile): |
| 163 | os.unlink(potfile) |
157 | 164 | raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors)) |
158 | 165 | |
159 | | if xgettext_reencodes_utf8: |
160 | | msgs = msgs.decode('utf-8').encode('iso-8859-1') |
161 | | |
162 | | if thefile != file: |
163 | | old = '#: '+os.path.join(dirpath, thefile)[2:] |
164 | | new = '#: '+os.path.join(dirpath, file)[2:] |
165 | | msgs = msgs.replace(old, new) |
166 | | if os.path.exists(potfile): |
167 | | # Strip the header |
168 | | msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) |
169 | | else: |
170 | | msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') |
171 | 166 | if msgs: |
| 167 | if xgettext_reencodes_utf8: |
| 168 | msgs = msgs.decode('utf-8').encode('iso-8859-1') |
| 169 | if thefile != file: |
| 170 | old = '#: '+os.path.join(dirpath, thefile)[2:] |
| 171 | new = '#: '+os.path.join(dirpath, file)[2:] |
| 172 | msgs = msgs.replace(old, new) |
| 173 | if os.path.exists(potfile): |
| 174 | # Strip the header |
| 175 | msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) |
| 176 | else: |
| 177 | msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') |
172 | 178 | open(potfile, 'ab').write(msgs) |
173 | 179 | if thefile != file: |
174 | 180 | os.unlink(os.path.join(dirpath, thefile)) |
… |
… |
|
178 | 184 | msgs = stdout.read() |
179 | 185 | errors = stderr.read() |
180 | 186 | if errors: |
| 187 | os.unlink(potfile) |
181 | 188 | raise CommandError("errors happened while running msguniq\n%s" % errors) |
182 | | open(potfile, 'w').write(msgs) |
183 | 189 | if os.path.exists(pofile): |
| 190 | open(potfile, 'w').write(msgs) |
184 | 191 | (stdin, stdout, stderr) = os.popen3('msgmerge -q "%s" "%s"' % (pofile, potfile), 't') |
185 | 192 | msgs = stdout.read() |
186 | 193 | errors = stderr.read() |
187 | 194 | if errors: |
| 195 | os.unlink(potfile) |
188 | 196 | raise CommandError("errors happened while running msgmerge\n%s" % errors) |
189 | 197 | open(pofile, 'wb').write(msgs) |
190 | 198 | os.unlink(potfile) |