Mercurial > babel > mirror
comparison doc/display.txt @ 2:20896f1e91c6 trunk
Forgot to check in the doc directory.
author | cmlenz |
---|---|
date | Wed, 30 May 2007 07:37:26 +0000 |
parents | |
children | 1b9956f20649 |
comparison
equal
deleted
inserted
replaced
1:7870274479f5 | 2:20896f1e91c6 |
---|---|
1 .. -*- mode: rst; encoding: utf-8 -*- | |
2 | |
3 ==================== | |
4 Locale Display Names | |
5 ==================== | |
6 | |
7 .. contents:: Contents | |
8 :depth: 2 | |
9 .. sectnum:: | |
10 | |
11 | |
12 Introduction | |
13 ============ | |
14 | |
15 While `message catalogs <catalogs.html>`_ allow you to localize any messages | |
16 in your application, there are a number of strings that are used in many | |
17 applications for which translations are readily available. | |
18 | |
19 Imagine for example you have a list of countries that users can choose from, | |
20 and you'd like to display the names of those countries in the language the | |
21 user prefers. Instead of translating all those country names yourself in your | |
22 application, you can make use of the translations provided by the locale data | |
23 included with Babel, which is based on the `Common Locale Data Repository | |
24 (CLDR) <http://unicode.org/cldr/>`_ developed and maintained by the `Unicode | |
25 Consortium <http://unicode.org/>`_. | |
26 | |
27 | |
28 The ``Locale`` Class | |
29 ==================== | |
30 | |
31 You normally access such locale data through the `Locale`_ class provided | |
32 by Babel:: | |
33 | |
34 >>> from babel import Locale | |
35 >>> locale = Locale('en', 'US') | |
36 >>> locale.territories['US'] | |
37 u'United States' | |
38 >>> locale = Locale('es', 'MX') | |
39 >>> locale.territories['US'] | |
40 u'Estados Unidos' | |
41 | |
42 .. _`Locale`: api/babel.core.Locale-class.html | |
43 | |
44 In addition to country/territory names, the locale data also provides access to | |
45 names of languages, scripts, variants, time zones, and more. Some of the data | |
46 is closely related to `number and date formatting`_. | |
47 | |
48 Most of the corresponding ``Locale`` properties return dictionaries, where the | |
49 key is a code such as the ISO country and language codes. Consult the API | |
50 documentation for references to the relevant specifications. | |
51 | |
52 .. _`number and date formatting`: formatting.html |