Edgewall Software

Changes between Version 6 and Version 7 of CookBook/PluginL10N


Ignore:
Timestamp:
May 9, 2010, 12:24:57 AM (14 years ago)
Author:
hasienda <hoff.st@…>
Comment:

added link to other related resource, minor editorial changes

Legend:

Unmodified
Added
Removed
Modified
  • CookBook/PluginL10N

    v6 v7  
    55Professional coders/translators, please skip to the actual cookbook content in '[#Requiredworkflow Required workflow]', since there can't be any news for you before that section.
    66
    7 If you want to learn about translation for a plugin, that as you know already provides one/several message catalog/s, section '[#Dotranslatorswork Do translators work]' and following parts are for you.
     7If 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 willing to take care for growing demand of their plugin speaking same (foreign) language(s) as Trac >= 0.12 should just read on.
     9Ultimately, 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.
    1010
    1111== i18n, l10n, ... help! ==
     
    1515
    1616== Background and concept of i18n/l10n support for Trac plugins ==
    17 It begun with adding Babel to Trac. Some plugin maintainers created their on translation module inside each plugin separately. This growing amount of code redundancy and possibility of error within imperfect copies of the translation module was certainly not a desirable situation. Trac core maintainers took responsibility with adding functions dedicated to i18n/l10n support for Trac plugins.
     17It begun with adding Babel to Trac. Some plugin maintainers created their own translation module inside each plugin separately. Growing amount of code redundancy and possibility of error within imperfect copies and variants of a translation module all that was certainly not a desirable situation. And Trac core maintainers took responsibility with adding functions dedicated to i18n/l10n support for Trac plugins.
    1818
    19 The evolution of this functions is documented in [comment:11:ticket:7497 ticket 7497]. The final implementation as documented there in [comment:12:ticket:7497 comment 12] was introduced to Trac trunk in [changeset: changeset r7705] and finally done with [changeset: changeset r7714].
     19The evolution of this functions has been documented in [comment:11:ticket:7497 ticket 7497]. The final implementation as mentioned there in [comment:12:ticket:7497 comment 12] was introduced to Trac trunk in [changeset: changeset r7705] and finally done with [changeset: changeset r7714].
    2020
    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 message texts 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 to Trac's main message catalog, if needed.
     21Now 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.
    2222
    23 Both searches take the locale setting as a second request argument. Valid settings are a combination of language and country code often extended by the character encoding used, i.e. ‘de_DE.UTF-8’. The encoding might of special relevance for languages that had an older encoding per default that was not sufficient for all common chars needed there. '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^
     23Both 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^
    2424
    2525First 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.
     
    137137As 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.
    138138
    139 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^
     139Now 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^
    140140
    141141=== Compile and use it ===
     
    162162^2^ http://en.wikipedia.org/w/index.php?title=Multilingualism&section=18 - Multilingualism in computing[[BR]]
    163163^3^ http://www.gnu.org/software/gettext/manual/gettext.html#Locale-Names - GNU 'gettext' utilities: Locale Names[[BR]]
    164 ^4^ http://www.gnu.org/software/gettext/manual/gettext.html#Editing - GNU 'gettext' utilities: Editing PO Files
     164^4^ http://www.gnu.org/software/gettext/manual/gettext.html#Editing - GNU 'gettext' utilities: Editing PO Files[[BR]]
     165^5^ http://techbase.kde.org/Localization/Concepts/PO_Odyssey - PO Odyssey in '!Localization/Concepts' section of KDE !TechBase