Changes between Version 8 and Version 9 of CookBook/PluginL10N
- Timestamp:
- May 9, 2010, 3:19:03 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CookBook/PluginL10N
v8 v9 7 7 If 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. 8 8 9 Ultimately, all plugin maintainers and developers in general, thatare 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.9 Ultimately, 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. 10 10 11 11 == i18n, l10n, ... help! == … … 50 50 assuming that folder `locale` will reside in `./foo/locale/` within the directory structure (as observable inside the Python egg after packaging). 51 51 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 54 If you didn't have it in the source by now, add another import statement 53 55 {{{ 54 56 import pkg_resources … … 56 58 at the beginning of the plugin script as well or the line `locale_dir = ...` (see previous code snippet) will throw an '!ImportError'. 57 59 58 [FIXME: explain what _version and ui are used for or leave them out, if unnecessary here] 60 The 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 {{{ 62 from api import _, tag_, N_ 63 }}} 59 64 60 65 ==== Preset configuration for i18n/l10n helper programs ==== … … 104 109 105 110 ==== 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`. 111 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`: 112 {{{ 113 diff -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 }}} 107 126 108 127 ==== 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.128 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. 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. 110 129 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`. 130 In 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 {{{ 132 install_requires = ['Trac >= 0.12dev'], 133 }}} 134 135 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`. And you may wish to leave a note regarding your i18n work along the copyright notices as well. 112 136 113 137 === Do translators work ===