diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
a
|
b
|
|
10 | 10 | from django.core.management.base import CommandError, BaseCommand |
11 | 11 | |
12 | 12 | pythonize_re = re.compile(r'\n\s*//') |
| 13 | pot_timestamp_re = re.compile(r'^"POT-Creation-Date:[^\\]+', re.MULTILINE) |
13 | 14 | |
14 | 15 | def handle_extensions(extensions=('html',)): |
15 | 16 | """ |
… |
… |
|
36 | 37 | # trick xgettext to parse them as Python files) |
37 | 38 | return set([x for x in ext_list if x != '.py']) |
38 | 39 | |
| 40 | def get_pot_timestamp(pofname): |
| 41 | """ |
| 42 | Extracts the POT-Creation-Date header line from .po file pofname. |
| 43 | """ |
| 44 | if not os.path.exists(pofname): |
| 45 | return None |
| 46 | tstamp = None |
| 47 | pof = open(pofname, "rU") |
| 48 | try: |
| 49 | for c, line in enumerate(pof): |
| 50 | if not line or c == 30: |
| 51 | break |
| 52 | m = pot_timestamp_re.search(line) |
| 53 | if m: |
| 54 | tstamp = m.group(0) |
| 55 | break |
| 56 | finally: |
| 57 | pof.close() |
| 58 | return tstamp |
| 59 | |
39 | 60 | def make_messages(locale=None, domain='django', verbosity='1', all=False, extensions=None): |
40 | 61 | """ |
41 | 62 | Uses the locale directory from the Django SVN tree or an application/ |
… |
… |
|
93 | 114 | pofile = os.path.join(basedir, '%s.po' % domain) |
94 | 115 | potfile = os.path.join(basedir, '%s.pot' % domain) |
95 | 116 | |
| 117 | # If there is a .po file already, get its POT creation timestamp header |
| 118 | pot_timestamp = get_pot_timestamp(pofile) |
| 119 | |
96 | 120 | if os.path.exists(potfile): |
97 | 121 | os.unlink(potfile) |
98 | 122 | |
… |
… |
|
173 | 197 | errors = p.stderr.read() |
174 | 198 | if errors: |
175 | 199 | raise CommandError("errors happened while running msgmerge\n%s" % errors) |
| 200 | if pot_timestamp: |
| 201 | # Put back the POT creation timestamp we preserved |
| 202 | msgs = pot_timestamp_re.sub(pot_timestamp, msgs) |
176 | 203 | open(pofile, 'wb').write(msgs) |
177 | 204 | os.unlink(potfile) |
178 | 205 | |