From c8730857293c694449110ec289210e7ec4f32aa4 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 21 Apr 2021 21:35:55 +0200 Subject: make language and active page available in all templates --- talermerchantdemos/landing/landing.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'talermerchantdemos/landing/landing.py') diff --git a/talermerchantdemos/landing/landing.py b/talermerchantdemos/landing/landing.py index 270e205..3c1f304 100644 --- a/talermerchantdemos/landing/landing.py +++ b/talermerchantdemos/landing/landing.py @@ -82,13 +82,19 @@ def get_locale(): return lang return "en" - ## # Make the environment available into templates. # # @return the environment-reading function. @app.context_processor def utility_processor(): + + def getactive(): + return "landing" + + def getlang(): + return get_locale() + def env(name, default=None): return os.environ.get(name, default) @@ -101,7 +107,7 @@ def utility_processor(): # returns the YYYY-MM-DD date format. return timestamp.strftime("%Y-%b-%d") - return dict(env=env, prettydate=prettydate) + return dict(env=env, prettydate=prettydate, getactive=getactive, getlang=getlang) ## @@ -116,7 +122,6 @@ def internal_error(e): "landing-error.html.j2", message=gettext("Internal error"), stack=traceback.format_exc(), - lang=get_locale(), ) @@ -175,7 +180,6 @@ def start(lang): return flask.render_template( "landing-index.html.j2", merchant_currency=CURRENCY, - lang=lang, bank_url=bank_register_url, merchant_blog_url=merchant_blog_url, merchant_donations_url=merchant_donations_url, @@ -186,7 +190,7 @@ def start(lang): @app.errorhandler(404) def handler_404(e): return flask.render_template( - "landing-error.html.j2", message=gettext("Page not found"), lang=get_locale() + "landing-error.html.j2", message=gettext("Page not found") ) @@ -195,5 +199,4 @@ def handler_405(e): return flask.render_template( "landing-error.html.j2", message=gettext("HTTP method not allowed for this page"), - lang=get_locale(), ) -- cgit v1.2.3