From 563f0b839c7d74be569231e83bf2a894bb24cfe4 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sat, 14 Mar 2020 22:54:36 +0100 Subject: Updated translations. --- newspipe/bootstrap.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'newspipe/bootstrap.py') diff --git a/newspipe/bootstrap.py b/newspipe/bootstrap.py index bbdd038e..80f8b694 100644 --- a/newspipe/bootstrap.py +++ b/newspipe/bootstrap.py @@ -7,7 +7,7 @@ import logging import os from flask import Flask, request -from flask_babel import Babel +from flask_babel import Babel, format_datetime from flask_sqlalchemy import SQLAlchemy @@ -77,3 +77,19 @@ def get_locale(): # header the browser transmits. We support de/fr/en in this # example. The best match wins. return request.accept_languages.best_match(application.config["LANGUAGES"].keys()) + + +# Jinja filters +def month_name(month_number): + return calendar.month_name[month_number] + + +def datetimeformat(value, format="%Y-%m-%d %H:%M"): + return value.strftime(format) + + +application.jinja_env.filters["month_name"] = month_name +application.jinja_env.filters["datetime"] = format_datetime +application.jinja_env.filters["datetimeformat"] = datetimeformat +# inject application in Jinja env +application.jinja_env.globals["application"] = application -- cgit