Changes between Version 13 and Version 14 of CookBook/PluginL10N
- Timestamp:
- May 10, 2010, 8:19:18 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CookBook/PluginL10N
v13 v14 1 = Adding i18n/l10n to Trac plugins (Trac >= 0.12)=1 = Adding i18n/l10n to Trac plugins ^(Trac >= 0.12)^ = 2 2 == Intro and Motivation == 3 3 Are you a user of Trac and do your work with it, nothing more? Well, you may ignore this page and go on reading another subpage of [wiki:CookBook CookBook]. … … 21 21 Now adding the needed i18n/l10n helper functions is done by importing a set of functions from `trac/util/translation.py` and providing proper configuration for an additional translation layer ('domain') inside the plugin code. On plugin initialization the dedicated translation domain is created as well and corresponding catalog files holding translated messages are loaded into it. Whenever a translatable text is encountered during runtime inside plugin's code, i18n/l10n helper functions will try to get the corresponding translation from the message catalog of plugin's domain and fall back silently to Trac's main message catalog, if needed. 22 22 23 // 23 The message catalog selection is done according to the locale setting. Valid settings are a combination of language and country code, optionally extended further by the character encoding used, i.e. to read like ‘de_DE.UTF-8’. Trac uses UTF-8 encoding internally, so there is not much to tell about that. 'C' is a special locale code since it disables all translations and programs use English texts as required by POSIX standard.^3^ 24 25 {{{#!comment 24 26 Both searches take the locale setting as a second request argument. Valid settings are a combination of language and country code, often extended further by the character encoding used, i.e. to read like ‘de_DE.UTF-8’. The encoding is of special relevance for languages that had an older encoding per default that was not sufficient for all common chars used by native speakers of that language. 'C' is a special locale code since it disables all translations and programs use English texts as required by POSIX standard. Character encoding is highly dependent on the underlying operation system then.^3^ 25 27 // … … 27 29 I don't think the character encoding plays any role here (we deal with unicode internally, 28 30 catalogs themselves are always encoded in UTF-8) - cboos 31 Thanks for the hint on non-relevance for Trac since this has that uniform encoding. So I hope the current text is better. 32 This might be deleted than. 33 }}} 29 34 30 35 First matching translation will replace the default text what by gettext convention is the same as the msgid, that is used, if all attempts fail to find an exact matching translation. … … 106 111 107 112 This will tell the i18n/l10n helper programs where to look for and store message catalog files. 113 114 {{{#!comment 115 resume review here... 116 }}} 108 117 109 118 In the `extract_messages` section there is just one more lines you may like to change: `msgid_bugs_address`. To allow for direct feedback regarding your i18n work add a valid e-mail address or a mailing list dedicated to translation issues there.