diff options
| author | Glandos <bugs-github@antipoul.fr> | 2020-05-07 22:56:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-07 22:56:17 +0200 |
| commit | 981edd413acfdd4786faf5439d2a05d6d7e4649e (patch) | |
| tree | 3c1598baf52dd447fd806a5038e8b8f0c0e83fbc /ihatemoney/run.py | |
| parent | 76911983af9e04e379853ab3c66804e73f5f16a0 (diff) | |
| download | ihatemoney-mirror-981edd413acfdd4786faf5439d2a05d6d7e4649e.zip ihatemoney-mirror-981edd413acfdd4786faf5439d2a05d6d7e4649e.tar.gz ihatemoney-mirror-981edd413acfdd4786faf5439d2a05d6d7e4649e.tar.bz2 | |
Improve currencies (#604)
- Rename "No Currency" to ISO4217 "XXX"
- Use Babel to render currency symbols and names in currency lists
- Improve i18n in bill lists
Fix #601
Fix #600
Diffstat (limited to 'ihatemoney/run.py')
| -rw-r--r-- | ihatemoney/run.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ihatemoney/run.py b/ihatemoney/run.py index b6c8cbb..e084e5b 100644 --- a/ihatemoney/run.py +++ b/ihatemoney/run.py @@ -3,7 +3,7 @@ import os.path import warnings from flask import Flask, g, render_template, request, session -from flask_babel import Babel +from flask_babel import Babel, format_currency from flask_mail import Mail from flask_migrate import Migrate, stamp, upgrade from werkzeug.middleware.proxy_fix import ProxyFix @@ -153,6 +153,22 @@ def create_app( # Translations babel = Babel(app) + # Undocumented currencyformat filter from flask_babel is forwarding to Babel format_currency + # We overwrite it to remove the currency sign ¤ when there is no currency + def currencyformat_nc(number, currency, *args, **kwargs): + """ + Same as flask_babel.Babel.currencyformat, but without the "no currency ¤" sign + when there is no currency. + """ + return format_currency( + number, + currency if currency != CurrencyConverter.no_currency else "", + *args, + **kwargs + ).strip() + + app.jinja_env.filters["currencyformat_nc"] = currencyformat_nc + @babel.localeselector def get_locale(): # get the lang from the session if defined, fallback on the browser "accept |
