当前位置: 首页>>代码示例>>Python>>正文


Python translation.pgettext_lazy方法代码示例

本文整理汇总了Python中django.utils.translation.pgettext_lazy方法的典型用法代码示例。如果您正苦于以下问题:Python translation.pgettext_lazy方法的具体用法?Python translation.pgettext_lazy怎么用?Python translation.pgettext_lazy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.utils.translation的用法示例。


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

示例1: resolve

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import pgettext_lazy [as 别名]
def resolve(self, context):
        """Resolve this variable against a given context."""
        if self.lookups is not None:
            # We're dealing with a variable that needs to be resolved
            value = self._resolve_lookup(context)
        else:
            # We're dealing with a literal, so it's already been "resolved"
            value = self.literal
        if self.translate:
            is_safe = isinstance(value, SafeData)
            msgid = value.replace('%', '%%')
            msgid = mark_safe(msgid) if is_safe else msgid
            if self.message_context:
                return pgettext_lazy(self.message_context, msgid)
            else:
                return gettext_lazy(msgid)
        return value 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:19,代码来源:base.py

示例2: resolve

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import pgettext_lazy [as 别名]
def resolve(self, context):
        """Resolve this variable against a given context."""
        if self.lookups is not None:
            # We're dealing with a variable that needs to be resolved
            value = self._resolve_lookup(context)
        else:
            # We're dealing with a literal, so it's already been "resolved"
            value = self.literal
        if self.translate:
            is_safe = isinstance(value, SafeData)
            msgid = value.replace('%', '%%')
            msgid = mark_safe(msgid) if is_safe else msgid
            if self.message_context:
                return pgettext_lazy(self.message_context, msgid)
            else:
                return ugettext_lazy(msgid)
        return value 
开发者ID:Yeah-Kun,项目名称:python,代码行数:19,代码来源:base.py

示例3: _set_external_network

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import pgettext_lazy [as 别名]
def _set_external_network(self, router, ext_net_dict):
        gateway_info = router.external_gateway_info
        if gateway_info:
            ext_net_id = gateway_info['network_id']
            if ext_net_id in ext_net_dict:
                gateway_info['network'] = ext_net_dict[ext_net_id]
            else:
                msg_params = {'ext_net_id': ext_net_id, 'router_id': router.id}
                msg = _('External network "%(ext_net_id)s" expected but not '
                        'found for router "%(router_id)s".') % msg_params
                messages.error(self.request, msg)
                # gateway_info['network'] is just the network name, so putting
                # in a smallish error message in the table is reasonable.
                gateway_info['network'] = pgettext_lazy(
                    'External network not found',
                    # Translators: The usage is "<UUID of ext_net> (Not Found)"
                    u'%s (Not Found)') % ext_net_id 
开发者ID:CiscoSystems,项目名称:avos,代码行数:19,代码来源:views.py

示例4: resolve

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import pgettext_lazy [as 别名]
def resolve(self, context):
        """Resolve this variable against a given context."""
        if self.lookups is not None:
            # We're dealing with a variable that needs to be resolved
            value = self._resolve_lookup(context)
        else:
            # We're dealing with a literal, so it's already been "resolved"
            value = self.literal
        if self.translate:
            if self.message_context:
                return pgettext_lazy(self.message_context, value)
            else:
                return ugettext_lazy(value)
        return value 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:16,代码来源:base.py

示例5: business_lines_list

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import pgettext_lazy [as 别名]
def business_lines_list(self, obj):
        bls = obj.business_lines.all()
        if bls.count():
            return ', '.join([bl.name for bl in bls])
        return pgettext_lazy('business lines', 'All') 
开发者ID:certsocietegenerale,项目名称:FIR,代码行数:7,代码来源:admin.py

示例6: dispatch

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import pgettext_lazy [as 别名]
def dispatch(self, request, *args, **kwargs):
        code_from_kwarg = {v: k for k, v in self.book_codes.items()}
        code_from_kwarg.update({None: False})
        self.in_book_status = code_from_kwarg[kwargs['in_book']]
        if self.in_book_status and not request.user.has_perm(PERM_SUPERVISOR):
            return HttpResponseRedirect(format_lazy(
                "{supervisors_url}#{section_countries}",
                supervisors_url=reverse_lazy('supervisors'),
                section_countries=pgettext_lazy("URL", "countries-list"),
            ))
        return super().dispatch(request, *args, **kwargs) 
开发者ID:tejoesperanto,项目名称:pasportaservo,代码行数:13,代码来源:views.py

示例7: get

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import pgettext_lazy [as 别名]
def get(self, request, *args, **kwargs):
        try:
            return HttpResponseRedirect(format_lazy(
                "{settings_url}#{section_email}",
                settings_url=reverse_lazy('profile_settings', kwargs={
                    'pk': request.user.profile.pk, 'slug': request.user.profile.autoslug}),
                section_email=pgettext_lazy("URL", "email-addr"),
            ))
        except Profile.DoesNotExist:
            return HttpResponseRedirect(reverse_lazy('email_update')) 
开发者ID:tejoesperanto,项目名称:pasportaservo,代码行数:12,代码来源:views.py

示例8: __init__

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import pgettext_lazy [as 别名]
def __init__(self, *args, **kwargs):
        site = kwargs.pop('site')
        super().__init__(*args, **kwargs)
        activities = Activity.objects.filter(site=site)
        self.fields['activity'].choices = [('none', pgettext_lazy('activity', 'None'))] + list(activities.values_list('slug', 'name')) 
开发者ID:PonyConf,项目名称:PonyConf,代码行数:7,代码来源:forms.py

示例9: __call__

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import pgettext_lazy [as 别名]
def __call__(self, value):
        super(AuthUserEmailValidator, self).__call__(value)

        from django.contrib.auth.models import User

        if User.objects.filter(email__iexact=value).exists():
            raise ValidationError(_('ecla', 'This email has already been taken.')) 
开发者ID:vinta,项目名称:django-email-confirm-la,代码行数:9,代码来源:validators.py

示例10: _get_action_name

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import pgettext_lazy [as 别名]
def _get_action_name(self, items=None, past=False):
        """Builds combinations like 'Delete Object' and 'Deleted
        Objects' based on the number of items and `past` flag.

        :param items:

            A list or tuple of items (or container with a __len__ method) to
            count the number of concerned items for which this method is
            called.
            When this method is called for a single item (by the BatchAction
            itself), this parameter can be omitted and the number of items
            will be considered as "one".
            If we want to evaluate to "zero" this parameter must not be omitted
            (and should be an empty container).

        :param past:

            Boolean flag indicating if the action took place in the past.
            By default a present action is considered.
        """
        action_type = "past" if past else "present"
        if items is None:
            # Called without items parameter (by a single instance.)
            count = 1
        else:
            count = len(items)

        # TODO(ygbo): get rid of self.use_action_method once action_present and
        # action_past are changed to methods handling plurals.
        action_attr = getattr(self, "action_%s" % action_type)
        if self.use_action_method:
            action_attr = action_attr(count)
        if isinstance(action_attr, (basestring, Promise)):
            action = action_attr
        else:
            toggle_selection = getattr(self, "current_%s_action" % action_type)
            action = action_attr[toggle_selection]

        if self.use_action_method:
            return action
        # TODO(ygbo): get rid of all this bellow once action_present and
        # action_past are changed to methods handling plurals.
        data_type = ungettext_lazy(
            self.data_type_singular,
            self.data_type_plural,
            count
        )
        if '%(data_type)s' in action:
            # If full action string is specified, use action as format string.
            msgstr = action
        else:
            if action_type == "past":
                msgstr = pgettext_lazy("past", "%(action)s %(data_type)s")
            else:
                msgstr = pgettext_lazy("present", "%(action)s %(data_type)s")
        return msgstr % {'action': action, 'data_type': data_type} 
开发者ID:CiscoSystems,项目名称:avos,代码行数:58,代码来源:actions.py


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