Edgewall Software

Changes between Version 1 and Version 2 of CookBook/PluginL10N


Ignore:
Timestamp:
May 7, 2010, 12:13:04 PM (14 years ago)
Author:
hasienda <hoff.st@…>
Comment:

added more content - just a step revision

Legend:

Unmodified
Added
Removed
Modified
  • CookBook/PluginL10N

    v1 v2  
    3131a walk-through
    3232
    33 General advice of [wiki:TracL10N TracL10N] on making good translation for Trac in general applies here too.
     33General advice from [wiki:TracL10N TracL10N] on making good translation for Trac in general applies here too.
    3434
    35 === Preparing the pluging code ===
     35=== Preparing the plugin code ===
     36==== Provide translation configuration ====
     37add lines to `setup.cfg`, or if it doesn't exist, create it
     38This will tell the translation helper programs where to look and store message catalog files. Since this is a per plugin translation, you need to customize the code to the plugins name wherever it reads `foo` in the example.
     39
     40==== Mark text for extraction ====
     41In python scripts you'll have to wrap text with the translation function `_()` to get it handled by translation helper programs. Some code, that was
     42{{{
     43    msg = 'This is a msg text.'
     44}}}
     45before, will read like
     46{{{
     47    msg = _('This is a msg text.')
     48}}}
     49afterwards.
     50
     51This is a somewhat time consuming task depending on the size of the plugin's code. If you initially fail to find all desired texts you may notice this by missing them from the message catalog later and come back to this step again. If the plugin maintainer is unaware of your l10n work or unwilling to support it and he adds more message without the translation function call, remember that you have to do the wrapping of these new texts too.
     52
     53Message extraction for Genshi templates should be done auto-magically. However there is a markup available, to ensure extraction even from less common tags.
     54
     55[FIXME: add details about msg extraction from templates and other files]
     56
     57==== Register new files for packaging ====
     58To include the translated messages into the packaged plugin you need to add the path to the catalog files to `package_data` in `setup.py`.
     59
     60==== New plugin version ====
     61The plugin will not work with any Trac version before 0.12dev, since import of the translation helper functions introduced for 0.12 will fail. It is possible to wrap the import with a `try:` and define dummy functions in a corresponding `except ImportError:` to allow the plugin to work with older versions of Trac, but there might already be a different version for 0.11 and 0.12, so this is not required in most cases.
     62
     63All the work you did by now will go unnoticed, at least with regard to package naming. To help with identification of the new revision you should bump the plugin's version. This is done by changing the version/revision, typically in `setup.cfg` or `setup.py`.
     64
     65
    3666=== Translation work ===
     67
    3768=== Compilation and testing ===
     69Compile the `messages.po` catalog file with your translations into a machine readable `messages.mo` file.
     70
     71Now go for the plugin packaging, make the python egg.
     72
    3873=== Advanced stuff ===
    3974==== Finally l10n ====