Skip to main content

This recipe generate calls of zope3 i18n utilities i18nextract and i18nmaergeall for collecting and merging msgstr from packages.

Detailed Documentation

I18n Recipe

Parameter

This recipe generate calls of zope3 i18n utilities i18nextract and i18nmaergeall for collecting and merging msgstr from packages.

The recipe has two options:

eggs

The 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-paths

One or more extra paths to include in the generated i18nextract script.

Example

In 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/utilities

To re-extract i18n messages from the code execute bin/i18nextract from your buildout directory:

$ bin/i18nextract -d <domain> -p <path> -o <locales> -s <site.zcml>

This will update the <domain>.pot file.

To merge those changes to all existing translations you can do that by executing the bin/i18nmergeall script from your buildout directory:

$ bin/i18nmergeall -l <path>/<locales>

Details

The 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
-  i18nmergeall

We 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

Release files for iwm.recipe.i18n 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for iwm.recipe.i18n 0.0.1
File Interpreter ABI Platform
iwm.recipe.i18n-0.0.1-py2.4.egg Legacy Egg format - - Details

Release files / iwm.recipe.i18n-0.0.1-py2.4.egg

Download URL iwm.recipe.i18n-0.0.1-py2.4.egg
Size 10.8 kB
Tags Egg
SHA-256 checksum
How to use checksums
fea8d40a2adc7be4a6e8b670fbcc405110c488e04fbd6a7754522810ea5a2f37
BLAKE2b-256 checksum
How to use checksums
9bf5d3cbff423c38abb8e6f5d33b35d717cd5f190c3db18075a142965121a7ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page