Skip to content

Commit

Permalink
Traduction des modèles Tag & Category (#1946)
Browse files Browse the repository at this point in the history
* Translate Tag model

* Translate Category model

* Translate filters. Update translation files
  • Loading branch information
raphodn authored Feb 22, 2023
1 parent 033c6af commit 63713fb
Show file tree
Hide file tree
Showing 14 changed files with 368 additions and 96 deletions.
13 changes: 7 additions & 6 deletions api/questions/filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import django_filters
from django.utils.translation import gettext_lazy as _

from categories.models import Category
from core import constants
Expand All @@ -7,22 +8,22 @@


class QuestionFilter(django_filters.FilterSet):
type = django_filters.MultipleChoiceFilter(label="Type(s) de question", choices=constants.QUESTION_TYPE_CHOICES)
type = django_filters.MultipleChoiceFilter(label=_("Type(s)"), choices=constants.QUESTION_TYPE_CHOICES)
difficulty = django_filters.MultipleChoiceFilter(
label="Niveau(x) de difficulté de la question",
label=_("Difficulty level(s)"),
choices=constants.QUESTION_DIFFICULTY_CHOICES,
)
language = django_filters.MultipleChoiceFilter(label="Langue(s)", choices=constants.LANGUAGE_CHOICES)
language = django_filters.MultipleChoiceFilter(label=_("Language(s)"), choices=constants.LANGUAGE_CHOICES)
category = django_filters.ModelMultipleChoiceFilter(
label="Catégorie(s)",
label=_("Category(s)"),
queryset=Category.objects.all(),
)
tags = django_filters.ModelMultipleChoiceFilter(
label="Tag(s)",
label=_("Tag(s)"),
queryset=Tag.objects.all(),
)
author = django_filters.ModelMultipleChoiceFilter(
label="Auteur(s)",
label=_("Author(s)"),
queryset=User.objects.all_contributors(),
)
# TODO: QuestionFullStringSerializer, random
7 changes: 4 additions & 3 deletions api/quizs/filters.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import django_filters
from django.utils.translation import gettext_lazy as _

from core import constants
from tags.models import Tag
from users.models import User


class QuizFilter(django_filters.FilterSet):
language = django_filters.MultipleChoiceFilter(label="Langue(s)", choices=constants.LANGUAGE_CHOICES)
language = django_filters.MultipleChoiceFilter(label=_("Language(s)"), choices=constants.LANGUAGE_CHOICES)
tags = django_filters.ModelMultipleChoiceFilter(
label="Tag(s)",
label=_("Tag(s)"),
queryset=Tag.objects.all(),
)
authors = django_filters.ModelMultipleChoiceFilter(
label="Auteur(s)",
label=_("Author(s)"),
queryset=User.objects.all_contributors(),
)
spotlight = django_filters.BooleanFilter()
Expand Down
38 changes: 38 additions & 0 deletions categories/migrations/0005_category_model_translation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 4.1.5 on 2023-02-22 18:52

import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("categories", "0004_alter_category_created"),
]

operations = [
migrations.AlterModelOptions(
name="category",
options={"ordering": ["pk"], "verbose_name": "Category", "verbose_name_plural": "Categories"},
),
migrations.AlterField(
model_name="category",
name="created",
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name="Creation date"),
),
migrations.AlterField(
model_name="category",
name="name",
field=models.CharField(max_length=50, verbose_name="Name"),
),
migrations.AlterField(
model_name="category",
name="name_long",
field=models.CharField(max_length=150, verbose_name="Name (long version)"),
),
migrations.AlterField(
model_name="category",
name="updated",
field=models.DateTimeField(auto_now=True, verbose_name="Last update date"),
),
]
17 changes: 9 additions & 8 deletions categories/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
from django.db import models
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext_lazy as _


class Category(models.Model):
CATEGORY_TIMESTAMP_FIELDS = ["created", "updated"]

name = models.CharField(verbose_name="Nom", max_length=50, blank=False)
name_long = models.CharField(verbose_name="Nom (version longue)", max_length=150, blank=False)
description = RichTextField(verbose_name="Description", blank=True)
name = models.CharField(verbose_name=_("Name"), max_length=50, blank=False)
name_long = models.CharField(verbose_name=_("Name (long version)"), max_length=150, blank=False)
description = RichTextField(verbose_name=_("Description"), blank=True)

created = models.DateTimeField(verbose_name="Date de création", default=timezone.now)
updated = models.DateTimeField(verbose_name="Date de dernière modification", auto_now=True)
created = models.DateTimeField(verbose_name=_("Creation date"), default=timezone.now)
updated = models.DateTimeField(verbose_name=_("Last update date"), auto_now=True)

class Meta:
verbose_name = "Catégorie"
verbose_name_plural = "Catégories"
verbose_name = _("Category")
verbose_name_plural = _("Categories")
ordering = ["pk"]
constraints = [models.UniqueConstraint(fields=["name"], name="category_name_unique")]

Expand All @@ -35,4 +36,4 @@ def question_public_validated_count(self) -> int:
return self.questions.public().validated().count()

# Admin
question_public_validated_count.fget.short_description = "Questions (publiques & validées)"
question_public_validated_count.fget.short_description = _("Questions (public & validated)")
110 changes: 78 additions & 32 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-22 19:14+0100\n"
"POT-Creation-Date: 2023-02-22 20:16+0100\n"
"PO-Revision-Date: 2023-02-12 20:12+0100\n"
"Last-Translator: Didier Quirin <[email protected]>\n"
"Language-Team: \n"
Expand All @@ -19,6 +19,30 @@ msgstr ""
"X-Generator: Poedit 3.2.2\n"
"X-Translated-Using: django-rosetta 0.9.8\n"

#: api/questions/filters.py:11
msgid "Type(s)"
msgstr ""

#: api/questions/filters.py:13
msgid "Difficulty level(s)"
msgstr ""

#: api/questions/filters.py:16 api/quizs/filters.py:10
msgid "Language(s)"
msgstr ""

#: api/questions/filters.py:18
msgid "Category(s)"
msgstr ""

#: api/questions/filters.py:22 api/quizs/filters.py:12
msgid "Tag(s)"
msgstr ""

#: api/questions/filters.py:26 api/quizs/filters.py:16
msgid "Author(s)"
msgstr ""

#: app/settings.py:179 core/constants.py:117
msgid "English"
msgstr ""
Expand All @@ -39,6 +63,46 @@ msgstr ""
msgid "German"
msgstr ""

#: categories/models.py:11 quizs/models.py:88 tags/models.py:26
msgid "Name"
msgstr ""

#: categories/models.py:12
msgid "Name (long version)"
msgstr ""

#: categories/models.py:13 tags/models.py:27
msgid "Description"
msgstr ""

#: categories/models.py:15 questions/models.py:233 quizs/models.py:159
#: quizs/models.py:437 quizs/models.py:500 quizs/models.py:560
#: tags/models.py:29
msgid "Creation date"
msgstr ""

#: categories/models.py:16 questions/models.py:234 quizs/models.py:160
#: quizs/models.py:438 quizs/models.py:501 quizs/models.py:561
#: tags/models.py:30
msgid "Last update date"
msgstr ""

#: categories/models.py:19 questions/models.py:109 questions/models.py:237
#: templates/categories/detail_base.html:4
#: templates/categories/detail_questions.html:13
#: templates/tags/detail_questions.html:13
msgid "Category"
msgstr ""

#: categories/models.py:20 templates/categories/detail_base.html:13
#: templates/categories/list.html:5 templates/categories/list.html:14
msgid "Categories"
msgstr ""

#: categories/models.py:39 tags/models.py:63
msgid "Questions (public & validated)"
msgstr ""

#: contributions/forms.py:53
msgid "Message"
msgstr ""
Expand Down Expand Up @@ -115,6 +179,10 @@ msgstr ""
msgid "False"
msgstr ""

#: questions/filters.py:14 quizs/filters.py:17 tags/filters.py:10
msgid "Text search"
msgstr ""

#: questions/forms.py:33
msgid "Answer image"
msgstr ""
Expand All @@ -139,16 +207,9 @@ msgstr ""
msgid "Type"
msgstr ""

#: questions/models.py:109 questions/models.py:237
#: templates/categories/detail_base.html:4
#: templates/categories/detail_questions.html:13
#: templates/tags/detail_questions.html:13
msgid "Category"
msgstr ""

#: questions/models.py:117 questions/models.py:238 questions/models.py:358
#: quizs/models.py:102 quizs/models.py:166 quizs/models.py:369
#: templates/categories/detail_questions.html:14
#: tags/models.py:36 templates/categories/detail_questions.html:14
#: templates/includes/_header.html:35 templates/tags/create.html:17
#: templates/tags/detail_base.html:13 templates/tags/detail_questions.html:14
#: templates/tags/detail_quizs.html:13 templates/tags/list.html:14
Expand Down Expand Up @@ -281,16 +342,6 @@ msgstr ""
msgid "Visibility"
msgstr ""

#: questions/models.py:233 quizs/models.py:159 quizs/models.py:437
#: quizs/models.py:500 quizs/models.py:560
msgid "Creation date"
msgstr ""

#: questions/models.py:234 quizs/models.py:160 quizs/models.py:438
#: quizs/models.py:501 quizs/models.py:561
msgid "Last update date"
msgstr ""

#: questions/models.py:239 questions/models.py:359 quizs/models.py:181
#: templates/includes/_header.html:29 templates/questions/detail_base.html:34
#: templates/quizs/create.html:4 templates/quizs/create.html:18
Expand Down Expand Up @@ -338,10 +389,6 @@ msgstr ""
msgid "Quiz background image"
msgstr ""

#: quizs/models.py:88
msgid "Name"
msgstr ""

#: quizs/models.py:89
msgid "Slug"
msgstr ""
Expand Down Expand Up @@ -432,6 +479,14 @@ msgstr ""
msgid "Relationship type"
msgstr ""

#: tags/models.py:35 templates/tags/detail_base.html:4
msgid "Tag"
msgstr ""

#: tags/models.py:64
msgid "Quizs (public & published)"
msgstr ""

#: templates/403.html:4 templates/404.html:4 templates/404.html:10
#: templates/500.html:4 templates/500.html:10
msgid "Error"
Expand Down Expand Up @@ -527,11 +582,6 @@ msgstr ""
msgid "View"
msgstr ""

#: templates/categories/detail_base.html:13 templates/categories/list.html:5
#: templates/categories/list.html:14
msgid "Categories"
msgstr ""

#: templates/categories/detail_base.html:28
#: templates/contributions/detail_base.html:33
#: templates/glossary/detail_base.html:28
Expand Down Expand Up @@ -906,7 +956,3 @@ msgstr ""
#: templates/quizs/detail_edit.html:72
msgid "The quiz is published even though it is not validated"
msgstr ""

#: templates/tags/detail_base.html:4
msgid "Tag"
msgstr ""
Binary file modified locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 63713fb

Please sign in to comment.