Skip to content

Commit 248aee1

Browse files
committed
Modified makemessages so it creates .pot files once per invocation.
It creates a `locale/django.pot` file once instead of one `locale/<locale_code>/django.pot` file for every locale involved. Thanks Michal Čihař for the report and patch.
1 parent eee8652 commit 248aee1

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

django/core/management/commands/makemessages.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ def write_po_file(pofile, potfile, domain, locale, verbosity, stdout,
234234
"#. #-#-#-#-# %s.pot (PACKAGE VERSION) #-#-#-#-#\n" % domain, "")
235235
with open(pofile, 'w') as fp:
236236
fp.write(msgs)
237-
if not keep_pot:
238-
os.unlink(potfile)
239237
if no_obsolete:
240238
msgs, errors, status = _popen(
241239
'msgattrib %s %s -o "%s" --no-obsolete "%s"' %
@@ -314,6 +312,16 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False,
314312
wrap = '--no-wrap' if no_wrap else ''
315313
location = '--no-location' if no_location else ''
316314

315+
potfile = os.path.join(localedir, '%s.pot' % str(domain))
316+
317+
if os.path.exists(potfile):
318+
os.unlink(potfile)
319+
320+
for dirpath, file in find_files(".", ignore_patterns, verbosity,
321+
stdout, symlinks=symlinks):
322+
process_file(file, dirpath, potfile, domain, verbosity, extensions,
323+
wrap, location, keep_pot, stdout)
324+
317325
for locale in locales:
318326
if verbosity > 0:
319327
stdout.write("processing language %s\n" % locale)
@@ -322,20 +330,14 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False,
322330
os.makedirs(basedir)
323331

324332
pofile = os.path.join(basedir, '%s.po' % str(domain))
325-
potfile = os.path.join(basedir, '%s.pot' % str(domain))
326-
327-
if os.path.exists(potfile):
328-
os.unlink(potfile)
329-
330-
for dirpath, file in find_files(".", ignore_patterns, verbosity,
331-
stdout, symlinks=symlinks):
332-
process_file(file, dirpath, potfile, domain, verbosity, extensions,
333-
wrap, location, keep_pot, stdout)
334333

335334
if os.path.exists(potfile):
336335
write_po_file(pofile, potfile, domain, locale, verbosity, stdout,
337336
not invoked_for_django, wrap, location, no_obsolete, keep_pot)
338337

338+
if not keep_pot:
339+
os.unlink(potfile)
340+
339341

340342
class Command(NoArgsCommand):
341343
option_list = NoArgsCommand.option_list + (

tests/regressiontests/i18n/commands/extraction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,9 @@ def test_no_location_disabled(self):
297297

298298
class KeepPotFileExtractorTests(ExtractorTests):
299299

300+
POT_FILE='locale/django.pot'
301+
300302
def setUp(self):
301-
self.POT_FILE = self.PO_FILE + 't'
302303
super(KeepPotFileExtractorTests, self).setUp()
303304

304305
def tearDown(self):

0 commit comments

Comments
 (0)