fix: affichage des dates en français via filtre Jinja2 date_fr

This commit is contained in:
2026-03-11 18:34:36 +01:00
parent b6d5754c98
commit 9e40c7b876
3 changed files with 16 additions and 2 deletions

View File

@@ -31,6 +31,19 @@ def _migrate_db(app):
conn.commit() conn.commit()
_JOURS_FR = ["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"]
_MOIS_FR = ["", "janvier", "février", "mars", "avril", "mai", "juin",
"juillet", "août", "septembre", "octobre", "novembre", "décembre"]
def _date_fr(d):
"""Formate une date en français : 'mercredi 11 mars 2026'."""
from datetime import date as date_type
jour = _JOURS_FR[d.weekday()]
mois = _MOIS_FR[d.month]
return f"{jour} {d.day} {mois} {d.year}"
def create_app(config_path=None): def create_app(config_path=None):
app = Flask(__name__, instance_relative_config=True) app = Flask(__name__, instance_relative_config=True)
@@ -50,6 +63,7 @@ def create_app(config_path=None):
app.config["TOML"] = {} app.config["TOML"] = {}
db.init_app(app) db.init_app(app)
app.jinja_env.filters["date_fr"] = _date_fr
from app.routes.dashboard import bp as dashboard_bp from app.routes.dashboard import bp as dashboard_bp
from app.routes.entries import bp as entries_bp from app.routes.entries import bp as entries_bp

View File

@@ -4,7 +4,7 @@
<div class="bg-white rounded-xl shadow p-4 mb-4"> <div class="bg-white rounded-xl shadow p-4 mb-4">
<h2 class="font-semibold text-gray-700 mb-2"> <h2 class="font-semibold text-gray-700 mb-2">
Aujourd'hui — {{ today.strftime('%A %d %B %Y') }} Aujourd'hui — {{ today | date_fr }}
</h2> </h2>
{% if today_entry %} {% if today_entry %}
<p class="text-green-700 font-medium">{{ today_entry.day_type }} — {{ today_entry.total_hours_str() }}</p> <p class="text-green-700 font-medium">{{ today_entry.day_type }} — {{ today_entry.total_hours_str() }}</p>

View File

@@ -12,7 +12,7 @@
{% for entry in entries %} {% for entry in entries %}
<div class="bg-white rounded-xl shadow p-3 flex items-center justify-between"> <div class="bg-white rounded-xl shadow p-3 flex items-center justify-between">
<div> <div>
<p class="font-medium text-sm">{{ entry.date.strftime('%a %d %b %Y') }}</p> <p class="font-medium text-sm">{{ entry.date | date_fr }}</p>
<p class="text-xs text-gray-500"> <p class="text-xs text-gray-500">
{{ entry.day_type }} {{ entry.day_type }}
{% if entry.time_slots %} — {{ entry.total_hours_str() }}{% endif %} {% if entry.time_slots %} — {{ entry.total_hours_str() }}{% endif %}