115
|
1 .. -*- mode: rst; encoding: utf-8 -*-
|
|
2
|
|
3 ============
|
|
4 Introduction
|
|
5 ============
|
|
6
|
|
7 The functionality Babel provides for internationalization (I18n) and
|
|
8 localization (L10N) can be separated into two different aspects:
|
|
9
|
|
10 * tools to build and work with ``gettext`` message catalogs, and
|
|
11 * a Python interface to the CLDR (Common Locale Data Repository), providing
|
|
12 access to various locale display names, localized number and date
|
|
13 formatting, etc.
|
|
14
|
|
15 .. contents:: Contents
|
|
16 :depth: 2
|
|
17 .. sectnum::
|
|
18
|
|
19
|
|
20 Message Catalogs
|
|
21 ================
|
|
22
|
|
23 While the Python standard library includes a
|
|
24 `gettext <http://docs.python.org/lib/module-gettext.html>`_ module that enables
|
|
25 applications to use message catalogs, it requires developers to build these
|
|
26 catalogs using GNU tools such as ``xgettext``, ``msgmerge``, and ``msgfmt``.
|
|
27 And while ``xgettext`` does have support for extracting messages from Python
|
|
28 files, it does not know how to deal with other kinds of files commonly found
|
|
29 in Python web-applications, such as templates, nor does it provide an easy
|
|
30 extensibility mechanism to add such support.
|
|
31
|
|
32 Babel addresses this by providing a framework where various extraction methods
|
|
33 can be plugged in to a larger message extraction framework, and also removes
|
|
34 the dependency on the GNU ``gettext`` tools for common tasks, as these aren't
|
|
35 necessarily available on all platforms. See `Working with Message Catalogs`_
|
|
36 for details on this aspect of Babel.
|
|
37
|
124
|
38 .. _`Working with Message Catalogs`: messages.html
|
115
|
39
|
|
40
|
|
41 Locale Data
|
|
42 ===========
|
|
43
|
|
44 Furthermore, while the Python standard library does include support for basic
|
|
45 localization with respect to the formatting of numbers and dates (the
|
|
46 `locale <http://docs.python.org/lib/module-locale.html>`_ module, among others),
|
|
47 this support is based on the assumption that there will be only one specific
|
|
48 locale used per process (at least simultaneously.) Also, it doesn't provide
|
|
49 access to other kinds of locale data, such as the localized names of countries,
|
|
50 languages, or time-zones, which are frequently needed in web-based applications.
|
|
51
|
|
52 For these requirements, Babel includes data extracted from the `Common Locale
|
|
53 Data Repository (CLDR) <http://unicode.org/cldr/>`_, and provides a number of
|
|
54 convenient methods for accessing and using this data. See `Locale Display
|
133
|
55 Names`_, `Date Formatting`_, and `Number Formatting`_ for more information on
|
|
56 this aspect of Babel.
|
115
|
57
|
|
58
|
|
59 .. _`Locale Display Names`: display.html
|
124
|
60 .. _`Date Formatting`: dates.html
|
|
61 .. _`Number Formatting`: numbers.html
|