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, "")
with open(pofile, 'w') as fp:
fp.write(msgs)
if not keep_pot:
os.unlink(potfile)
if no_obsolete:
msgs, errors, status = _popen(
'msgattrib %s %s -o "%s" --no-obsolete "%s"' %
@ -314,15 +312,7 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False,
wrap = '--no-wrap' if no_wrap else ''
location = '--no-location' if no_location else ''
for locale in locales:
if verbosity > 0:
stdout.write("processing language %s\n" % locale)
basedir = os.path.join(localedir, locale, 'LC_MESSAGES')
if not os.path.isdir(basedir):
os.makedirs(basedir)
pofile = os.path.join(basedir, '%s.po' % str(domain))
potfile = os.path.join(basedir, '%s.pot' % str(domain))
potfile = os.path.join(localedir, '%s.pot' % str(domain))
if os.path.exists(potfile):
os.unlink(potfile)
@ -332,10 +322,22 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False,
process_file(file, dirpath, potfile, domain, verbosity, extensions,
wrap, location, keep_pot, stdout)
for locale in locales:
if verbosity > 0:
stdout.write("processing language %s\n" % locale)
basedir = os.path.join(localedir, locale, 'LC_MESSAGES')
if not os.path.isdir(basedir):
os.makedirs(basedir)
pofile = os.path.join(basedir, '%s.po' % str(domain))
if os.path.exists(potfile):
write_po_file(pofile, potfile, domain, locale, verbosity, stdout,
not invoked_for_django, wrap, location, no_obsolete, keep_pot)
if not keep_pot:
os.unlink(potfile)
class Command(NoArgsCommand):
option_list = NoArgsCommand.option_list + (

View File

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