Edgewall Software

Changes between Version 3 and Version 4 of GenshiRecipes/Localization


Ignore:
Timestamp:
Nov 9, 2006, 2:42:58 PM (17 years ago)
Author:
David Fraser <davidf@…>
Comment:

fixed syntax, added usage hints

Legend:

Unmodified
Added
Removed
Modified
  • GenshiRecipes/Localization

    v3 v4  
    308308            stream = filter_(iter(stream), ctxt)
    309309        return genshi.core.Stream(stream)
    310 }}
     310}}}
    311311
    312312This derived class then allows you to call the above localization function as a prefilter on templates. It uses the domain_name as a parameter (this corresponds to which PO/MO file to use for translation, but assumes you can construct or retrieve a translation object for the current user on the fly using a get_translation function (not described here):
    313 {{
     313{{{
    314314#!python
    315315class LocalizeMarkupTemplate(PrefilterMarkupTemplate):
     
    344344        """
    345345        return super(LocalizeMarkupTemplate, self).generate(prefilters + [self.localize_prefilter], *args, **kwargs)
    346 }}
     346}}}
     347
     348== Using the above code ==
     349
     350Basically the above code should really be integrated into Genshi, but if you want to use it first:
     351 * Place it in a module that you can use
     352 * Run the extraction code to get the .pot files containing your translatable text (and verify that they seem sensible)
     353 * Use a translation editor (something like [[http://translate.sourceforge.net/wiki/pootle|Pootle]] for online translation or poedit or kbabel for a local GUI
     354 * Use the LocalizationTemplate class rather than the standard MarkupTemplate class to parse your templates, and set up the required translation hooks for generation