Exemple #1
0
    def money_format(value, grouping = True, symbol = True):
        try:
            value = float(value)
        except:
            return ""

        with get_locale_ctx(locale.LC_MONETARY):
            return locale.currency(value, grouping = grouping, symbol = symbol)
Exemple #2
0
    def number_format(value, grouping = True, monetary = False, rounding = None):
        try:
            value = float(value)
        except:
            return ""

        if rounding is not None:
            format = '%.{0}f'.format(str(rounding))
        else:
            format = '%.2f'

        with get_locale_ctx(locale.LC_NUMERIC):
            return locale.format(format, value, grouping = grouping, monetary = monetary)