'sort output by file location (default False)'),
('msgid-bugs-address=', None,
'set report address for msgid'),
+ ('copyright-holder=', None,
+ 'set copyright holder in output'),
('input-dirs=', None,
'directories that should be scanned for messages'),
]
self.sort_output = False
self.sort_by_file = False
self.msgid_bugs_address = None
+ self.copyright_holder = None
def finalize_options(self):
if self.no_default_keywords and not self.keywords:
version=self.distribution.get_version(), width=self.width,
charset=self.charset, no_location=self.no_location,
omit_header=self.omit_header, sort_output=self.sort_output,
- sort_by_file=self.sort_by_file)
+ sort_by_file=self.sort_by_file,
+ copyright_holder=self.copyright_holder)
finally:
outfile.close()
parser.add_option('--msgid-bugs-address', dest='msgid_bugs_address',
metavar='EMAIL@ADDRESS',
help='set report address for msgid')
+ parser.add_option('--copyright-holder', dest='copyright_holder',
+ help='set copyright holder in output')
parser.set_defaults(charset='utf-8', keywords=[],
no_default_keywords=False, no_location=False,
charset=options.charset, no_location=options.no_location,
omit_header=options.omit_header,
sort_output=options.sort_output,
- sort_by_file=options.sort_by_file)
+ sort_by_file=options.sort_by_file,
+ copyright_holder=options.copyright_holder)
finally:
if options.output:
outfile.close()
POT_HEADER = """\
# Translations template for %(project)s.
-# Copyright (C) %(year)s ORGANIZATION
+# Copyright (C) %(year)s %(copyright_holder)s
# This file is distributed under the same license as the
# %(project)s project.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
def write_pot(fileobj, catalog, project='PROJECT', version='VERSION', width=76,
charset='utf-8', no_location=False, omit_header=False,
- sort_output=False, sort_by_file=False):
+ sort_output=False, sort_by_file=False, copyright_holder=None):
r"""Write a ``gettext`` PO (portable object) template file for a given
message catalog to the provided file-like object.
:param no_location: do not emit a location comment for every message
:param omit_header: do not include the ``msgid ""`` entry at the top of the
output
+ :param copyright_holder: sets the copyright holder in the output
"""
def _normalize(key):
return normalize(key, width=width).encode(charset, 'backslashreplace')
messages = list(catalog)
messages.sort(lambda x,y: cmp(x.locations, y.locations))
else:
- messages = catalog
+ messages = catalog
+
+ _copyright_holder = copyright_holder or 'ORGANIZATION'
for message in messages:
if not message.id: # This is the header "message"
_write(POT_HEADER % {
'year': time.strftime('%Y'),
'project': project,
+ 'copyright_holder': _copyright_holder,
})
if not no_location: