Changes between Version 3 and Version 4 of GenshiRecipes/Localization
- Timestamp:
- Nov 9, 2006, 2:42:58 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GenshiRecipes/Localization
v3 v4 308 308 stream = filter_(iter(stream), ctxt) 309 309 return genshi.core.Stream(stream) 310 }} 310 }}} 311 311 312 312 This 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 {{{ 314 314 #!python 315 315 class LocalizeMarkupTemplate(PrefilterMarkupTemplate): … … 344 344 """ 345 345 return super(LocalizeMarkupTemplate, self).generate(prefilters + [self.localize_prefilter], *args, **kwargs) 346 }} 346 }}} 347 348 == Using the above code == 349 350 Basically 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