mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 09:22:38 +02:00
update locale selector definition
This commit is contained in:
parent
b03966f2c4
commit
113e010dc5
1 changed files with 12 additions and 12 deletions
|
@ -202,7 +202,18 @@ def create_app(
|
|||
default_timezone = str(LOCALTZ)
|
||||
except pytz.exceptions.UnknownTimeZoneError:
|
||||
pass
|
||||
babel = Babel(app, default_timezone=default_timezone)
|
||||
|
||||
def get_locale():
|
||||
# get the lang from the session if defined, fallback on the browser "accept
|
||||
# languages" header.
|
||||
lang = session.get(
|
||||
"lang",
|
||||
request.accept_languages.best_match(app.config["SUPPORTED_LANGUAGES"]),
|
||||
)
|
||||
setattr(g, "lang", lang)
|
||||
return lang
|
||||
|
||||
Babel(app, default_timezone=default_timezone, locale_selector=get_locale)
|
||||
|
||||
# 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
|
||||
|
@ -223,17 +234,6 @@ def create_app(
|
|||
|
||||
app.jinja_env.filters["currency"] = currency
|
||||
|
||||
@babel.localeselector
|
||||
def get_locale():
|
||||
# get the lang from the session if defined, fallback on the browser "accept
|
||||
# languages" header.
|
||||
lang = session.get(
|
||||
"lang",
|
||||
request.accept_languages.best_match(app.config["SUPPORTED_LANGUAGES"]),
|
||||
)
|
||||
setattr(g, "lang", lang)
|
||||
return lang
|
||||
|
||||
return app
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue