mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
new def to format percentages with current locale decimal point
This commit is contained in:
parent
4370606fc1
commit
dfb477ec4b
1 changed files with 8 additions and 0 deletions
|
@ -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
|
||||
##############################################################################
|
||||
|
||||
|
|
Loading…
Reference in a new issue