From 21ca7669f7393086bec41fddfdb375c7e4d39d16 Mon Sep 17 00:00:00 2001 From: Quido Zientek <quido@codero.cz> Date: Tue, 30 Aug 2022 15:24:56 +0200 Subject: [PATCH] [FEATURE] set month name to czech --- elections2021/constants.py | 15 +++++++++++++++ main/models.py | 8 ++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/elections2021/constants.py b/elections2021/constants.py index c39b48e1..3350e1f6 100644 --- a/elections2021/constants.py +++ b/elections2021/constants.py @@ -125,6 +125,21 @@ REGION_NAME_VARIANT = {code: name2 for code, slug, name, name2 in REGION_DATA} REGION_SLUGS = {slug: code for code, slug, name, name2 in REGION_DATA} REGION_OPTIONS = [(slug, name) for code, slug, name, name2 in REGION_DATA] +MONTH_NAMES = [ + "Leden", + "Únor", + "Březen", + "Duben", + "Květen", + "Červen", + "Červenec", + "Srpen", + "Září", + "Říjen", + "Listopad", + "Prosinec", +] + PIRATES = "pirati" STAN = "stan" PARTY_CHOICES = ((PIRATES, "Piráti"), (STAN, "STAN")) diff --git a/main/models.py b/main/models.py index df2f8202..91d81a5a 100644 --- a/main/models.py +++ b/main/models.py @@ -1,3 +1,4 @@ +import locale from datetime import timedelta from functools import cached_property @@ -23,7 +24,10 @@ from wagtail.core.fields import RichTextField, StreamField from wagtail.core.models import Page from wagtailmetadata.models import MetadataPageMixin -from elections2021.constants import REGION_CHOICES # pozor, import ze sousedního modulu +from elections2021.constants import ( # pozor, import ze sousedního modulu + MONTH_NAMES, + REGION_CHOICES, +) from shared.const import RICH_TEXT_DEFAULT_FEATURES from shared.forms import SubscribeForm from shared.models import ( # MenuMixin, @@ -380,7 +384,7 @@ class MainArticlesPage( def get_empty_month_data(date_obj): return { "month_number": date_obj.month, - "month_text": date_obj.strftime("%B"), + "month_text": MONTH_NAMES[date_obj.month - 1], "left_column": [], "right_column": [], } -- GitLab