Python django.utils.translation 模块,ungettext_lazy() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用django.utils.translation.ungettext_lazy()

项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def filesizeformat(bytes, filesize_number_format):
    try:
        bytes = float(bytes)
    except (TypeError, ValueError, UnicodeDecodeError):
        return ungettext_lazy("%(size)d Byte",
                              "%(size)d Bytes", 0) % {'size': 0}

    if bytes < units.Ki:
        bytes = int(bytes)
        return ungettext_lazy("%(size)d Byte",
                              "%(size)d Bytes", bytes) % {'size': bytes}
    if bytes < units.Mi:
        return _("%s KB") % filesize_number_format(bytes / units.Ki)
    if bytes < units.Gi:
        return _("%s MB") % filesize_number_format(bytes / units.Mi)
    if bytes < units.Ti:
        return _("%s GB") % filesize_number_format(bytes / units.Gi)
    if bytes < units.Pi:
        return _("%s TB") % filesize_number_format(bytes / units.Ti)
    return _("%s PB") % filesize_number_format(bytes / units.Pi)
项目:tumanov_castleoaks    作者:Roamdev    | 项目源码 | 文件源码
def shortdate(value):
    now = timezone.template_localtime(timezone.now())
    diff = now - value

    if diff < timezone.timedelta():
        return date_format(value, "DATE_FORMAT")
    elif diff.days < 1:
        return _('today')
    elif diff.days < 2:
        return _('yesterday')
    elif diff.days < 30:
        return ungettext_lazy('%d day ago', '%d days ago') % diff.days
    else:
        months = diff.days // 30
        if months <= 6:
            return ungettext_lazy('a month ago', '%d months ago') % months
        else:
            return date_format(value, "DATE_FORMAT")
项目:c3nav    作者:c3nav    | 项目源码 | 文件源码
def get_user_data(request):
    permissions = AccessPermission.get_for_request(request)
    result = {
        'logged_in': bool(request.user.is_authenticated),
    }
    if permissions:
        result.update({
            'title': _('not logged in'),
            'subtitle': ungettext_lazy('%d area unlocked', '%d areas unlocked', len(permissions)) % len(permissions),
            'permissions': tuple(permissions),
        })
    else:
        result.update({
            'title': _('Login'),
            'subtitle': None,
            'permissions': (),
        })
    if request.user.is_authenticated:
        result['title'] = request.user.username
    return result
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete Container",
            u"Delete Containers",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Deleted Container",
            u"Deleted Containers",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete Object",
            u"Delete Objects",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Deleted Object",
            u"Deleted Objects",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete Volume",
            u"Delete Volumes",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Detach Volume",
            u"Detach Volumes",
            count
        )

    # This action is asynchronous.
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Detaching Volume",
            u"Detaching Volumes",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete Volume Snapshot",
            u"Delete Volume Snapshots",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Scheduled deletion of Volume Snapshot",
            u"Scheduled deletion of Volume Snapshots",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete Consistency Group",
            u"Delete Consistency Groups",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete Volume Backup",
            u"Delete Volume Backups",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Scheduled deletion of Volume Backup",
            u"Scheduled deletion of Volume Backups",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete VPN Service",
            u"Delete VPN Services",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Scheduled deletion of VPN Service",
            u"Scheduled deletion of VPN Services",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete IKE Policy",
            u"Delete IKE Policies",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete IPSec Policy",
            u"Delete IPSec Policies",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Scheduled deletion of IPSec Policy",
            u"Scheduled deletion of IPSec Policies",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete IPSec Site Connection",
            u"Delete IPSec Site Connections",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Scheduled deletion of IPSec Site Connection",
            u"Scheduled deletion of IPSec Site Connections",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Check Stack",
            u"Check Stacks",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Suspend Stack",
            u"Suspend Stacks",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Suspended Stack",
            u"Suspended Stacks",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Resume Stack",
            u"Resume Stacks",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Resumed Stack",
            u"Resumed Stacks",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete Stack",
            u"Delete Stacks",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete Instance",
            u"Delete Instances",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Scheduled deletion of Instance",
            u"Scheduled deletion of Instances",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Hard Reboot Instance",
            u"Hard Reboot Instances",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Hard Rebooted Instance",
            u"Hard Rebooted Instances",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Soft Rebooted Instance",
            u"Soft Rebooted Instances",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return (
            ungettext_lazy(
                u"Pause Instance",
                u"Pause Instances",
                count
            ),
            ungettext_lazy(
                u"Resume Instance",
                u"Resume Instances",
                count
            ),
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return (
            ungettext_lazy(
                u"Paused Instance",
                u"Paused Instances",
                count
            ),
            ungettext_lazy(
                u"Resumed Instance",
                u"Resumed Instances",
                count
            ),
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return (
            ungettext_lazy(
                u"Suspend Instance",
                u"Suspend Instances",
                count
            ),
            ungettext_lazy(
                u"Resume Instance",
                u"Resume Instances",
                count
            ),
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return (
            ungettext_lazy(
                u"Suspended Instance",
                u"Suspended Instances",
                count
            ),
            ungettext_lazy(
                u"Resumed Instance",
                u"Resumed Instances",
                count
            ),
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return (
            ungettext_lazy(
                u"Shelved Instance",
                u"Shelved Instances",
                count
            ),
            ungettext_lazy(
                u"Unshelved Instance",
                u"Unshelved Instances",
                count
            ),
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Start Instance",
            u"Start Instances",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Started Instance",
            u"Started Instances",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Lock Instance",
            u"Lock Instances",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Locked Instance",
            u"Locked Instances",
            count
        )

    # TODO(akrivoka): When the lock status is added to nova, revisit this
    # to only allow unlocked instances to be locked
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Unlocked Instance",
            u"Unlocked Instances",
            count
        )

    # TODO(akrivoka): When the lock status is added to nova, revisit this
    # to only allow locked instances to be unlocked
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete Pool",
            u"Delete Pools",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Scheduled deletion of Pool",
            u"Scheduled deletion of Pools",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete Monitor",
            u"Delete Monitors",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Scheduled deletion of Monitor",
            u"Scheduled deletion of Monitors",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Scheduled deletion of Member",
            u"Scheduled deletion of Members",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_present(count):
        return ungettext_lazy(
            u"Delete Security Group",
            u"Delete Security Groups",
            count
        )
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def action_past(count):
        return ungettext_lazy(
            u"Deleted Security Group",
            u"Deleted Security Groups",
            count
        )