changeset 5:132526dcd074 trunk

* The creation-date header in generated PO files now includes the timezone offset. * The distutils frontend pulls the project name and version from the distribution object.
author cmlenz
date Wed, 30 May 2007 10:16:37 +0000
parents 5a7f2bc6b114
children c3b1b0b3d129
files babel/catalog/frontend.py babel/catalog/pofile.py
diffstat 2 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/babel/catalog/frontend.py
+++ b/babel/catalog/frontend.py
@@ -56,7 +56,7 @@
          '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 @@
                 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()
--- a/babel/catalog/pofile.py
+++ b/babel/catalog/pofile.py
@@ -20,8 +20,9 @@
 
 # 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 @@
 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 @@
                 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 _normalize(key):
         return normalize(key, charset=charset)
 
-    if creation_date is None:
-        creation_date = datetime.now()
-
     if not omit_header:
         fileobj.write(POT_HEADER % {
+            'project': project,
+            'version': version,
+            'creation_date': time.strftime('%Y-%m-%d %H:%M%z'),
             'charset': charset,
-            'time': creation_date.strftime('%Y-%m-%d %H:%M'),
-            'project': project,
-            'version': version
         })
 
     locations = {}
Copyright (C) 2012-2017 Edgewall Software