annotate doc/support.txt @ 556:454fe7a76877 tip

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