# HG changeset patch # User palgarvio # Date 1181468366 0 # Node ID 9a05230571f8c97f41f79586cacdf98e8b347172 # Parent ee043bb666f01ea780413062dbc00248f0ab17cc Implemented item 4 from #12. Set the copyright holder in the output. diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py --- a/babel/messages/frontend.py +++ b/babel/messages/frontend.py @@ -85,6 +85,8 @@ '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'), ] @@ -107,6 +109,7 @@ 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: @@ -164,7 +167,8 @@ 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() @@ -408,6 +412,8 @@ 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, @@ -467,7 +473,8 @@ 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() diff --git a/babel/messages/pofile.py b/babel/messages/pofile.py --- a/babel/messages/pofile.py +++ b/babel/messages/pofile.py @@ -129,7 +129,7 @@ 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 , YEAR. @@ -223,7 +223,7 @@ 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. @@ -259,6 +259,7 @@ :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') @@ -279,7 +280,9 @@ 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" @@ -288,6 +291,7 @@ _write(POT_HEADER % { 'year': time.strftime('%Y'), 'project': project, + 'copyright_holder': _copyright_holder, }) if not no_location: diff --git a/doc/cmdline.txt b/doc/cmdline.txt --- a/doc/cmdline.txt +++ b/doc/cmdline.txt @@ -65,6 +65,8 @@ --sort-by-file sort output by file location (default False) --msgid-bugs-address=EMAIL@ADDRESS set report address for msgid + --copyright-holder=COPYRIGHT_HOLDER + set copyright holder in output init diff --git a/doc/setup.txt b/doc/setup.txt --- a/doc/setup.txt +++ b/doc/setup.txt @@ -61,6 +61,7 @@ --sort-output generate sorted output (default False) --sort-by-file sort output by file location (default False) --msgid-bugs-address set report address for msgid + --copyright-holder set copyright holder in output --input-dirs directories that should be scanned for messages usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]