我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用django.utils.translation.ungettext_lazy()。
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)
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")
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
def action_present(count): return ungettext_lazy( u"Delete Container", u"Delete Containers", count )
def action_past(count): return ungettext_lazy( u"Deleted Container", u"Deleted Containers", count )
def action_present(count): return ungettext_lazy( u"Delete Object", u"Delete Objects", count )
def action_past(count): return ungettext_lazy( u"Deleted Object", u"Deleted Objects", count )
def action_present(count): return ungettext_lazy( u"Delete Volume", u"Delete Volumes", count )
def action_present(count): return ungettext_lazy( u"Detach Volume", u"Detach Volumes", count ) # This action is asynchronous.
def action_past(count): return ungettext_lazy( u"Detaching Volume", u"Detaching Volumes", count )
def action_present(count): return ungettext_lazy( u"Delete Volume Snapshot", u"Delete Volume Snapshots", count )
def action_past(count): return ungettext_lazy( u"Scheduled deletion of Volume Snapshot", u"Scheduled deletion of Volume Snapshots", count )
def action_present(count): return ungettext_lazy( u"Delete Consistency Group", u"Delete Consistency Groups", count )
def action_present(count): return ungettext_lazy( u"Delete Volume Backup", u"Delete Volume Backups", count )
def action_past(count): return ungettext_lazy( u"Scheduled deletion of Volume Backup", u"Scheduled deletion of Volume Backups", count )
def action_present(count): return ungettext_lazy( u"Delete VPN Service", u"Delete VPN Services", count )
def action_past(count): return ungettext_lazy( u"Scheduled deletion of VPN Service", u"Scheduled deletion of VPN Services", count )
def action_present(count): return ungettext_lazy( u"Delete IKE Policy", u"Delete IKE Policies", count )
def action_present(count): return ungettext_lazy( u"Delete IPSec Policy", u"Delete IPSec Policies", count )
def action_past(count): return ungettext_lazy( u"Scheduled deletion of IPSec Policy", u"Scheduled deletion of IPSec Policies", count )
def action_present(count): return ungettext_lazy( u"Delete IPSec Site Connection", u"Delete IPSec Site Connections", count )
def action_past(count): return ungettext_lazy( u"Scheduled deletion of IPSec Site Connection", u"Scheduled deletion of IPSec Site Connections", count )
def action_present(count): return ungettext_lazy( u"Check Stack", u"Check Stacks", count )
def action_present(count): return ungettext_lazy( u"Suspend Stack", u"Suspend Stacks", count )
def action_past(count): return ungettext_lazy( u"Suspended Stack", u"Suspended Stacks", count )
def action_present(count): return ungettext_lazy( u"Resume Stack", u"Resume Stacks", count )
def action_past(count): return ungettext_lazy( u"Resumed Stack", u"Resumed Stacks", count )
def action_present(count): return ungettext_lazy( u"Delete Stack", u"Delete Stacks", count )
def action_present(count): return ungettext_lazy( u"Delete Instance", u"Delete Instances", count )
def action_past(count): return ungettext_lazy( u"Scheduled deletion of Instance", u"Scheduled deletion of Instances", count )
def action_present(count): return ungettext_lazy( u"Hard Reboot Instance", u"Hard Reboot Instances", count )
def action_past(count): return ungettext_lazy( u"Hard Rebooted Instance", u"Hard Rebooted Instances", count )
def action_past(count): return ungettext_lazy( u"Soft Rebooted Instance", u"Soft Rebooted Instances", count )
def action_present(count): return ( ungettext_lazy( u"Pause Instance", u"Pause Instances", count ), ungettext_lazy( u"Resume Instance", u"Resume Instances", count ), )
def action_past(count): return ( ungettext_lazy( u"Paused Instance", u"Paused Instances", count ), ungettext_lazy( u"Resumed Instance", u"Resumed Instances", count ), )
def action_present(count): return ( ungettext_lazy( u"Suspend Instance", u"Suspend Instances", count ), ungettext_lazy( u"Resume Instance", u"Resume Instances", count ), )
def action_past(count): return ( ungettext_lazy( u"Suspended Instance", u"Suspended Instances", count ), ungettext_lazy( u"Resumed Instance", u"Resumed Instances", count ), )
def action_past(count): return ( ungettext_lazy( u"Shelved Instance", u"Shelved Instances", count ), ungettext_lazy( u"Unshelved Instance", u"Unshelved Instances", count ), )
def action_present(count): return ungettext_lazy( u"Start Instance", u"Start Instances", count )
def action_past(count): return ungettext_lazy( u"Started Instance", u"Started Instances", count )
def action_present(count): return ungettext_lazy( u"Lock Instance", u"Lock Instances", count )
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
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
def action_present(count): return ungettext_lazy( u"Delete Pool", u"Delete Pools", count )
def action_past(count): return ungettext_lazy( u"Scheduled deletion of Pool", u"Scheduled deletion of Pools", count )
def action_present(count): return ungettext_lazy( u"Delete Monitor", u"Delete Monitors", count )
def action_past(count): return ungettext_lazy( u"Scheduled deletion of Monitor", u"Scheduled deletion of Monitors", count )
def action_past(count): return ungettext_lazy( u"Scheduled deletion of Member", u"Scheduled deletion of Members", count )
def action_present(count): return ungettext_lazy( u"Delete Security Group", u"Delete Security Groups", count )
def action_past(count): return ungettext_lazy( u"Deleted Security Group", u"Deleted Security Groups", count )