[Checkins] SVN: z3c.recipe.i18n/trunk/ Added buildout option `verify_domain`. When set to ``true`` i18nextract only retrives the message ids of specified domain from python files. Otherwise (default and previous behavior) all messages ids in all domains in python files are retrieved.
Michael Howitz
mh at gocept.com
Thu Feb 18 04:17:06 EST 2010
Log message for revision 109104:
Added buildout option `verify_domain`. When set to ``true`` i18nextract only retrives the message ids of specified domain from python files. Otherwise (default and previous behavior) all messages ids in all domains in python files are retrieved.
Changed:
U z3c.recipe.i18n/trunk/CHANGES.txt
U z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/README.txt
U z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18n.py
U z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18nextract.py
-=-
Modified: z3c.recipe.i18n/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.i18n/trunk/CHANGES.txt 2010-02-18 01:40:27 UTC (rev 109103)
+++ z3c.recipe.i18n/trunk/CHANGES.txt 2010-02-18 09:17:06 UTC (rev 109104)
@@ -7,7 +7,12 @@
- Fixed test setup to run with current packages.
+- Added buildout option `verify_domain`. When set to ``true``
+ i18nextract only retrives the message ids of specified domain from
+ python files. Otherwise (default and previous behavior) all messages
+ ids in all domains in python files are retrieved.
+
0.6.0 (2009-12-02)
------------------
Modified: z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/README.txt
===================================================================
--- z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/README.txt 2010-02-18 01:40:27 UTC (rev 109103)
+++ z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/README.txt 2010-02-18 09:17:06 UTC (rev 109104)
@@ -5,7 +5,7 @@
z3c.recipe.i18n
---------------
-This Zope 3 recipes offers different tools which allows to extract i18n
+This Zope 3 recipes offers different tools which allows to extract i18n
translation messages from egg based packages.
The 'i18n' recipe can be used to generate the required scripts for extract
@@ -33,7 +33,7 @@
packages
The names of one or more eggs which the messages should get extracted from.
Note, this is different to the original zope.app.locales implementation.
- The original implementation uses one path as -d argument which assumes a
+ The original implementation uses one path as -d argument which assumes a
specific zope.* package structure with an old style trunk setup.
domain
@@ -45,14 +45,14 @@
maker
One or more module name which can get used as additional maker. This module
must be located in the python path because it get resolved by
- zope.configuration.name.resolve. For a sample maker see
+ zope.configuration.name.resolve. For a sample maker see
z3c.csvvocabulary.csvStrings.
Makers are called with these arguments: 'path', 'base_path', 'exclude_dirs',
'domain', 'include_default_domain' and 'site_zcml'. The return value has to
be a catalog dictionary.
zcml (required)
- The contents of configuration used for extraction. Normaly used for load
+ The contents of configuration used for extraction. Normaly used for load
meta configuration.
excludeDefaultDomain (optional, default=False)
@@ -63,16 +63,21 @@
pythonOnly (optional, default=False)
Only extract message ids from Python (False if not used)
+verify_domain (optional, default=False)
+ Retrieve all the messages in all the domains in python files when
+ verify_domain is False otherwise only retrive the messages of the
+ specified domain. (False if not used)
+
exludeDirectoryName (optional, default=[])
- Allows to specify one or more directory name, relative to the package, to
+ Allows to specify one or more directory name, relative to the package, to
exclude. (None if not used)
headerTemplate (optional, default=None)
The path of the pot header template relative to the buildout directory.
environment
- A section name defining a set of environment variables that should be
- exported before starting the tests. Can be used for set product
+ A section name defining a set of environment variables that should be
+ exported before starting the tests. Can be used for set product
configuration enviroment.
extraPaths
@@ -91,7 +96,7 @@
... from setuptools import setup
... setup(name = 'demo1')
... ''')
-
+
>>> mkdir('demo2')
>>> write('demo2', 'setup.py',
... '''
@@ -242,6 +247,7 @@
... maker = z3c.csvvocabulary.csvStrings
... excludeDefaultDomain = true
... pythonOnly = true
+ ... verify_domain = true
... exludeDirectoryName = foo
... bar
... headerTemplate = pot_header.txt
@@ -293,7 +299,7 @@
import z3c.recipe.i18n.i18nextract
<BLANKLINE>
if __name__ == '__main__':
- z3c.recipe.i18n.i18nextract.main(['i18nextract', '-d', 'recipe', '-s', '/sample-buildout/parts/i18n/configure.zcml', '-o', '/sample-buildout/outputDir', '--exclude-default-domain', '--python-only', '-m', 'z3c.csvvocabulary.csvStrings', '-p', 'demo1', '-x', 'foo', '-x', 'bar', '-t', '/sample-buildout/pot_header.txt'])
+ z3c.recipe.i18n.i18nextract.main(['i18nextract', '-d', 'recipe', '-s', '/sample-buildout/parts/i18n/configure.zcml', '-o', '/sample-buildout/outputDir', '--exclude-default-domain', '--python-only', '--verify-domain', '-m', 'z3c.csvvocabulary.csvStrings', '-p', 'demo1', '-x', 'foo', '-x', 'bar', '-t', '/sample-buildout/pot_header.txt'])
i18nmergeall
------------
Modified: z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18n.py
===================================================================
--- z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18n.py 2010-02-18 01:40:27 UTC (rev 109103)
+++ z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18n.py 2010-02-18 09:17:06 UTC (rev 109104)
@@ -67,7 +67,8 @@
excludeDefaultDomain = self.options.get('excludeDefaultDomain',
False)
- pythonOnly = self.options.get('pythonOnly', False)
+ pythonOnly = self.options.get('pythonOnly', False)
+ verify_domain = self.options.get('verify_domain', False)
# setup configuration file
zcml = self.options.get('zcml', None)
@@ -108,6 +109,9 @@
if pythonOnly:
arguments.extend(['--python-only'])
+ if verify_domain:
+ arguments.extend(['--verify-domain'])
+
makers = [m for m in self.options.get('maker', '').split() if m!='']
for m in makers:
arguments.extend(['-m', m])
@@ -118,7 +122,7 @@
for p in packages:
arguments.extend(['-p', p])
- exludeDirNames = [x for x
+ exludeDirNames = [x for x
in self.options.get('exludeDirectoryName', '').split()
if x!='']
for x in exludeDirNames:
Modified: z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18nextract.py
===================================================================
--- z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18nextract.py 2010-02-18 01:40:27 UTC (rev 109103)
+++ z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18nextract.py 2010-02-18 09:17:06 UTC (rev 109104)
@@ -16,8 +16,8 @@
Page Templates and ZCML located in egg packages.
This tool will extract all findable message strings from all
-internationalizable files in your defined eggs product. It only extracts
-message ids of the specified domain. It defaults to the 'z3c' domain and the
+internationalizable files in your defined eggs product. It only extracts
+message ids of the specified domain. It defaults to the 'z3c' domain and the
z3c package whihc use the shared 'z3c' i18n namespace.
Note: The Python Code extraction tool does not support domain
@@ -53,6 +53,8 @@
May be used more than once.
--python-only
Only extract message ids from Python
+ --verify-domain
+ Only retrieve the messages of the specified domains in the python files.
-t <path>
Specifies the file path of the header template.
@@ -118,7 +120,7 @@
def zcml_strings(path, domain="zope", site_zcml=None):
"""Retrieve all ZCML messages from `dir` that are in the `domain`.
-
+
Note, the pot maker runs in a loop for each package and the maker collects
only the given messages from such a package by the given path. This allows
us to collect messages from eggs and external packages. This also prevents
@@ -151,7 +153,7 @@
argv[1:],
'hed:s:i:m:p:o:x:t:',
['help', 'domain=', 'site_zcml=', 'path=', 'python-only',
- 'exclude-default-domain'])
+ 'verify-domain', 'exclude-default-domain'])
except getopt.error, msg:
usage(1, msg)
@@ -160,6 +162,7 @@
output_dir = None
exclude_dirs = []
python_only = False
+ verify_domain = False
site_zcml = None
makers = []
eggPaths = []
@@ -181,6 +184,8 @@
exclude_dirs.append(arg)
elif opt in ('--python-only',):
python_only = True
+ elif opt in ('--verify-domain'):
+ verify_domain = True
elif opt in ('-p', '--package'):
package = resolve(arg)
path = os.path.dirname(package.__file__)
@@ -204,9 +209,10 @@
"exclude dirs: %r\n" \
"include default domain: %r\n" \
"python only: %r\n" \
+ "verify domain: %r\n" \
"header template: %r\n" \
% (domain, site_zcml, exclude_dirs, include_default_domain,
- python_only, header_template)
+ python_only, verify_domain, header_template)
# setup pot maker
maker = POTMaker(output_file, '', header_template)
@@ -226,7 +232,9 @@
"path: %r\n" \
% (pkgPath, basePath, path)
- maker.add(py_strings(path, domain, exclude=exclude_dirs), basePath)
+ maker.add(py_strings(path, domain, exclude=exclude_dirs,
+ verify_domain=verify_domain),
+ basePath)
if not python_only:
maker.add(zcml_strings(path, domain, site_zcml), basePath)
maker.add(tal_strings(path, domain, include_default_domain,
More information about the checkins
mailing list