From 8010ff18bfe69dacc3e6fcdb93719dbf313d8849 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Fri, 1 Jul 2022 16:13:09 +0200 Subject: use month names from locale instead of redoing it --- fietsboek/util.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/fietsboek/util.py b/fietsboek/util.py index b56584f..0f9cc5d 100644 --- a/fietsboek/util.py +++ b/fietsboek/util.py @@ -2,6 +2,7 @@ import random import string +import babel import markdown import bleach import gpxpy @@ -83,23 +84,8 @@ def month_name(request, month): :rtype: str """ assert 1 <= month <= 12 - # Explicitely list them so that Babel can extract them - months = [ - _("month.january"), - _("month.february"), - _("month.march"), - _("month.april"), - _("month.may"), - _("month.june"), - _("month.july"), - _("month.august"), - _("month.september"), - _("month.october"), - _("month.november"), - _("month.december"), - ] - our_month = months[month - 1] - return request.localizer.translate(our_month) + locale = babel.Locale.parse(request.localizer.locale_name) + return locale.months["stand-alone"]["wide"][month] def random_alphanum_string(length=20): -- cgit v1.2.3