Edgewall Software

Changes between Version 4 and Version 5 of CookBook/PluginL10N


Ignore:
Timestamp:
May 8, 2010, 3:39:13 PM (14 years ago)
Author:
hasienda <hoff.st@…>
Comment:

added more content going towards desired amount of information

Legend:

Unmodified
Added
Removed
Modified
  • CookBook/PluginL10N

    v4 v5  
    1 = Adding l10n support to Trac plugins (Trac >= 0.12) =
     1= Adding i18n/l10n to Trac plugins (Trac >= 0.12) =
    22== Motivation ==
    33[FIXME: content needed, especially address the intended audience (plugin maintainers and developers in general) here - who should read on (and who shouldn't care at all)]
    44
    5 == i18n vs. l10n (again) ==
    6 [FIXME: is this needed?, well consider this is nice to the reader allowing to focus on i18n after coming from the greater scope of l10n, but be as short as possible when]
     5== i18n, l10n, ... help! ==
     6For professionals: please skip this, since there can't be any news for you.
    77
     8In short '''i18n''' stands for '''`i`'''`nternationalizatio`'''`n`''' (count 18 more chars between i and n) and is defined as software design for programs with translation support. '''`l`'''`ocalisatio`'''`n`''' that is abbreviated as '''l10n''' could be seen as a follow-up process providing data for one or more locales. It is taking care of feature differences between the original/default (that is English is most cases including Trac) and a given locale as well. Such features are i.e. sentence structure including punctuation and formatting of numbers, date/time strings, and currencies. Once you did some ground work at the source (i18n), most remaining is proper translation work (l10n) putting more or less effort in preserving the sense of the original while looking as native locale as possible.^1^
    89
    9 == Background and basics of i18n support ==
    10 The evolution of native support for Trac plugins 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]. Adding the needed i18n helper functions is as easy as adding
     10'''NLS''' (National Language Support or Native Language Support) is meant to be the sum of both. And there are more related terms that we could safely skip for now.^1, 2^
     11
     12== Background and basics of i18n/l10n support for plugin ==
     13The evolution of native i18n/l10n support for Trac plugins 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]. Adding the needed i18n/l10n helper functions is as easy as adding
    1114{{{
    1215from trac.util.translation import domain_functions
     
    1518    '_', 'tag_', 'N_', 'add_domain')
    1619}}}
    17 at the beginning of the main python script file of an existing or new plugin. To bring in the compiled message catalog for actually using the translated texts one will have to extend the `__init__` function of plugins main class too. For a fictional plugin Foo this would be done like this:
     20at the beginning of the main python script file of an existing or new plugin. To bring in the compiled message catalog for actually using the translated texts one will have to extend the `__init__` function of plugins main class too. For a fictional plugin 'foo' this would be done like this:
    1821{{{
    1922    def __init__(self):
     
    2427        add_domain(self.env.path, locale_dir)
    2528}}}
    26 assuming that folder `locale` will reside in `./foo/locale/` within the directory structure (of the Python egg). If you didn't have it, add a `import pkg_resources` to the beginning of the plugin script as well or the line `locale_dir = ...` will throw an '!ImportError'.
     29assuming that folder `locale` will reside in `./foo/locale/` within the directory structure (of the Python egg). If you didn't have it in the source by now, add a `import pkg_resources` to the beginning of the plugin script as well or the line `locale_dir = ...` will throw an '!ImportError'.
    2730
    2831[FIXME: explain what _version and ui are used for or leave them out, if unnecessary here]
     
    102105
    103106=== Advanced stuff ===
    104 ==== Finally l10n ====
     107==== Finally 'true' l10n ====
    105108
    106109== Related resources ==
     110
     111^1^ http://en.wikipedia.org/wiki/Internationalization_and_localization - Internationalization and localization[[BR]]
     112^2^ http://en.wikipedia.org/w/index.php?title=Multilingualism&section=18 - Multilingualism in computing