'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']
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()
# TODO: line wrapping
-from datetime import datetime
+from datetime import date, datetime
import re
+import time
from babel import __version__ as VERSION
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"
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.
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 = {}