Home | Trees | Indices | Help |
|
---|
|
object --+ | Locale
Representation of a specific locale.
>>> locale = 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. >>> locale = Locale('en', 'US') >>> locale.language 'en' >>> locale.territory 'US'
|
Return the system default locale for the specified category. >>> for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE']: ... os.environ[name] = '' >>> os.environ['LANG'] = 'fr_FR.UTF-8' >>> Locale.default('LC_MESSAGES') <Locale "fr_FR">
See Also: default_locale |
Find the best match between available and requested locale strings. >>> Locale.negotiate(['de_DE', 'en_US'], ['de_DE', 'de_AT']) <Locale "de_DE"> >>> Locale.negotiate(['de_DE', 'en_US'], ['en', 'de']) <Locale "de"> >>> Locale.negotiate(['de_DE', 'de'], ['en_US']) You can specify the character used in the locale identifiers to separate the differnet components. This separator is applied to both lists. Also, case is ignored in the comparison: >>> Locale.negotiate(['de-DE', 'de'], ['en-us', 'de-de'], sep='-') <Locale "de_DE">
See Also: negotiate_locale |
Create a Locale instance for the given locale identifier. >>> l = Locale.parse('de-DE', sep='-') >>> l.display_name u'Deutsch (Deutschland)' If the >>> Locale.parse(l) <Locale "de_DE">
See Also: parse_locale |
|
|
Return the display name of the locale using the given locale. The display name will include the language, territory, script, and variant, if those are specified. >>> Locale('zh', 'CN', script='Hans').get_display_name('en') u'Chinese (Simplified Han, China)'
|
Property Details |
display_nameThe localized display name of the locale. >>> Locale('en').display_name u'English' >>> Locale('en', 'US').display_name u'English (United States)' >>> Locale('sv').display_name u'svenska'
|
english_nameThe english display name of the locale. >>> Locale('de').english_name u'German' >>> Locale('de', 'DE').english_name u'German (Germany)'
|
languagesMapping of language codes to translated language names. >>> Locale('de', 'DE').languages['ja'] u'Japanisch'
See Also: ISO 639 |
scriptsMapping of script codes to translated script names. >>> Locale('en', 'US').scripts['Hira'] u'Hiragana'
See Also: ISO 15924 |
territoriesMapping of script codes to translated script names. >>> Locale('es', 'CO').territories['DE'] u'Alemania'
See Also: ISO 3166 |
variantsMapping of script codes to translated script names. >>> Locale('de', 'DE').variants['1901'] u'Alte deutsche Rechtschreibung'
|
currenciesMapping of currency codes to translated currency names. >>> Locale('en').currencies['COP'] u'Colombian Peso' >>> Locale('de', 'DE').currencies['COP'] u'Kolumbianischer Peso'
|
currency_symbolsMapping of currency codes to symbols. >>> Locale('en', 'US').currency_symbols['USD'] u'$' >>> Locale('es', 'CO').currency_symbols['USD'] u'US$'
|
number_symbolsSymbols used in number formatting. >>> Locale('fr', 'FR').number_symbols['decimal'] u','
|
decimal_formatsLocale patterns for decimal number formatting. >>> Locale('en', 'US').decimal_formats[None] <NumberPattern u'#,##0.###'>
|
currency_formatsLocale patterns for currency number formatting. >>> print Locale('en', 'US').currency_formats[None] <NumberPattern u'\xa4#,##0.00'>
|
percent_formatsLocale patterns for percent number formatting. >>> Locale('en', 'US').percent_formats[None] <NumberPattern u'#,##0%'>
|
scientific_formatsLocale patterns for scientific number formatting. >>> Locale('en', 'US').scientific_formats[None] <NumberPattern u'#E0'>
|
periodsLocale display names for day periods (AM/PM). >>> Locale('en', 'US').periods['am'] u'AM'
|
daysLocale display names for weekdays. >>> Locale('de', 'DE').days['format']['wide'][3] u'Donnerstag'
|
monthsLocale display names for months. >>> Locale('de', 'DE').months['format']['wide'][10] u'Oktober'
|
quartersLocale display names for quarters. >>> Locale('de', 'DE').quarters['format']['wide'][1] u'1. Quartal'
|
erasLocale display names for eras. >>> Locale('en', 'US').eras['wide'][1] u'Anno Domini' >>> Locale('en', 'US').eras['abbreviated'][0] u'BC'
|
time_zonesLocale display names for time zones. >>> Locale('en', 'US').time_zones['Europe/London']['long']['daylight'] u'British Summer Time' >>> Locale('en', 'US').time_zones['America/St_Johns']['city'] u"St. John's"
|
meta_zonesLocale display names for meta time zones. Meta time zones are basically groups of different Olson time zones that have the same GMT offset and daylight savings time. >>> Locale('en', 'US').meta_zones['Europe_Central']['long']['daylight'] u'Central European Summer Time'
Since: version 0.9 |
zone_formatsPatterns related to the formatting of time zones. >>> Locale('en', 'US').zone_formats['fallback'] u'%(1)s (%(0)s)' >>> Locale('pt', 'BR').zone_formats['region'] u'Hor\xe1rio %s'
Since: version 0.9 |
first_week_dayThe first day of a week, with 0 being Monday. >>> Locale('de', 'DE').first_week_day 0 >>> Locale('en', 'US').first_week_day 6
|
weekend_startThe day the weekend starts, with 0 being Monday. >>> Locale('de', 'DE').weekend_start 5
|
weekend_endThe day the weekend ends, with 0 being Monday. >>> Locale('de', 'DE').weekend_end 6
|
min_week_daysThe minimum number of days in a week so that the week is counted as the first week of a year or month. >>> Locale('de', 'DE').min_week_days 4
|
date_formatsLocale patterns for date formatting. >>> Locale('en', 'US').date_formats['short'] <DateTimePattern u'M/d/yy'> >>> Locale('fr', 'FR').date_formats['long'] <DateTimePattern u'd MMMM yyyy'>
|
time_formatsLocale patterns for time formatting. >>> Locale('en', 'US').time_formats['short'] <DateTimePattern u'h:mm a'> >>> Locale('fr', 'FR').time_formats['long'] <DateTimePattern u'HH:mm:ss z'>
|
datetime_formatsLocale patterns for datetime formatting. >>> Locale('en').datetime_formats[None] u'{1} {0}' >>> Locale('th').datetime_formats[None] u'{1}, {0}'
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Aug 25 14:35:53 2008 | http://epydoc.sourceforge.net |