]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
* The creation-date header in generated PO files now includes the timezone offset.
authorChristopher Lenz <cmlenz@gmail.com>
Wed, 30 May 2007 10:16:37 +0000 (10:16 +0000)
committerChristopher Lenz <cmlenz@gmail.com>
Wed, 30 May 2007 10:16:37 +0000 (10:16 +0000)
 * The distutils frontend pulls the project name and version from the distribution object.

babel/catalog/frontend.py
babel/catalog/pofile.py

index 31074d2e4720d85f0c3ced150a2605ea82c9692a..360b3f4f5d60c6c62604fe66cb4256fac08fc8c8 100644 (file)
@@ -56,7 +56,7 @@ class extract_messages(Command):
          'do not include location comments with filename and line number'),
         ('omit-header', None,
          'do not include msgid "" entry in header'),
-        ('output-file=', None,
+        ('output-file=', 'o',
          'name of the output file'),
     ]
     boolean_options = ['no-location', 'omit-header']
@@ -88,8 +88,10 @@ class extract_messages(Command):
                 for filename, lineno, funcname, message in extracted:
                     messages.append((os.path.join(dirname, filename), lineno,
                                      funcname, message))
-            write_po(outfile, messages, charset=self.charset,
-                     no_location=self.no_location, omit_header=self.omit_header)
+            write_po(outfile, messages, project=self.distribution.get_name(),
+                     version=self.distribution.get_version(),
+                     charset=self.charset, no_location=self.no_location,
+                     omit_header=self.omit_header)
             log.info('writing PO file to %s' % self.output_file)
         finally:
             outfile.close()
index 595641e68b98ad5da1fb8d56138e02fb255223fb..3eb82bb375400c7c71becda200100a955ae35aa7 100644 (file)
@@ -20,8 +20,9 @@ format.
 
 # TODO: line wrapping
 
-from datetime import datetime
+from datetime import date, datetime
 import re
+import time
 
 from babel import __version__ as VERSION
 
@@ -35,7 +36,7 @@ POT_HEADER = """\
 msgid ""
 msgstr ""
 "Project-Id-Version: %%(project)s %%(version)s\\n"
-"POT-Creation-Date: %%(time)s\\n"
+"POT-Creation-Date: %%(creation_date)s\\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
 "Language-Team: LANGUAGE <LL@li.org>\\n"
@@ -123,8 +124,8 @@ def read_po(fileobj):
                 if msg.startswith('['):
                     pass # plural
 
-def write_po(fileobj, messages, project=None, version=None, creation_date=None,
-             charset='utf-8', no_location=False, omit_header=False):
+def write_po(fileobj, messages, project=None, version=None, charset='utf-8',
+             no_location=False, omit_header=False):
     r"""Write a ``gettext`` PO (portable object) file to the given file-like
     object.
     
@@ -165,15 +166,12 @@ def write_po(fileobj, messages, project=None, version=None, creation_date=None,
     def _normalize(key):
         return normalize(key, charset=charset)
 
-    if creation_date is None:
-        creation_date = datetime.now()
-
     if not omit_header:
         fileobj.write(POT_HEADER % {
-            'charset': charset,
-            'time': creation_date.strftime('%Y-%m-%d %H:%M'),
             'project': project,
-            'version': version
+            'version': version,
+            'creation_date': time.strftime('%Y-%m-%d %H:%M%z'),
+            'charset': charset,
         })
 
     locations = {}