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