cmlenz@4: .. -*- mode: rst; encoding: utf-8 -*- cmlenz@4: cmlenz@4: ==================== cmlenz@4: Locale Display Names cmlenz@4: ==================== cmlenz@4: cmlenz@4: .. contents:: Contents cmlenz@4: :depth: 2 cmlenz@4: .. sectnum:: cmlenz@4: cmlenz@4: cmlenz@4: Introduction cmlenz@4: ============ cmlenz@4: cmlenz@4: While `message catalogs `_ allow you to localize any messages cmlenz@4: in your application, there are a number of strings that are used in many cmlenz@4: applications for which translations are readily available. cmlenz@4: cmlenz@4: Imagine for example you have a list of countries that users can choose from, cmlenz@4: and you'd like to display the names of those countries in the language the cmlenz@4: user prefers. Instead of translating all those country names yourself in your cmlenz@4: application, you can make use of the translations provided by the locale data cmlenz@4: included with Babel, which is based on the `Common Locale Data Repository cmlenz@4: (CLDR) `_ developed and maintained by the `Unicode cmlenz@4: Consortium `_. cmlenz@4: cmlenz@4: cmlenz@4: The ``Locale`` Class cmlenz@4: ==================== cmlenz@4: cmlenz@4: You normally access such locale data through the `Locale`_ class provided cmlenz@4: by Babel:: cmlenz@4: cmlenz@4: >>> from babel import Locale cmlenz@4: >>> locale = Locale('en', 'US') cmlenz@4: >>> locale.territories['US'] cmlenz@4: u'United States' cmlenz@4: >>> locale = Locale('es', 'MX') cmlenz@4: >>> locale.territories['US'] cmlenz@4: u'Estados Unidos' cmlenz@4: cmlenz@4: .. _`Locale`: api/babel.core.Locale-class.html cmlenz@4: cmlenz@4: In addition to country/territory names, the locale data also provides access to cmlenz@4: names of languages, scripts, variants, time zones, and more. Some of the data cmlenz@4: is closely related to `number and date formatting`_. cmlenz@4: cmlenz@4: Most of the corresponding ``Locale`` properties return dictionaries, where the cmlenz@4: key is a code such as the ISO country and language codes. Consult the API cmlenz@4: documentation for references to the relevant specifications. cmlenz@4: cmlenz@4: .. _`number and date formatting`: formatting.html