Translate notifications
This commit is contained in:
parent
bc011e47be
commit
5b01a68cdb
|
|
@ -1,6 +1,5 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from gettext import gettext
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
|
|
@ -33,9 +32,12 @@ class NotificationService:
|
||||||
def send_assignment_submitted_notification(
|
def send_assignment_submitted_notification(
|
||||||
cls, recipient: User, sender: User, assignment_completion: AssignmentCompletion
|
cls, recipient: User, sender: User, assignment_completion: AssignmentCompletion
|
||||||
):
|
):
|
||||||
verb = gettext(
|
texts = {
|
||||||
"%(sender)s hat die geleitete Fallarbeit «%(assignment_title)s» abgegeben."
|
"de": "%(sender)s hat die geleitete Fallarbeit «%(assignment_title)s» abgegeben.",
|
||||||
) % {
|
"fr": "%(sender)s a soumis l'étude de cas dirigée «%(assignment_title)s».",
|
||||||
|
"it": "%(sender)s ha consegnato il caso di studio guidato «%(assignment_title)s».",
|
||||||
|
}
|
||||||
|
verb = texts.get(recipient.language, "de") % {
|
||||||
"sender": sender.get_full_name(),
|
"sender": sender.get_full_name(),
|
||||||
"assignment_title": assignment_completion.assignment.title,
|
"assignment_title": assignment_completion.assignment.title,
|
||||||
}
|
}
|
||||||
|
|
@ -60,9 +62,12 @@ class NotificationService:
|
||||||
assignment_completion: AssignmentCompletion,
|
assignment_completion: AssignmentCompletion,
|
||||||
target_url: str,
|
target_url: str,
|
||||||
):
|
):
|
||||||
verb = gettext(
|
texts = {
|
||||||
"%(sender)s hat die geleitete Fallarbeit «%(assignment_title)s» bewertet."
|
"de": "%(sender)s hat die geleitete Fallarbeit «%(assignment_title)s» bewertet.",
|
||||||
) % {
|
"fr": "%(sender)s a évalué l'étude de cas dirigée «%(assignment_title)s».",
|
||||||
|
"it": "%(sender)s ha valutato il caso di studio guidato «%(assignment_title)s».",
|
||||||
|
}
|
||||||
|
verb = texts.get(recipient.language, "de") % {
|
||||||
"sender": sender.get_full_name(),
|
"sender": sender.get_full_name(),
|
||||||
"assignment_title": assignment_completion.assignment.title,
|
"assignment_title": assignment_completion.assignment.title,
|
||||||
}
|
}
|
||||||
|
|
@ -85,7 +90,14 @@ class NotificationService:
|
||||||
recipient: User,
|
recipient: User,
|
||||||
feedback_response: FeedbackResponse,
|
feedback_response: FeedbackResponse,
|
||||||
):
|
):
|
||||||
verb = f"New feedback for circle {feedback_response.circle.title}"
|
texts = {
|
||||||
|
"de": "Feedback abgeschickt für Circle «%(circle_title)s»",
|
||||||
|
"fr": "Feedback envoyé pour le cercle «%(circle_title)s»",
|
||||||
|
"it": "Feedback inviato per il cerchio «%(circle_title)s»",
|
||||||
|
}
|
||||||
|
verb = texts.get(recipient.language, "de") % {
|
||||||
|
"circle_title": feedback_response.circle.title,
|
||||||
|
}
|
||||||
|
|
||||||
return cls._send_notification(
|
return cls._send_notification(
|
||||||
recipient=recipient,
|
recipient=recipient,
|
||||||
|
|
@ -104,9 +116,16 @@ class NotificationService:
|
||||||
recipient: User,
|
recipient: User,
|
||||||
attendance_course: CourseSessionAttendanceCourse,
|
attendance_course: CourseSessionAttendanceCourse,
|
||||||
):
|
):
|
||||||
|
texts = {
|
||||||
|
"de": "Erinnerung: Bald findet ein Präsenzkurs statt",
|
||||||
|
"fr": "Rappel: Un cours de présence aura lieu bientôt.",
|
||||||
|
"it": "Promemoria: Un corso di presenza avrà luogo presto.",
|
||||||
|
}
|
||||||
|
verb = texts.get(recipient.language, "de")
|
||||||
|
|
||||||
return cls._send_notification(
|
return cls._send_notification(
|
||||||
recipient=recipient,
|
recipient=recipient,
|
||||||
verb="Erinnerung: Bald findet ein Präsenzkurs statt",
|
verb=verb,
|
||||||
notification_category=NotificationCategory.INFORMATION,
|
notification_category=NotificationCategory.INFORMATION,
|
||||||
notification_trigger=NotificationTrigger.ATTENDANCE_COURSE_REMINDER,
|
notification_trigger=NotificationTrigger.ATTENDANCE_COURSE_REMINDER,
|
||||||
target_url=attendance_course.learning_content.get_frontend_url(),
|
target_url=attendance_course.learning_content.get_frontend_url(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue