La langue est prise en compte, traduction fonctionnelle

This commit is contained in:
Jean-Marie Favreau 2023-10-29 20:19:50 +01:00
parent 99ab55d48b
commit 8cdb578277
5 changed files with 35 additions and 149 deletions

View File

@ -1,134 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-14 15:29+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: agenda_culturel/models.py:15
msgid "Published"
msgstr "Publié"
#: agenda_culturel/models.py:16
msgid "Trash"
msgstr "Corbeille"
#: agenda_culturel/models.py:17
msgid "Draft"
msgstr "Brouillon"
#: agenda_culturel/models.py:24
msgid "Title"
msgstr "Titre"
#: agenda_culturel/models.py:24
msgid "Short title"
msgstr "Titre court"
#: agenda_culturel/models.py:26
msgid "Status"
msgstr "Status"
#: agenda_culturel/models.py:28
msgid "Day of the event"
msgstr "Date de l'événement"
#: agenda_culturel/models.py:29
msgid "Starting time"
msgstr "Heure de début"
#: agenda_culturel/models.py:31
msgid "End day of the event"
msgstr "Fin de l'événement"
#: agenda_culturel/models.py:31
msgid "End day of the event, only required if different from the start day."
msgstr ""
"Date de fin de l'événement, uniquement nécessaire s'il est différent du "
"premier jour de l'événement"
#: agenda_culturel/models.py:32
msgid "Final time"
msgstr "Heure de fin"
#: agenda_culturel/models.py:34
msgid "Location"
msgstr "Localisation"
#: agenda_culturel/models.py:34
msgid "Address of the event"
msgstr "Adresse de l'événement"
#: agenda_culturel/models.py:36
msgid "Description"
msgstr "Description"
#: agenda_culturel/models.py:36
msgid "General description of the event"
msgstr "Description générale de l'événement"
#: agenda_culturel/models.py:38
msgid "Illustration"
msgstr "Illustration"
#: agenda_culturel/models.py:38
msgid "URL of the illustration image"
msgstr "URL de l'image illustrative"
#: agenda_culturel/models.py:39
msgid "Illustration description"
msgstr "Description de l'illustration"
#: agenda_culturel/models.py:39
msgid "Alternative text used by screen readers for the image"
msgstr "Texte alternatif utiliser par les lecteurs d'écrans pour l'image"
#: agenda_culturel/models.py:41
msgid "URLs"
msgstr "URLs"
#: agenda_culturel/models.py:41
msgid "List of all the urls where this event can be found."
msgstr "Liste de toutes les urls où l'événement peut être trouvé."
#: agenda_culturel/models.py:55
msgid "Event"
msgstr "Événement"
#: agenda_culturel/models.py:56
msgid "Events"
msgstr "Événements"
#: agenda_culturel/views.py:11
msgid "this_week"
msgstr "cette_semaine"
#: agenda_culturel/views.py:12
msgid "this_weekend"
msgstr "ce_weekend"
#: agenda_culturel/views.py:13
msgid "next_week"
msgstr "semaine_prochaine"
#: agenda_culturel/views.py:14
msgid "this_month"
msgstr "ce_mois_ci"
#: agenda_culturel/views.py:15
#, fuzzy
#| msgid "next_mont"
msgid "next_month"
msgstr "mois_prochain"

View File

@ -1,5 +1,6 @@
from os import getenv as os_getenv, path as os_path # noqa
from pathlib import Path
from django.utils.translation import gettext_lazy as _
from django.core.management.utils import get_random_secret_key
@ -45,6 +46,7 @@ MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
'django.middleware.locale.LocaleMiddleware',
"corsheaders.middleware.CorsMiddleware", # CorsMiddleware should be placed as high as possible,
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
@ -108,7 +110,7 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
LANGUAGE_CODE = "fr-fr"
LANGUAGE_CODE = "fr"
TIME_ZONE = "Europe/Paris"
@ -116,6 +118,12 @@ USE_I18N = True
USE_TZ = True
LANGUAGES = (
('en-us', _('English')),
('fr', _('French')),
)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

View File

@ -1,5 +1,9 @@
{% extends "agenda_culturel/page.html" %}
{% load i18n %}
{% load cat_extra %}
{% block entete_header %}
@ -10,7 +14,7 @@
<header>
<div id="display-mode" class="nav-buttons">
{% for mode in modes %}
{% if selected_mode == mode.name %}
{% if selected_mode.name == mode.name %}
<span class="mode selected">{{ mode }}</span>
{% else %}
{% if category %}
@ -24,15 +28,17 @@
<div id="categories" class="nav-buttons">
{% for cat in categories %}
{% if category == cat %}
<span class="cat {{ cat.css_class }} selected">{{ cat }} <a href="{% url 'view_mode' selected_mode %}" class="close"></a></span>
<span class="cat {{ cat.css_class }} selected">{{ cat }} <a href="{% url 'view_mode' selected_mode.name %}" class="close"></a></span>
{% else %}
<a href="{% url 'view_mode_cat' selected_mode cat.pk %}" class="cat {{ cat.css_class }} {% if category == None %}selected{% endif %}">{{ cat }}</a>
<a href="{% url 'view_mode_cat' selected_mode.name cat.pk %}" class="cat {{ cat.css_class }} {% if category == None %}selected{% endif %}">{{ cat }}</a>
{% endif %}
{% endfor %}
</div>
</header>
<section>
{% block events %}{% endblock %}
{% block events %}
<h2>{{ selected_mode | capfirst }}</h2>
{% endblock %}
</section>
<footer id="tags">
TODO

View File

@ -21,7 +21,7 @@
<body>
<div id="full_content" class="{% block main_class %}{% endblock %}">
<header>
<h1>Les nuits électromagmatiques</h1>
<h1>Les nuits énigmagmatiques</h1>
<div role="doc-subtitle">Agenda culturel de Clermont-Ferrand et des environs</div>
</header>
<section>

View File

@ -9,17 +9,19 @@ from django.utils import timezone
from enum import StrEnum
from datetime import datetime, timedelta
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _
from django.utils.translation import activate, get_language_info
class DisplayMode(StrEnum):
this_week = _("this week")
this_weekend = _("this weekend")
next_week = _("next week")
next_weekend = _("next weekend")
this_month = _("this month")
next_month = _("next month")
this_week = "this week"
this_weekend = "this weekend"
next_week = "next week"
next_weekend = "next weekend"
this_month = "this month"
next_month = "next month"
def i18n_value(self):
return _(self.value)
def get_dates(self):
now = datetime.now()
@ -44,6 +46,9 @@ class DisplayMode(StrEnum):
delta = end - start
return [start + timedelta(days=x) for x in range(0, delta.days + 1)]
def __str__(self):
return str(self.i18n_value())
def home(request):
# TODO: si on est au début de la semaine, on affiche la semaine en entier
@ -55,7 +60,8 @@ def home(request):
def view_mode(request, mode):
categories = Category.objects.all()
dates = DisplayMode[mode].get_dates()
context = {"modes": list(DisplayMode), "selected_mode": mode, "categories": categories }
activate("fr")
context = {"modes": list(DisplayMode), "selected_mode": DisplayMode[mode], "categories": categories }
# TODO: select matching events
return render(request, 'agenda_culturel/page-events.html', context)