Package turbogears :: Package i18n :: Module format
[hide private]

Module format

source code

Localized formatting functions. These functions extract localization data from config files located in the data/directory.

Functions [hide private]
 
is_locale_format(locale) source code
 
get_locale_module(locale) source code
 
get(locale, name, default=None) source code
 
get_countries(locale=None)
Returns list of tuples, consisting of international country code and localized name, e.g.
source code
 
get_country(key, locale=None)
Returns localized name of country based on international country code
source code
 
get_languages(locale=None)
Returns list of tuples, with language code and localized name, e.g.
source code
 
get_language(key, locale=None)
Returns localized name of language based on language code
source code
 
get_month_names(locale=None)
Returns list of full month names, starting with January
source code
 
get_abbr_month_names(locale=None)
Returns list of abbreviated month names, starting with Jan
source code
 
get_weekday_names(locale=None)
Returns list of full weekday names
source code
 
get_abbr_weekday_names(locale=None)
Returns list of abbreviated weekday names
source code
 
get_decimal_format(locale=None) source code
 
get_group_format(locale=None) source code
 
format_number(value, locale=None)
Returns number formatted with grouping for thousands, e.g.
source code
 
format_decimal(value, num_places, locale=None)
Returns number formatted with grouping for thousands and correct notation, e.g.
source code
 
format_currency(value, locale=None)
Returns formatted currency value
source code
 
parse_number(value, locale=None)
Takes localized number string and returns a long integer (or throws ValueError if bad format)
source code
 
parse_decimal(value, locale=None)
Takes localized decimal string and returns a float (or throws ValueError if bad format)
source code
 
get_date_format(format, locale=None) source code
 
format_date(dt, format='medium', locale=None, time_format='', date_format='')
Returns formatted date value.
source code
Function Details [hide private]

get_countries(locale=None)

source code 

Returns list of tuples, consisting of international country code and localized name, e.g. ('AU', 'Australia')

get_languages(locale=None)

source code 

Returns list of tuples, with language code and localized name, e.g. ('en', 'English')

format_number(value, locale=None)

source code 

Returns number formatted with grouping for thousands, e.g. 5000000>5,000,000

format_decimal(value, num_places, locale=None)

source code 

Returns number formatted with grouping for thousands and correct notation, e.g. 5000000.898>5,000,000.898

format_date(dt, format='medium', locale=None, time_format='', date_format='')

source code 

Returns formatted date value.

format can be "full", "long", "medium" or "short". To have complete control over formatting, use time_format and date_format parameters.

Parameters:
  • dt (datetime.datetime) - datetime
  • format (string) - format("full", "long", "medium", "short")
  • locale (XXX) - XXX
  • time_format (string) - standard time formatting string, e.g. %H:%M
  • time_format (string) - date formatting template string. Template variables include standard date formatting string like %d or %Y plus a few locale-specific names: %%(abbrmonthname)s, %%(dayname)s, %%(abbrmonthname)s and %%(monthname)s.