templatetags: work around multiple spaces in newer num2words output (#82017)
gitea/hobo/pipeline/head There was a failure building this commit Details

This commit is contained in:
Frédéric Péters 2023-10-31 18:11:52 +01:00
parent 67609853be
commit 62211149b6
1 changed files with 6 additions and 2 deletions

View File

@ -57,8 +57,12 @@ def as_numeral_currency(number):
if not number:
return ''
try:
# workaround newer num2words always specifiying cents
return num2words(unlazy(number), lang=get_language(), to='currency').removesuffix(' et zéro centimes')
# workaround newer num2words always specifiying cents, and outputting consecutive spaces
return (
num2words(unlazy(number), lang=get_language(), to='currency')
.removesuffix(' et zéro centimes')
.replace(' ', ' ')
)
except (TypeError, ValueError, decimal.InvalidOperation):
return ''