本文整理汇总了Python中babel.core.default_locale函数的典型用法代码示例。如果您正苦于以下问题:Python default_locale函数的具体用法?Python default_locale怎么用?Python default_locale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default_locale函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_default_locale
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"
开发者ID:nickretallack,项目名称:babel,代码行数:8,代码来源:test_core.py
示例2: test_default_locale
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'
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:8,代码来源:test_core.py
示例3: get_locale
def get_locale(locale=None, default='en_US_POSIX'):
"""Return default locale to use if one is not provided."""
if not locale:
locale = default_locale('LC_TIME')
if not locale:
locale = default
return locale
开发者ID:dgilland,项目名称:zulu,代码行数:9,代码来源:delta.py
示例4: default_locale
"""
from __future__ import division
import re
from pytz.gae import pytz as _pytz
from datetime import date, datetime, time, timedelta
from bisect import bisect_right
from babel.core import default_locale, get_global, Locale
from babel.util import UTC, LOCALTZ
from babel._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.
开发者ID:eavae,项目名称:mlang,代码行数:30,代码来源:dates.py
示例5: default_locale
* ``LANG``
: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)
import re
from datetime import date as date_, datetime as datetime_
from babel.core import default_locale, Locale, get_global
from babel._compat import Decimal, InvalidOperation, ROUND_HALF_EVEN
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
"""
开发者ID:marcosptf,项目名称:fedora,代码行数:31,代码来源:numbers.py
示例6: test_ignore_invalid_locales_in_lc_ctype
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')
开发者ID:dstanek,项目名称:babel,代码行数:6,代码来源:test_core.py
示例7: default_locale
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://babel.edgewall.org/log/.
"""Plural form definitions."""
from babel.core import default_locale, Locale
from operator import itemgetter
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': (),
开发者ID:AgentJay,项目名称:webapp-improved,代码行数:31,代码来源:plurals.py
示例8: default_locale
+-------------------------+------------------------------------------+-----------------------------------------+
| printable_zero_line_char| Printable character for zero line units | u'|' |
+-------------------------+------------------------------------------+-----------------------------------------+
| tick_char | Character to render for axis ticks | u'+' |
+-------------------------+------------------------------------------+-----------------------------------------+
| ellipsis_chars | Characters to render for ellipsis | u'...' |
+-------------------------+------------------------------------------+-----------------------------------------+
"""
from babel.core import default_locale
_options = {
#: Default locale for number formatting
'default_locale': default_locale('LC_NUMERIC') or 'en_US',
#: Character to render for horizontal lines
'horizontal_line_char': u'-',
#: Character to render for vertical lines
'vertical_line_char': u'|',
#: Character to render for bar chart units
'bar_char': u'░',
#: Printable character to render for bar chart units
'printable_bar_char': u':',
#: Character to render for zero line units
'zero_line_char': u'▓',
#: Printable character to render for zero line units
'printable_zero_line_char': u'|',
#: Character to render for axis ticks
'tick_char': u'+',
#: Characters to render for ellipsis
开发者ID:nbedi,项目名称:agate,代码行数:31,代码来源:config.py
示例9: default_locale
PRINTABLE_BAR_MARK = u':'
#: Character to render for zero line units
ZERO_MARK = u'▓'
#: Printable character to render for zero line units
PRINTABLE_ZERO_MARK = u'|'
#: Character to render for axis ticks
TICK_MARK = u'+'
#: Characters to render for ellipsis
ELLIPSIS = u'...'
#: Default locale for number formatting
LC_NUMERIC = default_locale('LC_NUMERIC') or 'en_US'
#: Sentinal for use when `None` is an valid argument value
default = object()
def memoize(func):
"""
Dead-simple memoize decorator for instance methods that take no arguments.
This is especially useful since so many of our classes are immutable.
"""
memo = None
@wraps(func)
def wrapper(self):
开发者ID:01-,项目名称:agate,代码行数:31,代码来源:utils.py
示例10: default_locale
from babel.core import default_locale, Locale
from babel.util import rsplit
__all__ = [
"format_number",
"format_decimal",
"format_currency",
"format_percent",
"format_scientific",
"parse_number",
"parse_decimal",
"NumberFormatError",
]
__docformat__ = "restructuredtext en"
LC_NUMERIC = default_locale("LC_NUMERIC")
def get_currency_name(currency, locale=LC_NUMERIC):
"""Return the name used by the locale for the specified currency.
>>> get_currency_name('USD', 'en_US')
u'US Dollar'
:param currency: the currency code
:param locale: the `Locale` object or locale identifier
:return: the currency symbol
:rtype: `unicode`
:since: version 0.9.4
"""
return Locale.parse(locale).currencies.get(currency, currency)
开发者ID:2013Commons,项目名称:HUE-SHARK,代码行数:31,代码来源:numbers.py
示例11: default_locale
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://babel.edgewall.org/wiki/License.
#
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://babel.edgewall.org/log/.
"""Plural form definitions."""
from babel.core import default_locale, Locale
from babel.util import itemgetter
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': (),
开发者ID:2013Commons,项目名称:HUE-SHARK,代码行数:31,代码来源:plurals.py
示例12: default_locale
Locale dependent formatting of lists.
The default locale for the functions in this module is determined by the
following environment variables, in that order:
* ``LC_ALL``, and
* ``LANG``
:copyright: (c) 2015-2019 by the Babel Team.
:license: BSD, see LICENSE for more details.
"""
from babel.core import Locale, default_locale
DEFAULT_LOCALE = default_locale()
def format_list(lst, style='standard', locale=DEFAULT_LOCALE):
"""
Format the items in `lst` as a list.
>>> format_list(['apples', 'oranges', 'pears'], locale='en')
u'apples, oranges, and pears'
>>> format_list(['apples', 'oranges', 'pears'], locale='zh')
u'apples\u3001oranges\u548cpears'
>>> format_list(['omena', 'peruna', 'aplari'], style='or', locale='fi')
u'omena, peruna tai aplari'
These styles are defined, but not all are necessarily available in all locales.
The following text is verbatim from the Unicode TR35-49 spec [1].
开发者ID:python-babel,项目名称:babel,代码行数:30,代码来源:lists.py
示例13: default_locale
from babel.core import default_locale, get_global, Locale
from babel.util import UTC
__all__ = [
"format_date",
"format_datetime",
"format_time",
"format_timedelta",
"get_timezone_name",
"parse_date",
"parse_datetime",
"parse_time",
]
__docformat__ = "restructuredtext en"
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_period_names(locale=LC_TIME):
"""Return the names for day periods (AM/PM) used by the locale.
>>> get_period_names(locale='en_US')['am']
u'AM'
:param locale: the `Locale` object, or a locale string
:return: the dictionary of period names
开发者ID:miracle2k,项目名称:babel,代码行数:31,代码来源:dates.py
示例14: get_locale
def get_locale():
# TODO - G.M - 27-03-2018 - [i18n] Reconnect true internationalization
return default_locale('LC_TIME')
开发者ID:tracim,项目名称:tracim,代码行数:3,代码来源:translation.py
注:本文中的babel.core.default_locale函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论