annotate 0.9.x/doc/support.txt @ 557:3c590f6f5dfa stable tip

Merged revisions 607 via svnmerge from http://svn.edgewall.org/repos/babel/trunk ........ r607 | pjenvey | 2011-04-24 21:41:23 -0700 (Sun, 24 Apr 2011) | 3 lines keywords only support space separated values, not comma separated thanks agronholm ........
author pjenvey
date Mon, 25 Apr 2011 04:44:13 +0000
parents 5b7d3f9f7d74
children
rev   line source
263
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
1 .. -*- mode: rst; encoding: utf-8 -*-
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
2
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
3 =============================
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
4 Support Classes and Functions
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
5 =============================
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
6
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
7 .. contents:: Contents
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
8 :depth: 2
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
9 .. sectnum::
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
10
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
11
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
12 The ``babel.support`` modules contains a number of classes and functions that
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
13 can help with integrating Babel, and internationalization in general, into your
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
14 application or framework. The code in this module is not used by Babel itself,
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
15 but instead is provided to address common requirements of applications that
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
16 should handle internationalization.
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
17
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
18
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
19 ---------------
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
20 Lazy Evaluation
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
21 ---------------
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
22
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
23 One such requirement is lazy evaluation of translations. Many web-based
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
24 applications define some localizable message at the module level, or in general
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
25 at some level where the locale of the remote user is not yet known. For such
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
26 cases, web frameworks generally provide a "lazy" variant of the ``gettext``
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
27 functions, which basically translates the message not when the ``gettext``
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
28 function is invoked, but when the string is accessed in some manner.
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
29
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
30
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
31 ---------------------------
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
32 Extended Translations Class
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
33 ---------------------------
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
34
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
35 Many web-based applications are composed of a variety of different components
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
36 (possibly using some kind of plugin system), and some of those components may
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
37 provide their own message catalogs that need to be integrated into the larger
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
38 system.
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
39
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
40 To support this usage pattern, Babel provides a ``Translations`` class that is
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
41 derived from the ``GNUTranslations`` class in the ``gettext`` module. This
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
42 class adds a ``merge()`` method that takes another ``Translations`` instance,
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
43 and merges the content of the latter into the main catalog:
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
44
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
45 .. code-block:: python
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
46
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
47 translations = Translations.load('main')
5b7d3f9f7d74 Create branch for 0.9.x maintenance.
cmlenz
parents:
diff changeset
48 translations.merge(Translations.load('plugin1'))
Copyright (C) 2012-2017 Edgewall Software