From 914482bc76954aef067ac73314a19f415a32c61c Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Sun, 26 Apr 2020 16:40:35 +0200 Subject: Use Flask-Babel to localize datetime in the History Page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By formatting datetime on the server, we get nice localized datetime strings that are adapted to the currently-selected language. Example: - English: "Apr 26, 2020, 3:58:54 PM" - French: "26 avr. 2020 à 15:58:54" - German: "26.04.2020, 15:58:54" - Spanish: "26 abr. 2020 15:58:54" - Indonesian: "26 Apr 2020 15.58.54" - Chinese: "2020年4月26日 下午3:58:54" However, there is a downside: time is not adapted to the user timezone. The solution is to define a timezone on the server: we use the server OS timezone by default, and it can be customized through the BABEL_DEFAULT_TIMEZONE setting. It's still not ideal, because it assumes that all users are in the same timezone (the one configured on the server). --- ihatemoney/templates/history.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ihatemoney/templates') diff --git a/ihatemoney/templates/history.html b/ihatemoney/templates/history.html index d9f2b4d..d4965d8 100644 --- a/ihatemoney/templates/history.html +++ b/ihatemoney/templates/history.html @@ -161,7 +161,7 @@ {% for event in history %} - + {{ event.time|datetimeformat("medium") }}