Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit 248aee16066b2a336f16c844580cf043d853874b 1 parent eee8652
Ramiro Morales authored January 16, 2013
24  django/core/management/commands/makemessages.py
@@ -234,8 +234,6 @@ def write_po_file(pofile, potfile, domain, locale, verbosity, stdout,
234 234
         "#. #-#-#-#-#  %s.pot (PACKAGE VERSION)  #-#-#-#-#\n" % domain, "")
235 235
     with open(pofile, 'w') as fp:
236 236
         fp.write(msgs)
237  
-    if not keep_pot:
238  
-        os.unlink(potfile)
239 237
     if no_obsolete:
240 238
         msgs, errors, status = _popen(
241 239
             'msgattrib %s %s -o "%s" --no-obsolete "%s"' %
@@ -314,6 +312,16 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False,
314 312
     wrap = '--no-wrap' if no_wrap else ''
315 313
     location = '--no-location' if no_location else ''
316 314
 
  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
+
317 325
     for locale in locales:
318 326
         if verbosity > 0:
319 327
             stdout.write("processing language %s\n" % locale)
@@ -322,20 +330,14 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False,
322 330
             os.makedirs(basedir)
323 331
 
324 332
         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)
334 333
 
335 334
         if os.path.exists(potfile):
336 335
             write_po_file(pofile, potfile, domain, locale, verbosity, stdout,
337 336
                     not invoked_for_django, wrap, location, no_obsolete, keep_pot)
338 337
 
  338
+    if not keep_pot:
  339
+        os.unlink(potfile)
  340
+
339 341
 
340 342
 class Command(NoArgsCommand):
341 343
     option_list = NoArgsCommand.option_list + (
3  tests/regressiontests/i18n/commands/extraction.py
@@ -297,8 +297,9 @@ def test_no_location_disabled(self):
297 297
 
298 298
 class KeepPotFileExtractorTests(ExtractorTests):
299 299
 
  300
+    POT_FILE='locale/django.pot'
  301
+
300 302
     def setUp(self):
301  
-        self.POT_FILE = self.PO_FILE + 't'
302 303
         super(KeepPotFileExtractorTests, self).setUp()
303 304
 
304 305
     def tearDown(self):

0 notes on commit 248aee1

Please sign in to comment.
Something went wrong with that request. Please try again.