comparison doc/support.txt @ 76:c23bc1c50297

Extended the docs a bit.
author cmlenz
date Fri, 08 Jun 2007 21:40:59 +0000
parents
children
comparison
equal deleted inserted replaced
75:98b27ffe1c3a 76:c23bc1c50297
1 .. -*- mode: rst; encoding: utf-8 -*-
2
3 =============================
4 Support Classes and Functions
5 =============================
6
7 .. contents:: Contents
8 :depth: 2
9 .. sectnum::
10
11
12 The ``babel.support`` modules contains a number of classes and functions that
13 can help with integrating Babel, and internationalization in general, into your
14 application or framework. The code in this module is not used by Babel itself,
15 but instead is provided to address common requirements of applications that
16 should handle internationalization.
17
18
19 ---------------
20 Lazy Evaluation
21 ---------------
22
23 One such requirement is lazy evaluation of translations. Many web-based
24 applications define some localizable message at the module level, or in general
25 at some level where the locale of the remote user is not yet known. For such
26 cases, web frameworks generally provide a "lazy" variant of the ``gettext``
27 functions, which basically translates the message not when the ``gettext``
28 function is invoked, but when the string is accessed in some manner.
29
30
31 ---------------------------
32 Extended Translations Class
33 ---------------------------
34
35 Many web-based applications are composed of a variety of different components
36 (possibly using some kind of plugin system), and some of those components may
37 provide their own message catalogs that need to be integrated into the larger
38 system.
39
40 To support this usage pattern, Babel provides a ``Translations`` class that is
41 derived from the ``GNUTranslations`` class in the ``gettext`` module. This
42 class adds a ``merge()`` method that takes another ``Translations`` instance,
43 and merges the content of the latter into the main catalog:
44
45 .. code-block:: python
46
47 translations = Translations.load('main')
48 translations.merge(Translations.load('plugin1'))
Copyright (C) 2012-2017 Edgewall Software