Skip to content

Commit

Permalink
Translate event properties. Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Mar 9, 2023
1 parent 4ad3c24 commit 17868b8
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 29 deletions.
73 changes: 50 additions & 23 deletions activity/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,45 +89,72 @@ def get_event_object_admin_absolute_url(self):

@property
def display_html(self) -> str:
if self.event_object_type in ["QUESTION", "QUIZ"]:
if self.event_object_type == "QUESTION":
# Prénom Nom a créé la question 'Question'
return self.display_question_quiz_with_admin_url_html
elif self.event_object_type in ["USER"]:
return self.display_question_with_admin_url_html
elif self.event_object_type == "QUIZ":
return self.display_quiz_with_admin_url_html
elif self.event_object_type == "USER":
return self.display_new_user_html

@property
def display_question_quiz_html(self) -> str:
def display_question_html(self) -> str:
"""
💡 <i>Prénom Nom</i> a créé la question <strong>test</strong>
💡 <i>Prénom Nom</i> created the question <strong>test</strong>
"""
return (
f"{self.display_event_emoji} "
f"<i>{self.actor_name}</i> a {self.get_event_verb_display().lower()} "
f"{self.display_event_object_type_prefix} {self.get_event_object_type_display().lower()} "
f"<strong>{self.event_object_name}</strong>"
html_message = _("<i>{actor_name}</i> {event_verb} the question <strong>{question_name}</strong>").format(
actor_name=self.actor_name,
event_verb=self.get_event_verb_display().lower(),
question_name=self.event_object_name,
)
return f"{self.display_event_emoji} {html_message}"

@property
def display_question_quiz_with_admin_url_html(self) -> str:
def display_quiz_html(self) -> str:
"""
💡 <i>Prénom Nom</i> a créé la question <a href="/questions/<id>/view/">test</a>
💡 <i>Prénom Nom</i> created the quiz <strong>test</strong>
"""
return (
f"{self.display_event_emoji} "
f"<i>{self.actor_name}</i> a {self.get_event_verb_display().lower()} "
f"{self.display_event_object_type_prefix} {self.get_event_object_type_display().lower()} "
f'<a href="{self.get_event_object_admin_absolute_url}">{self.event_object_name}</a>'
html_message = _("<i>{actor_name}</i> {event_verb} the quiz <strong>{quiz_name}</strong>").format(
actor_name=self.actor_name,
event_verb=self.get_event_verb_display().lower(),
quiz_name=self.event_object_name,
)
return f"{self.display_event_emoji} {html_message}"

@property
def display_new_user_html(self) -> str:
return f"{self.display_event_emoji} Nouveau contributeur ! <strong>{self.event_object_name}</strong>"
def display_question_with_admin_url_html(self) -> str:
"""
💡 <i>Prénom Nom</i> created the question <a href="/questions/<id>/view/">test</a>
"""
html_message = _(
'<i>{actor_name}</i> {event_verb} the question <a href="{question_admin_absolute_url}">{question_name}</a>'
).format(
actor_name=self.actor_name,
event_verb=self.get_event_verb_display().lower(),
question_name=self.event_object_name,
question_admin_absolute_url=self.get_event_object_admin_absolute_url,
)
return f"{self.display_event_emoji} {html_message}"

@property
def display_event_object_type_prefix(self) -> str:
if self.event_object_type in ["QUESTION"]:
return "la"
return "le"
def display_quiz_with_admin_url_html(self) -> str:
"""
💡 <i>Prénom Nom</i> created the quiz <a href="/quizs/<id>/view/">test</a>
"""
html_message = _(
'<i>{actor_name}</i> {event_verb} the quiz <a href="{quiz_admin_absolute_url}">{quiz_name}</a>'
).format(
actor_name=self.actor_name,
event_verb=self.get_event_verb_display().lower(),
quiz_name=self.event_object_name,
quiz_admin_absolute_url=self.get_event_object_admin_absolute_url,
)
return f"{self.display_event_emoji} {html_message}"

@property
def display_new_user_html(self) -> str:
html_message = _("New contributor! <i>{user_name}</i>").format(user_name=self.event_object_name)
return f"{self.display_event_emoji} {html_message}"

@property
def display_event_emoji(self):
Expand Down
33 changes: 32 additions & 1 deletion locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-24 20:46+0100\n"
"POT-Creation-Date: 2023-03-09 12:12+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -102,6 +102,37 @@ msgstr ""
msgid "Events"
msgstr ""

#: activity/models.py:105
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the question <strong>{question_name}</"
"strong>"
msgstr ""

#: activity/models.py:117
#, python-brace-format
msgid "<i>{actor_name}</i> {event_verb} the quiz <strong>{quiz_name}</strong>"
msgstr ""

#: activity/models.py:130
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the question <a "
"href=\"{question_admin_absolute_url}\">{question_name}</a>"
msgstr ""

#: activity/models.py:145
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the quiz <a "
"href=\"{quiz_admin_absolute_url}\">{quiz_name}</a>"
msgstr ""

#: activity/models.py:156
#, python-brace-format
msgid "New contributor! <i>{user_name}</i>"
msgstr ""

#: api/glossary/filters.py:8 api/questions/filters.py:16
#: api/quizs/filters.py:10
msgid "Language(s)"
Expand Down
33 changes: 32 additions & 1 deletion 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-24 20:46+0100\n"
"POT-Creation-Date: 2023-03-09 12:12+0100\n"
"PO-Revision-Date: 2023-02-12 20:12+0100\n"
"Last-Translator: Didier Quirin <[email protected]>\n"
"Language-Team: \n"
Expand Down Expand Up @@ -103,6 +103,37 @@ msgstr ""
msgid "Events"
msgstr ""

#: activity/models.py:105
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the question <strong>{question_name}</"
"strong>"
msgstr ""

#: activity/models.py:117
#, python-brace-format
msgid "<i>{actor_name}</i> {event_verb} the quiz <strong>{quiz_name}</strong>"
msgstr ""

#: activity/models.py:130
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the question <a "
"href=\"{question_admin_absolute_url}\">{question_name}</a>"
msgstr ""

#: activity/models.py:145
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the quiz <a "
"href=\"{quiz_admin_absolute_url}\">{quiz_name}</a>"
msgstr ""

#: activity/models.py:156
#, python-brace-format
msgid "New contributor! <i>{user_name}</i>"
msgstr ""

#: api/glossary/filters.py:8 api/questions/filters.py:16
#: api/quizs/filters.py:10
msgid "Language(s)"
Expand Down
33 changes: 32 additions & 1 deletion locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-24 20:46+0100\n"
"POT-Creation-Date: 2023-03-09 12:12+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -102,6 +102,37 @@ msgstr ""
msgid "Events"
msgstr ""

#: activity/models.py:105
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the question <strong>{question_name}</"
"strong>"
msgstr ""

#: activity/models.py:117
#, python-brace-format
msgid "<i>{actor_name}</i> {event_verb} the quiz <strong>{quiz_name}</strong>"
msgstr ""

#: activity/models.py:130
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the question <a "
"href=\"{question_admin_absolute_url}\">{question_name}</a>"
msgstr ""

#: activity/models.py:145
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the quiz <a "
"href=\"{quiz_admin_absolute_url}\">{quiz_name}</a>"
msgstr ""

#: activity/models.py:156
#, python-brace-format
msgid "New contributor! <i>{user_name}</i>"
msgstr ""

#: api/glossary/filters.py:8 api/questions/filters.py:16
#: api/quizs/filters.py:10
msgid "Language(s)"
Expand Down
Binary file modified locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
42 changes: 40 additions & 2 deletions locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-24 20:46+0100\n"
"PO-Revision-Date: 2023-02-24 20:49+0100\n"
"POT-Creation-Date: 2023-03-09 12:13+0100\n"
"PO-Revision-Date: 2023-03-09 12:15+0100\n"
"Last-Translator: Didier Quirin <[email protected]>\n"
"Language-Team: \n"
"Language: fr\n"
Expand Down Expand Up @@ -103,6 +103,44 @@ msgstr "Événement"
msgid "Events"
msgstr "Événements"

#: activity/models.py:105
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the question <strong>{question_name}</"
"strong>"
msgstr ""
"<i>{actor_name}</i> a {event_verb} la question <strong>{question_name}</"
"strong>"

#: activity/models.py:117
#, python-brace-format
msgid "<i>{actor_name}</i> {event_verb} the quiz <strong>{quiz_name}</strong>"
msgstr ""
"<i>{actor_name}</i> a {event_verb} le quiz <strong>{quiz_name}</strong>"

#: activity/models.py:130
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the question <a href="
"\"{question_admin_absolute_url}\">{question_name}</a>"
msgstr ""
"<i>{actor_name}</i> a {event_verb} la question <a href="
"\"{question_admin_absolute_url}\">{question_name}</a>"

#: activity/models.py:145
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the quiz <a href="
"\"{quiz_admin_absolute_url}\">{quiz_name}</a>"
msgstr ""
"<i>{actor_name}</i> a {event_verb} le quiz <a href="
"\"{quiz_admin_absolute_url}\">{quiz_name}</a>"

#: activity/models.py:156
#, python-brace-format
msgid "New contributor! <i>{user_name}</i>"
msgstr "Nouveau contributeur ! <i>{user_name}</i>"

#: api/glossary/filters.py:8 api/questions/filters.py:16
#: api/quizs/filters.py:10
msgid "Language(s)"
Expand Down
33 changes: 32 additions & 1 deletion locale/it/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-24 20:46+0100\n"
"POT-Creation-Date: 2023-03-09 12:12+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -102,6 +102,37 @@ msgstr ""
msgid "Events"
msgstr ""

#: activity/models.py:105
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the question <strong>{question_name}</"
"strong>"
msgstr ""

#: activity/models.py:117
#, python-brace-format
msgid "<i>{actor_name}</i> {event_verb} the quiz <strong>{quiz_name}</strong>"
msgstr ""

#: activity/models.py:130
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the question <a "
"href=\"{question_admin_absolute_url}\">{question_name}</a>"
msgstr ""

#: activity/models.py:145
#, python-brace-format
msgid ""
"<i>{actor_name}</i> {event_verb} the quiz <a "
"href=\"{quiz_admin_absolute_url}\">{quiz_name}</a>"
msgstr ""

#: activity/models.py:156
#, python-brace-format
msgid "New contributor! <i>{user_name}</i>"
msgstr ""

#: api/glossary/filters.py:8 api/questions/filters.py:16
#: api/quizs/filters.py:10
msgid "Language(s)"
Expand Down

0 comments on commit 17868b8

Please sign in to comment.