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.
This commit is contained in:
Ramiro Morales 2013-01-16 16:21:47 -03:00
parent eee865257a
commit 248aee1606
2 changed files with 15 additions and 12 deletions

View File

@ -234,8 +234,6 @@ def write_po_file(pofile, potfile, domain, locale, verbosity, stdout,
"#. #-#-#-#-# %s.pot (PACKAGE VERSION) #-#-#-#-#\n" % domain, "") "#. #-#-#-#-# %s.pot (PACKAGE VERSION) #-#-#-#-#\n" % domain, "")
with open(pofile, 'w') as fp: with open(pofile, 'w') as fp:
fp.write(msgs) fp.write(msgs)
if not keep_pot:
os.unlink(potfile)
if no_obsolete: if no_obsolete:
msgs, errors, status = _popen( msgs, errors, status = _popen(
'msgattrib %s %s -o "%s" --no-obsolete "%s"' % 'msgattrib %s %s -o "%s" --no-obsolete "%s"' %
@ -314,6 +312,16 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False,
wrap = '--no-wrap' if no_wrap else '' wrap = '--no-wrap' if no_wrap else ''
location = '--no-location' if no_location else '' location = '--no-location' if no_location else ''
potfile = os.path.join(localedir, '%s.pot' % str(domain))
if os.path.exists(potfile):
os.unlink(potfile)
for dirpath, file in find_files(".", ignore_patterns, verbosity,
stdout, symlinks=symlinks):
process_file(file, dirpath, potfile, domain, verbosity, extensions,
wrap, location, keep_pot, stdout)
for locale in locales: for locale in locales:
if verbosity > 0: if verbosity > 0:
stdout.write("processing language %s\n" % locale) stdout.write("processing language %s\n" % locale)
@ -322,20 +330,14 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False,
os.makedirs(basedir) os.makedirs(basedir)
pofile = os.path.join(basedir, '%s.po' % str(domain)) pofile = os.path.join(basedir, '%s.po' % str(domain))
potfile = os.path.join(basedir, '%s.pot' % str(domain))
if os.path.exists(potfile):
os.unlink(potfile)
for dirpath, file in find_files(".", ignore_patterns, verbosity,
stdout, symlinks=symlinks):
process_file(file, dirpath, potfile, domain, verbosity, extensions,
wrap, location, keep_pot, stdout)
if os.path.exists(potfile): if os.path.exists(potfile):
write_po_file(pofile, potfile, domain, locale, verbosity, stdout, write_po_file(pofile, potfile, domain, locale, verbosity, stdout,
not invoked_for_django, wrap, location, no_obsolete, keep_pot) not invoked_for_django, wrap, location, no_obsolete, keep_pot)
if not keep_pot:
os.unlink(potfile)
class Command(NoArgsCommand): class Command(NoArgsCommand):
option_list = NoArgsCommand.option_list + ( option_list = NoArgsCommand.option_list + (

View File

@ -297,8 +297,9 @@ class NoLocationExtractorTests(ExtractorTests):
class KeepPotFileExtractorTests(ExtractorTests): class KeepPotFileExtractorTests(ExtractorTests):
POT_FILE='locale/django.pot'
def setUp(self): def setUp(self):
self.POT_FILE = self.PO_FILE + 't'
super(KeepPotFileExtractorTests, self).setUp() super(KeepPotFileExtractorTests, self).setUp()
def tearDown(self): def tearDown(self):