From dfb477ec4b7e83e8a4511ca7a08786a5cc3ac121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Susanna=20Bj=C3=B6rverud?= Date: Tue, 24 Mar 2009 13:31:19 +0100 Subject: [PATCH] new def to format percentages with current locale decimal point --- anki/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/anki/utils.py b/anki/utils.py index e5259bcee..7421c8f24 100644 --- a/anki/utils.py +++ b/anki/utils.py @@ -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 ##############################################################################