annotate doc/display.txt @ 57:e7080996fc46

`new_catalog` now accepts another argument, `--domain`, which is used to build the output file path, which now is of the form `<output_dir>/<locale>/<domain>.po`, the correct form. Removed the language and coutry arguments of `write_po`, which instead accepts a `babel.core.Locale` object to retrieve the needed object.
author palgarvio
date Fri, 08 Jun 2007 10:37:47 +0000
parents cf94e70a77f3
children b12c6a776c44
rev   line source
4
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
1 .. -*- mode: rst; encoding: utf-8 -*-
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
2
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
3 ====================
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
4 Locale Display Names
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
5 ====================
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
6
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
7 .. contents:: Contents
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
8 :depth: 2
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
9 .. sectnum::
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
10
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
11
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
12 Introduction
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
13 ============
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
14
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
15 While `message catalogs <catalogs.html>`_ allow you to localize any messages
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
16 in your application, there are a number of strings that are used in many
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
17 applications for which translations are readily available.
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
18
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
19 Imagine for example you have a list of countries that users can choose from,
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
20 and you'd like to display the names of those countries in the language the
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
21 user prefers. Instead of translating all those country names yourself in your
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
22 application, you can make use of the translations provided by the locale data
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
23 included with Babel, which is based on the `Common Locale Data Repository
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
24 (CLDR) <http://unicode.org/cldr/>`_ developed and maintained by the `Unicode
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
25 Consortium <http://unicode.org/>`_.
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
26
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
27
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
28 The ``Locale`` Class
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
29 ====================
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
30
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
31 You normally access such locale data through the `Locale`_ class provided
42
cf94e70a77f3 Syntax highlighting for the docs.
cmlenz
parents: 27
diff changeset
32 by Babel:
cf94e70a77f3 Syntax highlighting for the docs.
cmlenz
parents: 27
diff changeset
33
cf94e70a77f3 Syntax highlighting for the docs.
cmlenz
parents: 27
diff changeset
34 .. code-block:: pycon
4
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
35
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
36 >>> from babel import Locale
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
37 >>> locale = Locale('en', 'US')
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
38 >>> locale.territories['US']
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
39 u'United States'
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
40 >>> locale = Locale('es', 'MX')
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
41 >>> locale.territories['US']
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
42 u'Estados Unidos'
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
43
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
44 .. _`Locale`: api/babel.core.Locale-class.html
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
45
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
46 In addition to country/territory names, the locale data also provides access to
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
47 names of languages, scripts, variants, time zones, and more. Some of the data
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
48 is closely related to `number and date formatting`_.
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
49
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
50 Most of the corresponding ``Locale`` properties return dictionaries, where the
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
51 key is a code such as the ISO country and language codes. Consult the API
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
52 documentation for references to the relevant specifications.
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
53
2cada72b40ae Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
54 .. _`number and date formatting`: formatting.html
27
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
55
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
56
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
57 Calender Display Names
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
58 ======================
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
59
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
60 The `Locale`_ class provides access to many locale display names related to
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
61 calendar display, such as the names of week days or months.
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
62
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
63 These display names are of course used for date formatting, but can also be
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
64 used, for example, to show a list of months to the user in their preferred
42
cf94e70a77f3 Syntax highlighting for the docs.
cmlenz
parents: 27
diff changeset
65 language:
cf94e70a77f3 Syntax highlighting for the docs.
cmlenz
parents: 27
diff changeset
66
cf94e70a77f3 Syntax highlighting for the docs.
cmlenz
parents: 27
diff changeset
67 .. code-block:: pycon
27
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
68
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
69 >>> locale = Locale('es')
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
70 >>> month_names = locale.months['format']['wide'].items()
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
71 >>> month_names.sort()
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
72 >>> for idx, name in month_names:
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
73 ... print name
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
74 enero
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
75 febrero
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
76 marzo
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
77 abril
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
78 mayo
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
79 junio
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
80 julio
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
81 agosto
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
82 septiembre
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
83 octubre
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
84 noviembre
8d4cd0856f69 Add doc section on calender display names.
cmlenz
parents: 4
diff changeset
85 diciembre
Copyright (C) 2012-2017 Edgewall Software