Mercurial > babel > old > babel-test
view doc/display.txt @ 222:7945923e5fa6
o extract_python fixes:
- now returns None for non-string arguments
- no longer extracts strings from nested function calls
refs #38
- use the correct starting line number in multi-line gettext function
calls
- avoids falsely identifying string keyword arg defaults from
function definition names that match a keyword, e.g.:
def gettext(foo='bar')
- avoid capturing translator comments embedded within a gettext
function call
- default the file encoding to iso-8859-1 instead of ascii when
missing a magic encoding comment, to emulate pre Python 2.5
behavior. Python warns about 'non-ascii' chars when there is no magic
encoding comment, but < 2.5 actually treats them as iso-8859-1 for
backwards compat (PEP 263). >= 2.5 treats them as strict ascii
o extract fixes:
- filter out messages that don't contain strings where the keyword
specification calls for
fixes #39
- filter out empty string messages and emit a warning about them,
like xgettext
author | pjenvey |
---|---|
date | Wed, 18 Jul 2007 00:29:04 +0000 |
parents | bf1bcdf19111 |
children |
line wrap: on
line source
.. -*- mode: rst; encoding: utf-8 -*- ==================== Locale Display Names ==================== .. contents:: Contents :depth: 2 .. sectnum:: Introduction ============ While `message catalogs <messages.html>`_ allow you to localize any messages in your application, there are a number of strings that are used in many applications for which translations are readily available. Imagine for example you have a list of countries that users can choose from, and you'd like to display the names of those countries in the language the user prefers. Instead of translating all those country names yourself in your application, you can make use of the translations provided by the locale data included with Babel, which is based on the `Common Locale Data Repository (CLDR) <http://unicode.org/cldr/>`_ developed and maintained by the `Unicode Consortium <http://unicode.org/>`_. The ``Locale`` Class ==================== You normally access such locale data through the `Locale`_ class provided by Babel: .. code-block:: pycon >>> from babel import Locale >>> locale = Locale('en', 'US') >>> locale.territories['US'] u'United States' >>> locale = Locale('es', 'MX') >>> locale.territories['US'] u'Estados Unidos' .. _`Locale`: api/babel.core.Locale-class.html In addition to country/territory names, the locale data also provides access to names of languages, scripts, variants, time zones, and more. Some of the data is closely related to number and date formatting. Most of the corresponding ``Locale`` properties return dictionaries, where the key is a code such as the ISO country and language codes. Consult the API documentation for references to the relevant specifications. Calender Display Names ====================== The `Locale`_ class provides access to many locale display names related to calendar display, such as the names of week days or months. These display names are of course used for date formatting, but can also be used, for example, to show a list of months to the user in their preferred language: .. code-block:: pycon >>> locale = Locale('es') >>> month_names = locale.months['format']['wide'].items() >>> month_names.sort() >>> for idx, name in month_names: ... print name enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre