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
 
__init__(self, language, territory=None, script=None, variant=None)
Initialize the locale object from the given identifier components.
 
__eq__(self, other)
 
__ne__(self, other)
 
__repr__(self)
repr(x)
 
__str__(self)
str(x)
 
get_display_name(self, locale=None)
Return the display name of the locale using the given locale.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods
Locale
default(cls, category=None, aliases={'ar': 'ar_SY', 'bg': 'bg_BG', 'bs': 'bs_BA', 'ca': 'ca_ES', '...)
Return the system default locale for the specified category.
Locale
negotiate(cls, preferred, available, sep='_', aliases={'ar': 'ar_SY', 'bg': 'bg_BG', 'bs': 'bs_BA', 'ca': 'ca_ES', '...)
Find the best match between available and requested locale strings.
Locale
parse(cls, identifier, sep='_')
Create a Locale instance for the given locale identifier.
Properties
unicode display_name
The localized display name of the locale.
unicode english_name
The english display name of the locale.

Inherited from object: __class__

    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

__init__(self, language, territory=None, script=None, variant=None)
(Constructor)

 

Initialize the locale object from the given identifier components.

>>> l