Edgewall Software

Changes between Version 8 and Version 9 of CookBook/PluginL10N


Ignore:
Timestamp:
May 9, 2010, 3:19:03 PM (14 years ago)
Author:
hasienda <hoff.st@…>
Comment:

added some more information

Legend:

Unmodified
Added
Removed
Modified
  • CookBook/PluginL10N

    v8 v9  
    77If you want to learn about translation for a plugin, that as you know already provides one/several message catalog/s, the section '[#Dotranslatorswork Do translators work]' and following parts are for you.
    88
    9 Ultimately, all plugin maintainers and developers in general, that are facing requests and are willing to take care for growing demand of their plugin to speak same (foreign) language(s) as Trac >= 0.12 should just read on.
     9Ultimately, all plugin maintainers and developers in general, who are facing requests and are willing to take care for growing demand of their plugin to speak same (foreign) language(s) as Trac >= 0.12 should just read on.
    1010
    1111== i18n, l10n, ... help! ==
     
    5050assuming that folder `locale` will reside in `./foo/locale/` within the directory structure (as observable inside the Python egg after packaging).
    5151
    52 If you didn't have it in the source by now, add a
     52[FIXME: explain what _version and ui are used for or leave them out, if unnecessary here]
     53
     54If you didn't have it in the source by now, add another import statement
    5355{{{
    5456import pkg_resources
     
    5658at the beginning of the plugin script as well or the line `locale_dir = ...` (see previous code snippet) will throw an '!ImportError'.
    5759
    58 [FIXME: explain what _version and ui are used for or leave them out, if unnecessary here]
     60The i18n/l10n helper programs are available inside the plugin now, but if the plugin code contains several python script files and you encounter text for translation in one of them too, you need to import the functions from the main script, say it's name is `api.py`, there:
     61{{{
     62from api import _, tag_, N_
     63}}}
    5964
    6065==== Preset configuration for i18n/l10n helper programs ====
     
    104109
    105110==== Register message catalog files for packaging ====
    106 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`.
     111To include the translated messages into the packaged plugin you need to add the path to the catalog files to `package_data` in `setup.py`:
     112{{{
     113diff -u a/foo/setup.py b/foo/setup.py
     114--- a/foo/setup.py
     115+++ b/foo/setup.py
     116@@ -39,6 +39,8 @@
     117     package_data = {
     118         'foo': [
     119             'htdocs/css/*.css',
     120+            'locale/*.*',
     121+            'locale/*/LC_MESSAGES/*.*',
     122         ],
     123     },
     124     entry_points = {
     125}}}
    107126
    108127==== Announce new plugin version ====
    109 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.
     128The 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. If it is strictly required for your plugin, have a look at `setup.py` of the [browser:plugins/0.12/mercurial-plugin/setup.py?rev=9133 Mercurial plugin] provided with Trac.
    110129
    111 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`.
     130In all other cases you'll just add a line like the following as another argument to the setup() function in plugin's `setup.py`:
     131{{{
     132install_requires = ['Trac >= 0.12dev'],
     133}}}
     134
     135All 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`. And you may wish to leave a note regarding your i18n work along the copyright notices as well.
    112136
    113137=== Do translators work ===