ocale = Locale('en', 'US') >>> repr(locale) '<Locale "en_US">' >>> locale.display_name u'English (United States)'
A Locale object can also be instantiated from a raw locale string:
>>> locale = Locale.parse('en-US', sep='-') >>> repr(locale) '<Locale "en_US">'
Locale objects provide access to a collection of locale data, such as territory and language names, number and date format patterns, and more:
>>> locale.number_symbols['decimal'] u'.'
If a locale is requested for which no locale data is available, an UnknownLocaleError is raised:
>>> Locale.parse('en_DE') Traceback (most recent call last): ... UnknownLocaleError: unknown locale 'en_DE'
See Also: IETF RFC 3066
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
Class Methods | |||
Locale |
|
||
Locale |
|
||
Locale |
|
Properties | |
unicode
|
display_name The localized display name of the locale. |
unicode
|
english_name The english display name of the locale. |
Inherited from |
|
General Locale Display Names | |
---|---|
dict
|
languages Mapping of language codes to translated language names. |
dict
|
scripts Mapping of script codes to translated script names. |
dict
|
territories Mapping of script codes to translated script names. |
dict
|
variants Mapping of script codes to translated script names. |
Number Formatting | |
dict
|
currencies Mapping of currency codes to translated currency names. |
dict
|
currency_symbols Mapping of currency codes to symbols. |
dict
|
number_symbols Symbols used in number formatting. |
dict
|
decimal_formats Locale patterns for decimal number formatting. |
dict
|
currency_formats Locale patterns for currency number formatting. |
dict
|
percent_formats Locale patterns for percent number formatting. |
dict
|
scientific_formats Locale patterns for scientific number formatting. |
Calendar Information and Date Formatting | |
dict
|
periods Locale display names for day periods (AM/PM). |
dict
|
days Locale display names for weekdays. |
dict
|
months Locale display names for months. |
dict
|
quarters Locale display names for quarters. |
dict
|
eras Locale display names for eras. |
dict
|
time_zones Locale display names for time zones. |
dict
|
meta_zones Locale display names for meta time zones. |
dict
|
zone_formats Patterns related to the formatting of time zones. |
int
|
first_week_day The first day of a week, with 0 being Monday. |
int
|
weekend_start The day the weekend starts, with 0 being Monday. |
int
|
weekend_end The day the weekend ends, with 0 being Monday. |
int
|
min_week_days The minimum number of days in a week so that the week is counted as the first week of a year or month. |
dict
|
date_formats Locale patterns for date formatting. |
dict
|
time_formats Locale patterns for time formatting. |
dict
|
datetime_formats Locale patterns for datetime formatting. |
Method Details |
Initialize the locale object from the given identifier components.
>>> l |