new def to format percentages with current locale decimal point

This commit is contained in:
Susanna Björverud 2009-03-24 13:31:19 +01:00 committed by Damien Elmes
parent 4370606fc1
commit dfb477ec4b

View file

@ -106,6 +106,14 @@ def _pluralCount(time):
return 1
return round(time, 1)
# locale
##############################################################################
def fmtPercentage(float_value, point=1):
"Return string representing a float respecting current locale followed by a percentage sign"
fmt = '%' + "0.%(b)df" % {'b': point}
return locale.format_string(fmt, float_value) + "%"
# HTML
##############################################################################