Package: iwm.recipe.i18n
ContentsDetailed DocumentationParameterExampleDetailsDownloadThis recipe generate calls of zope3 i18n utilities i18nextract and i18nmaergeall
for collecting and merging msgstr from packages.Detailed DocumentationI18n RecipeParameterThis recipe generate calls of zope3 i18n utilities i18nextract and i18nmaergeall
for collecting and merging msgstr from packages.The recipe has two options:eggsThe eggs option specified a list of eggs to test given as one ore
more setuptools requirement strings.  Each string must be given on
a separate line.extra-pathsOne or more extra paths to include in the generated i18nextract script.ExampleIn Bebop the name of the domain is ‘bebop’, the package is ‘src/bebop’,
the output relative to the package is locales, and the location of site.zcml
is parts/instance/etc/site.zcml. The buildout snippet looks like:[i18n]
recipe = iwm.recipe.i18n
eggs = ${testinstance:eggs}
       iwm.recipe.i18n
extra-paths = parts/zope3/src
              parts/zope3/utilitiesTo re-extract i18n messages from the code executebin/i18nextractfrom your buildout directory:$ bin/i18nextract -d <domain> -p <path> -o <locales> -s <site.zcml>This will update the<domain>.potfile.To merge those changes to all existing translations you can do that by
executing thebin/i18nmergeallscript from your buildout directory:$ bin/i18nmergeall -l <path>/<locales>DetailsThe following text is partly lend from zc.recipe.testrunner.README.txt.To illustrate this, we’ll create a pair of projects in our sample
buildout:>>> mkdir(sample_buildout, 'demo')
>>> mkdir(sample_buildout, 'demo', 'demo')
>>> write(sample_buildout, 'demo', 'demo', '__init__.py', '')
>>> write(sample_buildout, 'demo', 'setup.py',
... """
... from setuptools import setup
...
... setup(name = "demo")
... """)

>>> mkdir(sample_buildout, 'demo2')
>>> mkdir(sample_buildout, 'demo2', 'demo2')
>>> write(sample_buildout, 'demo2', 'demo2', '__init__.py', '')
>>> write(sample_buildout, 'demo2', 'setup.py',
... """
... from setuptools import setup
...
... setup(name = "demo2", install_requires= ['demoneeded'])
... """)Demo 2 depends on demoneeded:>>> mkdir(sample_buildout, 'demoneeded')
>>> mkdir(sample_buildout, 'demoneeded', 'demoneeded')
>>> write(sample_buildout, 'demoneeded', 'demoneeded', '__init__.py', '')
>>> write(sample_buildout, 'demoneeded', 'setup.py',
... """
... from setuptools import setup
...
... setup(name = "demoneeded")
... """)We’ll update our buildout to install the demo project as a
develop egg and to create the test script:>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = demo demoneeded demo2
... parts = i18n
... offline = true
...
... [i18n]
... recipe = iwm.recipe.i18n
... eggs =
...    demo
...    demo2
... extra-paths = parts/zope3/src
...               parts/zope3/utilities
... """)Note that we specified both demo and demo2 in the eggs
option and that we put them on separate lines.We also specified the offline option to run the buildout in offline mode.Now when we run the buildout:>>> import os
>>> os.chdir(sample_buildout)
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),We get a i18n script installed in our bin directory:>>> ls(sample_buildout, 'bin')
-  buildout
-  i18nextract
-  i18nmergeallWe take a look of the content of i18nextract:>>> cat(sample_buildout, 'bin', 'i18nextract') # doctest:
#!python
<BLANKLINE>
import sys
sys.path[0:0] = [
  '/sample-buildout/demo',
  '/sample-buildout/demo2',
  '/sample-buildout/eggs/zope.testing-X-pyN.N.egg',
  '/sample-buildout/eggs/setuptools-X-pyN.N.egg',
  '/sample-buildout/demoneeded',
  '/sample-buildout/parts/zope3/src',
  '/sample-buildout/parts/zope3/utilities',
  ]
<BLANKLINE>
import os
sys.argv[0] = os.path.abspath(sys.argv[0])
<BLANKLINE>
<BLANKLINE>
import i18nextract
<BLANKLINE>
if __name__ == '__main__':
    i18nextract.main()And the content of i18nmergeall:>>> cat(sample_buildout, 'bin', 'i18nmergeall') # doctest:
#!python
<BLANKLINE>
import sys
sys.path[0:0] = [
  '/sample-buildout/demo',
  '/sample-buildout/demo2',
  '/sample-buildout/eggs/zope.testing-X-pyN.N.egg',
  '/sample-buildout/eggs/setuptools-X-pyN.N.egg',
  '/sample-buildout/demoneeded',
  '/sample-buildout/parts/zope3/src',
  '/sample-buildout/parts/zope3/utilities',
  ]
<BLANKLINE>
import os
sys.argv[0] = os.path.abspath(sys.argv[0])
<BLANKLINE>
<BLANKLINE>
import iwm.recipe.i18n.ctl
<BLANKLINE>
if __name__ == '__main__':
    iwm.recipe.i18n.ctl.main_i18nmergeall()Download