trac.dist

Extra commands for setup.py.

We provide a few extra command classes in l10n_cmdclass for localization tasks. We also modify the standard commands distutils.command.build and setuptools.command.install_lib classes in order to call the l10n commands for compiling catalogs at the right time during install.

class trac.dist.check_catalog(dist)

Bases: distutils.cmd.Command

Check message catalog command for use setup.py scripts.

Create and initialize a new Command object. Most importantly, invokes the ‘initialize_options()’ method, which is the real initializer and depends on the actual command being instantiated.

trac.dist.check_markup(catalog, message)

Verify markups in the translation.

trac.dist.extract_html(fileobj, keywords, comment_tags, options, text=False)

Extracts translatable texts from templates.

We simplify white-space found in translatable texts collected via the gettext function (which is what the trans directives use) and for text in the legacy Genshi templates, otherwise we would have near duplicates (e.g. admin.html, prefs.html).

We assume the template function gettext will do the same before trying to fetch the translation from the catalog.

trac.dist.extract_javascript_script(fileobj, keywords, comment_tags, options)

Extract messages from Javascript embedded in <script> tags.

Select <script type=”javascript/text”> tags and delegate to extract_javascript.

trac.dist.extract_python(fileobj, keywords, comment_tags, options)

Extract messages from Python source code, This is patched extract_python from Babel to support keyword argument mapping.

kwargs_maps option: names of keyword arguments will be mapping to index of messages array.

cleandoc_keywords option: a list of keywords to clean up the extracted messages with cleandoc.

trac.dist.extract_text(fileobj, keywords, comment_tags, options)

Extract messages from Genshi or Jinja2 text templates.

This is only needed as an interim measure, as long as we have both.

class trac.dist.generate_messages_js(dist)

Bases: distutils.cmd.Command

Generating message javascripts command for use setup.py scripts.

Create and initialize a new Command object. Most importantly, invokes the ‘initialize_options()’ method, which is the real initializer and depends on the actual command being instantiated.

trac.dist.simplify_message(message)

Transforms an extracted messsage (string or tuple) into one in which the repeated white-space has been simplified to a single space.