• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python i18n.get_current_babel_locale函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中shoop.utils.i18n.get_current_babel_locale函数的典型用法代码示例。如果您正苦于以下问题:Python get_current_babel_locale函数的具体用法?Python get_current_babel_locale怎么用?Python get_current_babel_locale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_current_babel_locale函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_dashboard_blocks

 def get_dashboard_blocks(self, request):
     if not self.check_demo_optin(request):
         return
     locale = get_current_babel_locale()
     n = now()
     weekday = format_date(n, "EEEE", locale=locale)
     today = format_date(n, locale=locale)
     yield DashboardValueBlock(
         id="test-x", color="blue", title="Happy %s!" % weekday, value=today, icon="fa fa-calendar"
     )
     yield DashboardNumberBlock(
         id="test-x", color="red", title="Visitors Yesterday", value=random.randint(2200, 10000), icon="fa fa-globe"
     )
     yield DashboardNumberBlock(id="test-x", color="gray", title="Registered Users", value=1240, icon="fa fa-user")
     yield DashboardNumberBlock(id="test-x", color="orange", title="Orders", value=32, icon="fa fa-inbox")
     yield DashboardMoneyBlock(
         id="test-x", color="green", title="Open Orders Value", value=32000, currency="USD", icon="fa fa-line-chart"
     )
     yield DashboardNumberBlock(id="test-x", color="yellow", title="Current Visitors", value=6, icon="fa fa-users")
     yield DashboardMoneyBlock(
         id="test-x", color="none", title="Sales this week", value=430.30, currency="USD", icon="fa fa-dollar"
     )
     yield DashboardValueBlock(
         id="test-1", value="\u03C0", title="The most delicious number", color="purple", icon="fa fa-smile-o"
     )
开发者ID:taedori81,项目名称:shoop,代码行数:25,代码来源:__init__.py


示例2: percent

def percent(value, ndigits=3):
    locale = get_current_babel_locale()
    if not ndigits:
        return format_percent(value, locale=locale)
    else:
        format = locale.percent_formats.get(None)
        new_fmt = format.pattern.replace("0", "0." + (ndigits * "#"))
        return format_percent(value, format=new_fmt, locale=locale)
开发者ID:noyonthe1,项目名称:shoop,代码行数:8,代码来源:shoop_common.py


示例3: get_choices

 def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH):
     locale = get_current_babel_locale()
     translated_choices = [
         (code, locale.languages.get(code, code))
         for (code, _)
         in super(LanguageField, self).get_choices(include_blank, blank_choice)
     ]
     translated_choices.sort(key=lambda pair: pair[1].lower())
     return translated_choices
开发者ID:portlyjent,项目名称:shoop,代码行数:9,代码来源:__init__.py


示例4: encode_line

def encode_line(line):
    return {
        "sku": line.sku,
        "text": line.text,
        "quantity": format_decimal(line.quantity, locale=get_current_babel_locale()),
        "unitPrice": format_money(line.base_unit_price.amount),
        "discountAmount": format_money(line.discount_amount.amount),
        "taxlessTotal": format_money(line.taxless_price.amount),
        "taxPercentage": format_percent(line.tax_rate, 2),
        "taxfulTotal": format_money(line.taxful_price.amount)
    }
开发者ID:sebad78,项目名称:shoop,代码行数:11,代码来源:create.py


示例5: datetime

def datetime(value, kind="datetime", format="medium", tz=True):
    """
    Format a datetime for human consumption.

    The currently active locale's formatting rules are used.  The output
    of this function is probably not machine-parseable.

    :param value: datetime object to format
    :type value: datetime.datetime

    :param kind: Format as 'datetime', 'date' or 'time'
    :type kind: str

    :param format:
      Format specifier or one of 'full', 'long', 'medium' or 'short'
    :type format: str

    :param tz:
      Convert to current or given timezone. Accepted values are:

         True (default)
             convert to currently active timezone (as reported by
             :func:`django.utils.timezone.get_current_timezone`)
         False (or other false value like empty string)
             do no convert to any timezone (use UTC)
         Other values (as str)
             convert to given timezone (e.g. ``"US/Hawaii"``)
    :type tz: bool|str
    """

    locale = get_current_babel_locale()

    if type(value) is date:  # Not using isinstance, since `datetime`s are `date` too.
        # We can't do any TZ manipulation for dates, so just use `format_date` always
        return format_date(value, format=format, locale=locale)

    if tz:
        value = localtime(value, (None if tz is True else tz))

    if kind == "datetime":
        return format_datetime(value, format=format, locale=locale)
    elif kind == "date":
        return format_date(value, format=format, locale=locale)
    elif kind == "time":
        return format_time(value, format=format, locale=locale)
    else:
        raise ValueError("Unknown `datetime` kind: %r" % kind)
开发者ID:Jeewes,项目名称:shoop,代码行数:47,代码来源:shoop_common.py


示例6: get_chart

 def get_chart(self):
     aggregate_data = group_by_period(
         Order.objects.valid().since(days=365),
         "order_date",
         "month",
         sum=Sum("taxful_total_price")
     )
     locale = get_current_babel_locale()
     bar_chart = BarChart(title=_("Sales per Month (last year)"), labels=[
         format_date(k, format=get_year_and_month_format(locale), locale=locale)
         for k in aggregate_data
     ])
     bar_chart.add_data(
         _("Sales (%(currency)s)") % {"currency": settings.SHOOP_HOME_CURRENCY},
         [bankers_round(v["sum"], settings.SHOOP_ORDER_TOTAL_DECIMALS) for v in aggregate_data.values()]
     )
     return bar_chart
开发者ID:jaywink,项目名称:shoop,代码行数:17,代码来源:dashboard.py


示例7: as_string_list

    def as_string_list(self, locale=None):
        locale = locale or get_current_babel_locale()
        country = self.country.code.upper()

        base_lines = [
            self.company_name,
            self.full_name,
            self.name_ext,
            self.street,
            self.street2,
            self.street3,
            "%s %s %s" % (self.region_code, self.postal_code, self.city),
            self.region,
            locale.territories.get(country, country) if not self.is_home else None
        ]

        stripped_lines = [force_text(line).strip() for line in base_lines if line]
        return [s for s in stripped_lines if (s and len(s) > 1)]
开发者ID:DemOneEh,项目名称:shoop,代码行数:18,代码来源:addresses.py


示例8: get_chart

 def get_chart(self):
     orders = get_orders_by_currency(self.currency)
     aggregate_data = group_by_period(
         orders.valid().since(days=365),
         "order_date",
         "month",
         sum=Sum("taxful_total_price_value")
     )
     locale = get_current_babel_locale()
     bar_chart = BarChart(title=_("Sales per Month (last year)"), labels=[
         format_date(k, format=get_year_and_month_format(locale), locale=locale)
         for k in aggregate_data
     ])
     bar_chart.add_data(
         _("Sales (%(currency)s)") % {"currency": self.currency},
         [
             bankers_round(v["sum"], 2)  # TODO: To be fixed in SHOOP-1912
             for v in aggregate_data.values()
         ]
     )
     return bar_chart
开发者ID:taedori81,项目名称:shoop,代码行数:21,代码来源:dashboard.py


示例9: format_order_date

 def format_order_date(self, instance, *args, **kwargs):
     return format_datetime(localtime(instance.order_date), locale=get_current_babel_locale())
开发者ID:kloudsio,项目名称:shoop,代码行数:2,代码来源:list.py


示例10: number

def number(value):
    return format_decimal(value, locale=get_current_babel_locale())
开发者ID:Jeewes,项目名称:shoop,代码行数:2,代码来源:shoop_common.py


示例11: _formatted_datetime

 def _formatted_datetime(self, dt):
     return format_datetime(localtime(dt), locale=get_current_babel_locale())
开发者ID:00WhengWheng,项目名称:shuup,代码行数:2,代码来源:views.py


示例12: __init__

 def __init__(self, id, value, title, currency=None, **kwargs):
     self.currency = (currency or settings.SHOOP_HOME_CURRENCY)
     value = parse_decimal_string(value)
     value = format_currency(value, currency=self.currency, locale=get_current_babel_locale())
     super(DashboardMoneyBlock, self).__init__(id, value, title, **kwargs)
开发者ID:charn,项目名称:shoop,代码行数:5,代码来源:blocks.py


示例13: format_end_date

 def format_end_date(self, instance, *args, **kwargs):
     return format_date(instance.end_date, locale=get_current_babel_locale())
开发者ID:jaywink,项目名称:kakaravaara3,代码行数:2,代码来源:views.py


示例14: home_currency

def home_currency(value):
    return format_home_currency(value, locale=get_current_babel_locale())
开发者ID:noyonthe1,项目名称:shoop,代码行数:2,代码来源:shoop_common.py


示例15: __init__

 def __init__(self, id, value, title, currency, **kwargs):
     self.currency = currency
     value = parse_decimal_string(value)
     value = format_currency(value, currency=self.currency, locale=get_current_babel_locale())
     super(DashboardMoneyBlock, self).__init__(id, value, title, **kwargs)
开发者ID:DemOneEh,项目名称:shoop,代码行数:5,代码来源:blocks.py



注:本文中的shoop.utils.i18n.get_current_babel_locale函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python campaigns.initialize_test函数代码示例发布时间:2022-05-27
下一篇:
Python utils.apply_request_middleware函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap