]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Implemented item 4 from #12. Set the copyright holder in the output.
authorPedro Algarvio <pedro@algarvio.me>
Sun, 10 Jun 2007 09:39:26 +0000 (09:39 +0000)
committerPedro Algarvio <pedro@algarvio.me>
Sun, 10 Jun 2007 09:39:26 +0000 (09:39 +0000)
babel/messages/frontend.py
babel/messages/pofile.py
doc/cmdline.txt
doc/setup.txt

index e6d42ebfb5be7d0b034ba79bbd3b7b84467d7dab..168ca5edd99dbe36854b565a6fc5a65762233a27 100644 (file)
@@ -85,6 +85,8 @@ class extract_messages(Command):
          '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 @@ class extract_messages(Command):
         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 @@ class extract_messages(Command):
                      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 @@ class CommandLineInterface(object):
         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 @@ class CommandLineInterface(object):
                       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()
index b51ee31fe610c8a79d55d2a1af0dd644c1200f85..07933989ec6133b20331df35e4aa90db6ee7157b 100644 (file)
@@ -129,7 +129,7 @@ def read_po(fileobj):
 
 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.
@@ -223,7 +223,7 @@ def normalize(string, width=76):
 
 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 @@ def write_pot(fileobj, catalog, project='PROJECT', version='VERSION', width=76,
     :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 @@ def write_pot(fileobj, catalog, project='PROJECT', version='VERSION', width=76,
         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 @@ def write_pot(fileobj, catalog, project='PROJECT', version='VERSION', width=76,
             _write(POT_HEADER % {
                 'year': time.strftime('%Y'),
                 'project': project,
+                'copyright_holder': _copyright_holder,
             })
 
         if not no_location:
index e258c9176a9cdbe2a7fffa6f425e511e0712d4eb..8be6c75622ae704cc481dad5b19fdc3a15121830 100644 (file)
@@ -65,6 +65,8 @@ a collection of source files::
       --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
index bf7355f97b9ce2ab54f3590c83693c95b9093cd5..e988d60800e3817e9ca98f3cc01259efd352e137 100644 (file)
@@ -61,6 +61,7 @@ If the command has been correctly installed or registered, another project's
       --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] ...]