--- makemessages.py.orig	2010-02-10 14:50:09.000000000 +0100
+++ makemessages.py	2010-02-10 15:04:56.000000000 +0100
@@ -42,7 +42,7 @@
     p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt', universal_newlines=True)
     return p.communicate()
 
-def make_messages(locale=None, domain='django', verbosity='1', all=False, extensions=None):
+def make_messages(locale=None, domain='django', verbosity='1', all=False, extensions=None, addcomments=False):
     """
     Uses the locale directory from the Django SVN tree or an application/
     project to process all
@@ -106,6 +106,11 @@
         for (dirpath, dirnames, filenames) in os.walk("."):
             all_files.extend([(dirpath, f) for f in filenames])
         all_files.sort()
+        addcomments_switch = ''
+        if addcomments == '':
+            addcomments_switch = '--add-comments'
+        elif addcomments and len(addcomments) > 0:
+            addcomments_switch = '--addcomments=%s' % addcomments
         for dirpath, file in all_files:
             file_base, file_ext = os.path.splitext(file)
             if domain == 'djangojs' and file_ext == '.js':
@@ -115,7 +120,7 @@
                 src = pythonize_re.sub('\n#', src)
                 thefile = '%s.py' % file
                 open(os.path.join(dirpath, thefile), "w").write(src)
-                cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (domain, os.path.join(dirpath, thefile))
+                cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 %s -o - "%s"' % (domain, addcomments_switch, os.path.join(dirpath, thefile))
                 msgs, errors = _popen(cmd)
                 if errors:
                     raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors))
@@ -142,8 +147,8 @@
                         raise SyntaxError(msg)
                 if verbosity > 1:
                     sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
-                cmd = 'xgettext -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
-                    domain, os.path.join(dirpath, thefile))
+                cmd = 'xgettext -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --from-code UTF-8 %s -o - "%s"' % (
+                    domain, addcomments_switch, os.path.join(dirpath, thefile))
                 msgs, errors = _popen(cmd)
                 if errors:
                     raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors))
@@ -186,6 +191,9 @@
         make_option('--extension', '-e', dest='extensions',
             help='The file extension(s) to examine (default: ".html", separate multiple extensions with commas, or use -e multiple times)',
             action='append'),
+        make_option('--add-comments', '-c', dest='addcomments',
+            help='place comment block with TAG (or those preceding keyword lines) in output file',
+            default=False),
     )
     help = "Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the django tree) or locale (for project and application) directory."
 
@@ -201,6 +209,7 @@
         verbosity = int(options.get('verbosity'))
         process_all = options.get('all')
         extensions = options.get('extensions') or ['html']
+        addcomments = options.get('addcomments')
 
         if domain == 'djangojs':
             extensions = []
@@ -210,4 +219,4 @@
         if '.js' in extensions:
             raise CommandError("JavaScript files should be examined by using the special 'djangojs' domain only.")
 
-        make_messages(locale, domain, verbosity, process_all, extensions)
+        make_messages(locale, domain, verbosity, process_all, extensions, addcomments)
