35 | | === Preparing the pluging code === |
| 35 | === Preparing the plugin code === |
| 36 | ==== Provide translation configuration ==== |
| 37 | add lines to `setup.cfg`, or if it doesn't exist, create it |
| 38 | This 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 ==== |
| 41 | In 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 | }}} |
| 45 | before, will read like |
| 46 | {{{ |
| 47 | msg = _('This is a msg text.') |
| 48 | }}} |
| 49 | afterwards. |
| 50 | |
| 51 | This 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 | |
| 53 | Message 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 ==== |
| 58 | To 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 ==== |
| 61 | The 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 | |
| 63 | All 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 | |