SVN: CMF/trunk/i18nextract.py - updated i18nextract.py

Yvo Schubbe <[email protected]>
Newsgroups gmane.comp.web.zope.cmf.cvs
Message-ID <[email protected]>
Log message for revision 71027:
  - updated i18nextract.py

Changed:
  U   CMF/trunk/i18nextract.py

-=-
Modified: CMF/trunk/i18nextract.py
===================================================================
--- CMF/trunk/i18nextract.py	2006-11-02 11:09:26 UTC (rev 71026)
+++ CMF/trunk/i18nextract.py	2006-11-02 17:32:22 UTC (rev 71027)
@@ -37,17 +37,26 @@
     -p / --path <path>
         Specifies the package that is supposed to be searched
         (i.e. 'zope/app')
+    -s / --site_zcml <path>
+        Specify the location of the 'site.zcml' file. By default the regular
+        Zope 3 one is used.
+    -e / --exclude-default-domain
+        Exclude all messages found as part of the default domain. Messages are
+        in this domain, if their domain could not be determined. This usually
+        happens in page template snippets.
     -o dir
         Specifies a directory, relative to the package in which to put the
         output translation template.
     -x dir
         Specifies a directory, relative to the package, to exclude.
         May be used more than once.
+    --python-only
+        Only extract message ids from Python
 
 $Id$
 """
-# XXX: This is a modified copy of zope3's utilities/i18nextract.py (r41131).
-#      It includes some modified code from zope.app.locales.extract (r41131).
+# XXX: This is a modified copy of zope3's utilities/i18nextract.py (r68098).
+#      It includes some modified code from zope.app.locales.extract (r69514).
 #      Extracting from ZCML is disabled for now.
 #
 #      This is just used to create .pot files for CMF. Don't make your code
@@ -80,7 +89,7 @@
 ##############################################################################
 msgid ""
 msgstr ""
-"Project-Id-Version: CMF 2.0\\n"
+"Project-Id-Version: CMF 2.1\\n"
 "POT-Creation-Date: $Date$\\n"
 "Language-Team: CMF Developers <[email protected]>\\n"
 "MIME-Version: 1.0\\n"
@@ -96,7 +105,6 @@
     def write(self):
         file = open(self._output_filename, 'w')
         file.write(pot_header % {'time':     time.ctime(),
-                                 'version':  self._getProductVersion(),
                                  'charset':  DEFAULT_CHARSET,
                                  'encoding': DEFAULT_ENCODING})
 
@@ -211,14 +219,16 @@
     # When the Domain is 'default', then this means that none was found;
     # Include these strings; yes or no?
     if include_default_domain:
-        catalog.update(engine.catalog['zope'])
+        defaultCatalog = engine.catalog.get('default')
+        if defaultCatalog == None:
+            engine.catalog['default'] = {}
+        catalog.update(engine.catalog['default'])
     for msgid, locations in catalog.items():
         catalog[msgid] = map(lambda l: (l[0], l[1][0]), locations)
     return catalog
 
 
 import os, sys, getopt
-
 def usage(code, msg=''):
     # Python 2.1 required
     print >> sys.stderr, __doc__
@@ -254,8 +264,8 @@
     try:
         opts, args = getopt.getopt(
             sys.argv[1:],
-            'hd:p:o:x:',
-            ['help', 'domain=', 'path=', 'python-only'])
+            'hd:s:i:p:o:x:',
+            ['help', 'domain=', 'site_zcml=', 'path=', 'python-only'])
     except getopt.error, msg:
         usage(1, msg)
 
@@ -264,12 +274,16 @@
     include_default_domain = True
     output_dir = None
     exclude_dirs = []
-    python_only = None
+    python_only = False
+    site_zcml = None
     for opt, arg in opts:
         if opt in ('-h', '--help'):
             usage(0)
         elif opt in ('-d', '--domain'):
             domain = arg
+        elif opt in ('-s', '--site_zcml'):
+            site_zcml = arg
+        elif opt in ('-e', '--exclude-default-domain'):
             include_default_domain = False
         elif opt in ('-o', ):
             output_dir = arg
@@ -302,15 +316,19 @@
 
     print "base path: %r\n" \
           "search path: %s\n" \
+          "'site.zcml' location: %s\n" \
           "exclude dirs: %r\n" \
           "domain: %r\n" \
-          "output file: %r" \
-          % (base_dir, path, exclude_dirs, domain, output_file)
+          "include default domain: %r\n" \
+          "output file: %r\n" \
+          "Python only: %r" \
+          % (base_dir, path, site_zcml, exclude_dirs, domain,
+             include_default_domain, output_file, python_only)
 
     maker = POTMaker(output_file, path)
     maker.add(py_strings(path, domain, exclude=exclude_dirs), base_dir)
     if not python_only:
-        maker.add(zcml_strings(path, domain), base_dir)
+        maker.add(zcml_strings(path, domain, site_zcml), base_dir)
         maker.add(tal_strings(path, domain, include_default_domain,
                               exclude=exclude_dirs), base_dir)
     maker.write()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.