Changes between Version 14 and Version 15 of CookBook/PluginL10N
- Timestamp:
- May 18, 2010, 11:50:09 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CookBook/PluginL10N
v14 v15 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 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^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.^[#a3 3]^ 24 24 25 25 {{{#!comment 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^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.^[#a3 3]^ 27 27 // 28 28 I'm not sure to what the above refers. Which search? What locale argument? … … 133 133 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 i18n 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. 134 134 135 Message extraction for Genshi templates should be done auto-magically. However there is the markup `i18n:msg` available to ensure extraction even from less common tags. But there are not all issues settled with some special cases for message extraction from Genshi templates, i.e. see [g:ticket:385 Genshi ticket 385]. You should search for similar issues you may encounter while trying to handle plugin templates.135 Message extraction for Genshi templates should be done auto-magically. However there is the markup `i18n:msg` available to ensure extraction even from less common tags. For a real-world example have a look at [changeset:9542/trunk/trac/ticket/templates/ Trac SVN changeset r9542] for marking previously undetected text in templates. But there are not all issues settled with some special cases for message extraction from Genshi templates, i.e. see [g:ticket:385 Genshi ticket 385]. You should search for similar issues you may encounter while trying to handle plugin templates. 136 136 137 137 [FIXME: add more details about msg extraction from other files] … … 173 173 174 174 === Do translators work === 175 General advice from [wiki:TracL10N TracL10N] on making good translation for Trac in general applies here too. For those who read previous parts, you do notice that we switch from talking about i18n to 'l10n' now, don't you? No source code mangling. All code below is no meant to become part of the plugin source but meant to be put to the command line. 175 General advice from [wiki:TracL10N TracL10N] on making good translation for Trac applies here too. 176 177 I.e. it's desirable to maintain a consistent wording across Trac and Trac plugins. 178 Since this is going beyond the scope of aforementioned [wiki:TracL10N TracL10N], there might be the need for more coordination. 179 Consider joining the [th:wiki:TracPluginTranslation Trac plugin l10n project], that utilizes [http://www.transifex.net/projects/p/Trac_Plugin-L10N/ Transifex] for uniform access to message catalogs for multiple plugins backed by a dedicated (Mercurial) [http://bitbucket.org/hasienda/trac_plugins-l10n message catalog repository] at Bitbucket.org. 180 Trac has some language teams at Transifex as well, so this is a good chance for tight translator cooperation. 181 182 For those who read previous parts, you do notice that we switch from talking about i18n to 'l10n' now, don't you? 183 No source code mangling. All code below is no meant to become part of the plugin source but meant to be put to the command line. 176 184 177 185 Switch to root directory of plugin's source, i.e.: … … 198 206 As you may guess, there is not much to be done, if the helper programs don't know what language you'd like to work on, so the language selection argument `-l` and identifier string are mandatory here. 199 207 200 Now fire up the editor of your choice. There are dedicated message catalog (.po) file editors that ensure for quick results as a beginner as well as make working on large message catalogs with few untranslated texts or translations marked 'fuzzy' much more convenient. See dedicated resources for details on choosing an editor program as well as for help on editing .po files.^ 4, 5^208 Now fire up the editor of your choice. There are dedicated message catalog (.po) file editors that ensure for quick results as a beginner as well as make working on large message catalogs with few untranslated texts or translations marked 'fuzzy' much more convenient. See dedicated resources for details on choosing an editor program as well as for help on editing .po files.^[#a4 4], [#a5 5]^ 201 209 202 210 If not already taken care for by your (PO) editor, the place to announce yourself as the last translator is after the default `TRANSLATOR:` label at top of the message catalog file. … … 218 226 219 227 === Advanced stuff === 220 ==== Finally 'true' l10n ==== 228 ==== About 'true' l10n ==== 229 A human translator will/should do better than an automatic translation, 230 since good l10n has more of a transcription than pure translation word by word. 231 It's encouraging to see the raise of native words for such terms like changeset, ticket and repository in different languages. 232 This will help Trac to not only fulfill it's promise to help project teams focusing on their work but even extend it's use to project management in general, where use of native language is much more common or even required in contrast to the traditional software development. 233 234 Details on that matter tend to become religious, so let's stop here. 221 235 222 236 == Related resources ==