Ticket #14240: django_localize_filesizeformat_number.diff

File django_localize_filesizeformat_number.diff, 1.3 KB (added by David Danier <david.danier@…>, 9 years ago)
  • django/template/defaultfilters.py

     
    810810    if bytes < 1024:
    811811        return ungettext("%(size)d byte", "%(size)d bytes", bytes) % {'size': bytes}
    812812    if bytes < 1024 * 1024:
    813         return ugettext("%.1f KB") % (bytes / 1024)
     813        return ugettext("%s KB") % formats.number_format(bytes / 1024, 1)
    814814    if bytes < 1024 * 1024 * 1024:
    815         return ugettext("%.1f MB") % (bytes / (1024 * 1024))
     815        return ugettext("%s MB") % formats.number_format(bytes / (1024 * 1024), 1)
    816816    if bytes < 1024 * 1024 * 1024 * 1024:
    817         return ugettext("%.1f GB") % (bytes / (1024 * 1024 * 1024))
     817        return ugettext("%s GB") % formats.number_format(bytes / (1024 * 1024 * 1024), 1)
    818818    if bytes < 1024 * 1024 * 1024 * 1024 * 1024:
    819         return ugettext("%.1f TB") % (bytes / (1024 * 1024 * 1024 * 1024))
    820     return ugettext("%.1f PB") % (bytes / (1024 * 1024 * 1024 * 1024 * 1024))
     819        return ugettext("%s TB") % formats.number_format(bytes / (1024 * 1024 * 1024 * 1024), 1)
     820    return ugettext("%s PB") % formats.number_format(bytes / (1024 * 1024 * 1024 * 1024 * 1024), 1)
    821821filesizeformat.is_safe = True
    822822
    823823def pluralize(value, arg=u's'):
Back to Top