예제 #1
0
 def test_unknown(self):
     """
     Test that when the current locale is not supported by Babel, it
     defaults to en-US.
     """
     activate('fy')
     eq_(Locale('en', 'US'), current_locale())
예제 #2
0
def babel_date(date, format='long'):
    """
    Format a date properly for the current locale. Format can be one of
    'short', 'medium', 'long', or 'full'.
    """
    locale = current_locale()
    return format_date(date, format, locale)
예제 #3
0
def month_year_picker(request):
    """Adds localized date info for the month-year picker widget."""
    locale = current_locale()

    return {
        'mypicker_months_short': get_month_names('abbreviated', locale=locale),
        'mypicker_months_long': get_month_names('wide', locale=locale)
    }
예제 #4
0
 def test_basic(self):
     """Test that the currently locale is correctly returned."""
     activate('fr')
     eq_(Locale('fr'), current_locale())
예제 #5
0
def babel_number(number):
    """Format a number properly for the current locale."""
    locale = current_locale()
    return format_number(number, locale)