How to use the humanize.i18n.django_language function in humanize

To help you get started, we’ve selected a few humanize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 1flow / sparks / sparks / django / templatetags / utils.py View on Github external
def naturalsize(number, type=None):
    """ Return a humanized (and translated) file size. """

    with humanize.i18n.django_language():
        if type is None:
            return humanize.naturalsize(number)

        if type in ('bin', 'binary'):
            return humanize.naturalsize(number, binary=True)

        if type in ('gnu', 'GNU'):
            return humanize.naturalsize(number, gnu=True)