Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I18n api #59

Merged
merged 41 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d2e2e2f
chore: translation of extensions allowed/forbidden fields #27
bsilkyn Mar 7, 2024
7c6fa12
Merge branch 'development' into i18n-api
bsilkyn Mar 7, 2024
22b7e32
chore: translate 404 errors to dutch #57
bsilkyn Mar 7, 2024
bfa13d4
chore: rebase
bsilkyn Mar 7, 2024
d66ecc5
chore: (Dutch) folder structure helper + course serializer + group se…
bsilkyn Mar 12, 2024
545a858
chore: (Dutch) folder structure helper + course serializer + group se…
bsilkyn Mar 12, 2024
ead419c
test: make authentication test names more professional
bsilkyn Mar 12, 2024
543903f
chore: add available language translations #100
bsilkyn Mar 12, 2024
4674614
chore: course_view dutch translation + adaption to translation keys #100
bsilkyn Mar 12, 2024
d5b865e
chore: group_view and project_view Dutch translation #100
bsilkyn Mar 12, 2024
90db265
chore: remote merge #100
bsilkyn Mar 12, 2024
9fde752
chore: English translation zip checks + course_serializer + group_ser…
bsilkyn Mar 13, 2024
174ddff
chore: English translation project_serializer #100
bsilkyn Mar 13, 2024
8b65cd7
chore: English translation course_view + group_view + project_view #100
bsilkyn Mar 13, 2024
c773823
chore: slight adjustments #100
bsilkyn Mar 13, 2024
dfda4a4
chore: adjustment to courses.error.students.past_course #100
bsilkyn Mar 13, 2024
7de8329
chore: adjustment to group.errors.full translation #100
bsilkyn Mar 13, 2024
6f434a7
chore: translation remove spelling mistakes #100
bsilkyn Mar 13, 2024
0bcefb8
chore: rebase
bsilkyn Mar 7, 2024
096cfa1
chore: (Dutch) folder structure helper + course serializer + group se…
bsilkyn Mar 12, 2024
42fd593
chore: (Dutch) folder structure helper + course serializer + group se…
bsilkyn Mar 12, 2024
d140174
test: make authentication test names more professional
bsilkyn Mar 12, 2024
33734ad
chore: add available language translations #100
bsilkyn Mar 12, 2024
6ac3a1e
chore: course_view dutch translation + adaption to translation keys #100
bsilkyn Mar 12, 2024
c5e43bd
chore: group_view and project_view Dutch translation #100
bsilkyn Mar 12, 2024
964e9bb
chore: another rebase #57
bsilkyn Mar 7, 2024
6502aa4
chore: English translation zip checks + course_serializer + group_ser…
bsilkyn Mar 13, 2024
b707646
chore: English translation project_serializer #100
bsilkyn Mar 13, 2024
c04a8fd
chore: English translation course_view + group_view + project_view #100
bsilkyn Mar 13, 2024
6095adf
chore: slight adjustments #100
bsilkyn Mar 13, 2024
1bc43c2
chore: adjustment to courses.error.students.past_course #100
bsilkyn Mar 13, 2024
f7a71cb
chore: adjustment to group.errors.full translation #100
bsilkyn Mar 13, 2024
b113fd9
chore: translation remove spelling mistakes #100
bsilkyn Mar 13, 2024
db3e97a
test: add little test #100
bsilkyn Mar 13, 2024
90cb281
Merge branch 'i18n-api' of gitsel2:SELab-2/UGent-7 into i18n-api
bsilkyn Mar 13, 2024
158043a
chore: fix for tests and linter #100
bsilkyn Mar 13, 2024
3bb0483
build: compile .po files
francisvaut Mar 13, 2024
4c27fba
test: fix test to be solely dependent on translation key, not transla…
bsilkyn Mar 13, 2024
a8c6635
Merge branch 'development' into i18n-api
bsilkyn Mar 13, 2024
7555246
chore: translate extra translation keys from project logic #100
bsilkyn Mar 13, 2024
2b0b035
fix: backend-tests.yaml
francisvaut Mar 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/backend-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ jobs:
python -m pip install --upgrade pip
pip install flake8
pip install -r ./backend/requirements.txt
- name: Compile translations
run: django-admin compilemessages
- name: Execute tests
run: cd backend; python manage.py test
148 changes: 148 additions & 0 deletions backend/api/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# 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: 2024-03-13 23: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"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: helpers/check_folder_structure.py:141
msgid "zip.errors.invalid_structure.blocked_extension_found"
msgstr "The submitted zip file contains a file with a non-allowed extension."

#: helpers/check_folder_structure.py:145 helpers/check_folder_structure.py:196
msgid "zip.success"
msgstr "The submitted zip file succeeds in all checks."

#: helpers/check_folder_structure.py:148
msgid "zip.errors.invalid_structure.obligated_extension_not_found"
msgstr ""
"The submitted zip file doesn't have any file with a certain file extension "
"that's obligated."

#: helpers/check_folder_structure.py:175
msgid "zip.errors.invalid_structure.directory_not_defined"
msgstr "An obligated directory was not found in the submitted zip file."

#: helpers/check_folder_structure.py:195
msgid "zip.errors.invalid_structure.directory_not_found_in_template"
msgstr ""
"There was a directory found in the submitted zip file, which was not asked "
"for."

#: serializers/course_serializer.py:58 serializers/course_serializer.py:77
msgid "courses.error.context"
msgstr "The course is not supplied in the context."

#: serializers/course_serializer.py:64 tests/test_locale.py:28
#: tests/test_locale.py:38
msgid "courses.error.students.already_present"
msgstr "The student is already present in the course."

#: serializers/course_serializer.py:68 serializers/course_serializer.py:87
msgid "courses.error.students.past_course"
msgstr "The course is from a past year, thus cannot be manipulated."

#: serializers/course_serializer.py:83
msgid "courses.error.students.not_present"
msgstr "The student is not present in the course."

#: serializers/group_serializer.py:47
msgid "group.errors.score_exceeds_max"
msgstr "The score exceeds the group's max score."

#: serializers/group_serializer.py:57 serializers/group_serializer.py:87
msgid "group.error.context"
msgstr "The group is not supplied in the context."

#: serializers/group_serializer.py:65 serializers/group_serializer.py:99
msgid "group.errors.locked"
msgstr "The group is currently locked."

#: serializers/group_serializer.py:69
msgid "group.errors.full"
msgstr "The group is already full."

#: serializers/group_serializer.py:73
msgid "group.errors.not_in_course"
msgstr "The student is not present in the related course."

#: serializers/group_serializer.py:77
msgid "group.errors.already_in_group"
msgstr "The student is already in the group."

#: serializers/group_serializer.py:95
msgid "group.errors.not_present"
msgstr "The student is currently not in the group."

#: serializers/project_serializer.py:56
msgid "project.errors.context"
msgstr "The project is not supplied in the context."

#: serializers/project_serializer.py:60
msgid "project.errors.start_date_in_past"
msgstr "The start date of the project lies in the past."

#: serializers/project_serializer.py:64
msgid "project.errors.deadline_before_start_date"
msgstr "The deadline of the project lies before the start date of the project."

#: serializers/project_serializer.py:89
msgid "project.error.submissions.past_project"
msgstr "The deadline of the project has already passed."

#: serializers/project_serializer.py:92
msgid "project.error.submissions.non_visible_project"
msgstr "The project is currently in a non-visible state."

#: serializers/project_serializer.py:95
msgid "project.error.submissions.archived_project"
msgstr "The project is archived."

#: views/course_view.py:58
msgid "courses.success.assistants.add"
msgstr "The assistant was successfully added to the course."

#: views/course_view.py:77
msgid "courses.success.assistants.remove"
msgstr "The assistant was successfully removed from the course."

#: views/course_view.py:111
msgid "courses.success.students.add"
msgstr "The student was successfully added to the course."

#: views/course_view.py:131
msgid "courses.success.students.remove"
msgstr "The student was successfully removed from the course."

#: views/course_view.py:186
msgid "course.success.project.add"
msgstr "The project was successfully added to the course."

#: views/group_view.py:73
msgid "group.success.students.add"
msgstr "The student was successfully added to the group."

#: views/group_view.py:92
msgid "group.success.students.remove"
msgstr "The student was successfully removed from the group."

#: views/group_view.py:111
msgid "group.success.submissions.add"
msgstr "The submission was successfully added to the group."

#: views/project_view.py:80
msgid "project.success.groups.created"
msgstr "A group was successfully created for the project."
149 changes: 149 additions & 0 deletions backend/api/locale/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# 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: 2024-03-13 23:07+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"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: helpers/check_folder_structure.py:141
msgid "zip.errors.invalid_structure.blocked_extension_found"
msgstr ""
"Bestanden met een verboden extensie zijn gevonden in het ingediende zip-"
"bestand."

#: helpers/check_folder_structure.py:145 helpers/check_folder_structure.py:196
msgid "zip.success"
msgstr "Het zip-bestand van de indiening bevat alle benodigde bestanden."

#: helpers/check_folder_structure.py:148
msgid "zip.errors.invalid_structure.obligated_extension_not_found"
msgstr ""
"Er is geen enkel bestand met een bepaalde extensie die verplicht is in het "
"ingediende zip-bestand."

#: helpers/check_folder_structure.py:175
msgid "zip.errors.invalid_structure.directory_not_defined"
msgstr "Een verplichte map is niet aanwezig in het ingediende zip-bestand."

#: helpers/check_folder_structure.py:195
msgid "zip.errors.invalid_structure.directory_not_found_in_template"
msgstr "Het ingediende zip-bestand bevat een map die niet gevraagd is."

#: serializers/course_serializer.py:58 serializers/course_serializer.py:77
msgid "courses.error.context"
msgstr "De opleiding is niet meegeleverd als context."

#: serializers/course_serializer.py:64 tests/test_locale.py:28
#: tests/test_locale.py:38
msgid "courses.error.students.already_present"
msgstr "De student bevindt zich al in de opleiding."

#: serializers/course_serializer.py:68 serializers/course_serializer.py:87
msgid "courses.error.students.past_course"
msgstr "De opleiding die men probeert te manipuleren is van een vorig jaar."

#: serializers/course_serializer.py:83
msgid "courses.error.students.not_present"
msgstr "De student bevindt zich niet in de opleiding."

#: serializers/group_serializer.py:47
msgid "group.errors.score_exceeds_max"
msgstr "De score van de groep is groter dan de maximum score."

#: serializers/group_serializer.py:57 serializers/group_serializer.py:87
msgid "group.error.context"
msgstr "De groep is niet meegegeven als context waar dat nodig is."

#: serializers/group_serializer.py:65 serializers/group_serializer.py:99
msgid "group.errors.locked"
msgstr "De groep is momenteel vergrendeld."

#: serializers/group_serializer.py:69
msgid "group.errors.full"
msgstr "De groep is al vol."

#: serializers/group_serializer.py:73
msgid "group.errors.not_in_course"
msgstr ""
"De student bevindt zich niet in de opleiding waartoe het project hoort."

#: serializers/group_serializer.py:77
msgid "group.errors.already_in_group"
msgstr "De student bevindt zich al in de groep."

#: serializers/group_serializer.py:95
msgid "group.errors.not_present"
msgstr "De student bevindt zich niet in de groep."

#: serializers/project_serializer.py:56
msgid "project.errors.context"
msgstr "Het project is niet meegegeven als context waar dat nodig is."

#: serializers/project_serializer.py:60
msgid "project.errors.start_date_in_past"
msgstr "De startdatum van het project ligt in het verleden."

#: serializers/project_serializer.py:64
msgid "project.errors.deadline_before_start_date"
msgstr "De uiterste inleverdatum voor het project ligt voor de startdatum."

#: serializers/project_serializer.py:89
msgid "project.error.submissions.past_project"
msgstr "De uiterste inleverdatum voor het project is gepasseerd."

#: serializers/project_serializer.py:92
msgid "project.error.submissions.non_visible_project"
msgstr "Het project is niet zichtbaar."

#: serializers/project_serializer.py:95
msgid "project.error.submissions.archived_project"
msgstr "Het project is gearchiveerd."

#: views/course_view.py:58
msgid "courses.success.assistants.add"
msgstr "De assistent is succesvol toegevoegd aan de opleiding."

#: views/course_view.py:77
msgid "courses.success.assistants.remove"
msgstr "De assistent is succesvol verwijderd uit de opleiding."

#: views/course_view.py:111
msgid "courses.success.students.add"
msgstr "De student is succesvol toegevoegd aan de opleiding."

#: views/course_view.py:131
msgid "courses.success.students.remove"
msgstr "De student is succesvol verwijderd uit de opleiding."

#: views/course_view.py:186
msgid "course.success.project.add"
msgstr "Het project is succesvol toegevoegd aan de opleiding."

#: views/group_view.py:73
msgid "group.success.students.add"
msgstr "De student is succesvol toegevoegd aan de groep."

#: views/group_view.py:92
msgid "group.success.students.remove"
msgstr "De student is succesvol verwijderd uit de groep."

#: views/group_view.py:111
msgid "group.success.submissions.add"
msgstr "De indiening is succesvol toegevoegd aan de groep."

#: views/project_view.py:80
msgid "project.success.groups.created"
msgstr "De groep is succesvol toegevoegd aan het project."
3 changes: 3 additions & 0 deletions backend/api/models/checks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from api.models.project import Project
from api.models.extension import FileExtension

Expand Down Expand Up @@ -38,6 +39,8 @@ class StructureCheck(models.Model):
blank=True
)

# ID check should be generated automatically


class ExtraCheck(models.Model):
"""Model that represents an extra check for a project.
Expand Down
6 changes: 3 additions & 3 deletions backend/api/serializers/project_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ def validate(self, data):

# Check if the project's deadline is not passed.
if project.deadline_passed():
raise ValidationError(gettext("project.error.submission.past_project"))
raise ValidationError(gettext("project.error.submissions.past_project"))

if not project.is_visible():
raise ValidationError(gettext("project.error.submission.non_visible_project"))
raise ValidationError(gettext("project.error.submissions.non_visible_project"))

if project.is_archived():
raise ValidationError(gettext("project.error.submission.archived_project"))
raise ValidationError(gettext("project.error.submissions.archived_project"))

return data
3 changes: 1 addition & 2 deletions backend/api/tests/test_file_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,4 @@ def test_your_checking(self):
obligated=[fileExtensionTS, fileExtensionTSX],
blocked=[])

succes = (True, 'zip.success')
self.assertEqual(check_zip_file(project=project, dir_path="structures/zip_struct1.zip"), succes)
self.assertTrue(check_zip_file(project=project, dir_path="structures/zip_struct1.zip")[0])
38 changes: 38 additions & 0 deletions backend/api/tests/test_locale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import json
from django.urls import reverse
from django.utils.translation import activate
from django.utils.translation import gettext as _
from rest_framework.test import APITestCase

from api.models.course import Course
from api.models.student import Student
from authentication.models import User


class TestLocaleAddAlreadyPresentStudentToCourse(APITestCase):
def setUp(self) -> None:
self.client.force_authenticate(User.get_dummy_admin())

course = Course.objects.create(id=1, name="Test Course", academic_startyear=2024)
student = Student.objects.create(id=1, first_name="John", last_name="Doe", email="[email protected]")

student.courses.add(course)

def test_default_locale(self):
response = self.client.post(reverse("course-students", args=["1"]),
{"student_id": 1})

self.assertEqual(response.status_code, 400)
body = json.loads(response.content.decode('utf-8'))
activate("en")
self.assertEqual(body["non_field_errors"][0], _("courses.error.students.already_present"))

def test_nl_locale(self):
response = self.client.post(reverse("course-students", args=["1"]),
{"student_id": 1},
headers={"accept-language": "nl"})

self.assertEqual(response.status_code, 400)
body = json.loads(response.content.decode('utf-8'))
activate("nl")
self.assertEqual(body["non_field_errors"][0], _("courses.error.students.already_present"))
Loading
Loading