def test_default_locale(os_environ): for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LC_MESSAGES']: os_environ[name] = '' os_environ['LANG'] = 'fr_FR.UTF-8' assert default_locale('LC_MESSAGES') == 'fr_FR' os_environ['LC_MESSAGES'] = 'POSIX' assert default_locale('LC_MESSAGES') == 'en_US_POSIX' for value in ['C', 'C.UTF-8', 'POSIX']: os_environ['LANGUAGE'] = value assert default_locale() == 'en_US_POSIX'
:copyright: (c) 2013 by the Babel Team. :license: BSD, see LICENSE for more details. """ # TODO: # Padding and rounding increments in pattern: # - http://www.unicode.org/reports/tr35/ (Appendix G.6) from decimal import Decimal, InvalidOperation import math import re from datetime import date as date_, datetime as datetime_ from py3babel.core import default_locale, Locale, get_global from py3babel._compat import range_type LC_NUMERIC = default_locale('LC_NUMERIC') def get_currency_name(currency, count=None, locale=LC_NUMERIC): """Return the name used by the locale for the specified currency. >>> get_currency_name('USD', locale='en_US') u'US Dollar' .. versionadded:: 0.9.4 :param currency: the currency code :param count: the optional count. If provided the currency name will be pluralized to that number if possible. :param locale: the `Locale` object or locale identifier """
~~~~~~~~~~~~~~~~~~~~~~ Plural form definitions. :copyright: (c) 2013 by the Babel Team. :license: BSD, see LICENSE for more details. """ from py3babel.core import default_locale, Locale from operator import itemgetter # XXX: remove this file, duplication with babel.plural LC_CTYPE = default_locale('LC_CTYPE') PLURALS = { # Afar # 'aa': (), # Abkhazian # 'ab': (), # Avestan # 'ae': (), # Afrikaans - From Pootle's PO's 'af': (2, '(n != 1)'), # Akan # 'ak': (), # Amharic # 'am': (),
def test_ignore_invalid_locales_in_lc_ctype(os_environ): # This is a regression test specifically for a bad LC_CTYPE setting on # MacOS X 10.6 (#200) os_environ['LC_CTYPE'] = 'UTF-8' # must not throw an exception default_locale('LC_CTYPE')
""" from __future__ import division import re import pytz as _pytz from datetime import date, datetime, time, timedelta from bisect import bisect_right from py3babel.core import default_locale, get_global, Locale from py3babel.util import UTC, LOCALTZ from py3babel._compat import string_types, integer_types, number_types LC_TIME = default_locale("LC_TIME") # Aliases for use in scopes where the modules are shadowed by local variables date_ = date datetime_ = datetime time_ = time def get_timezone(zone=None): """Looks up a timezone by name and returns it. The timezone object returned comes from ``pytz`` and corresponds to the `tzinfo` interface and can be used with all of the functions of Babel that operate with dates. If a timezone is not known a :exc:`LookupError` is raised. If `zone` is ``None`` a local zone object is returned.