Ticket #14240: django_localize_filesizeformat_number.diff
File django_localize_filesizeformat_number.diff, 1.3 KB (added by , 14 years ago) |
---|
-
django/template/defaultfilters.py
810 810 if bytes < 1024: 811 811 return ungettext("%(size)d byte", "%(size)d bytes", bytes) % {'size': bytes} 812 812 if bytes < 1024 * 1024: 813 return ugettext("% .1f KB") % (bytes / 1024)813 return ugettext("%s KB") % formats.number_format(bytes / 1024, 1) 814 814 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) 816 816 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) 818 818 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) 821 821 filesizeformat.is_safe = True 822 822 823 823 def pluralize(value, arg=u's'):