diff --git a/core/constants.py b/core/constants.py index f581913e8..b55371be8 100644 --- a/core/constants.py +++ b/core/constants.py @@ -107,15 +107,16 @@ (CONTRIBUTION_STATUS_IGNORED, "Ignoré"), ] -LANGUAGE_FRENCH = "Français" -LANGUAGE_ENGLISH = "English" -LANGUAGE_GERMAN = "Deutsch" -LANGUAGE_CHOICE_LIST = [ - LANGUAGE_FRENCH, - LANGUAGE_ENGLISH, - LANGUAGE_GERMAN, +LANGUAGE_FRENCH = "FRENCH" +LANGUAGE_ENGLISH = "ENGLISH" +LANGUAGE_GERMAN = "GERMAN" +LANGUAGE_OPTIONS = [ + (LANGUAGE_FRENCH, _("French"), "fr", "🇫🇷"), + (LANGUAGE_ENGLISH, _("English"), "en", "🇬🇧"), + (LANGUAGE_GERMAN, _("German"), "de", "🇩🇪"), ] -LANGUAGE_CHOICES = [(lang, lang) for lang in LANGUAGE_CHOICE_LIST] +LANGUAGE_CHOICES = [(language[0], language[1]) for language in LANGUAGE_OPTIONS] +LANGUAGE_CHOICE_LIST = [language[0] for language in LANGUAGE_CHOICES] NOTION_QUESTIONS_IMPORT_SCOPE_CHOICES = [ (0, "100 dernières questions modifiées"), diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po index 70a5ce982..da9838e1e 100644 --- a/locale/en/LC_MESSAGES/django.po +++ b/locale/en/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-02-16 22:38+0100\n" +"POT-Creation-Date: 2023-02-18 22:24+0100\n" "PO-Revision-Date: 2023-02-12 20:12+0100\n" "Last-Translator: Didier Quirin \n" "Language-Team: \n" @@ -19,11 +19,11 @@ msgstr "" "X-Generator: Poedit 3.2.2\n" "X-Translated-Using: django-rosetta 0.9.8\n" -#: app/settings.py:178 +#: app/settings.py:178 core/constants.py:115 msgid "English" msgstr "" -#: app/settings.py:179 +#: app/settings.py:179 core/constants.py:114 msgid "French" msgstr "" @@ -39,43 +39,47 @@ msgstr "" msgid "True or False" msgstr "" -#: core/constants.py:20 +#: core/constants.py:23 msgid "Junior" msgstr "" -#: core/constants.py:21 +#: core/constants.py:24 msgid "Easy" msgstr "" -#: core/constants.py:22 +#: core/constants.py:25 msgid "Medium" msgstr "" -#: core/constants.py:23 +#: core/constants.py:26 msgid "Hard" msgstr "" -#: core/constants.py:24 +#: core/constants.py:27 msgid "Expert" msgstr "" -#: core/constants.py:132 +#: core/constants.py:116 +msgid "German" +msgstr "" + +#: core/constants.py:136 msgid "Public (exported and the application)" msgstr "" -#: core/constants.py:133 +#: core/constants.py:137 msgid "Hidden (exported but not visible in the application)" msgstr "" -#: core/constants.py:134 +#: core/constants.py:138 msgid "Private (not exported and not in the application)" msgstr "" -#: core/constants.py:137 +#: core/constants.py:141 msgid "True" msgstr "" -#: core/constants.py:137 +#: core/constants.py:141 msgid "False" msgstr "" diff --git a/locale/fr/LC_MESSAGES/django.mo b/locale/fr/LC_MESSAGES/django.mo index eec234dc7..29daba959 100644 Binary files a/locale/fr/LC_MESSAGES/django.mo and b/locale/fr/LC_MESSAGES/django.mo differ diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index ea52af1b8..bd3fbd71f 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-02-16 22:38+0100\n" -"PO-Revision-Date: 2023-02-16 22:44+0100\n" +"POT-Creation-Date: 2023-02-18 22:24+0100\n" +"PO-Revision-Date: 2023-02-18 22:24+0100\n" "Last-Translator: Didier Quirin \n" "Language-Team: \n" "Language: fr\n" @@ -19,11 +19,11 @@ msgstr "" "X-Generator: Poedit 3.2.2\n" "X-Translated-Using: django-rosetta 0.9.8\n" -#: app/settings.py:178 +#: app/settings.py:178 core/constants.py:115 msgid "English" msgstr "Anglais" -#: app/settings.py:179 +#: app/settings.py:179 core/constants.py:114 msgid "French" msgstr "Français" @@ -39,43 +39,47 @@ msgstr "Questionnaire à choix multiples avec réponses multiples" msgid "True or False" msgstr "Vrai ou Faux" -#: core/constants.py:20 +#: core/constants.py:23 msgid "Junior" msgstr "Junior" -#: core/constants.py:21 +#: core/constants.py:24 msgid "Easy" msgstr "Facile" -#: core/constants.py:22 +#: core/constants.py:25 msgid "Medium" msgstr "Moyen" -#: core/constants.py:23 +#: core/constants.py:26 msgid "Hard" msgstr "Difficule" -#: core/constants.py:24 +#: core/constants.py:27 msgid "Expert" msgstr "Expert" -#: core/constants.py:132 +#: core/constants.py:116 +msgid "German" +msgstr "Allemand" + +#: core/constants.py:136 msgid "Public (exported and the application)" msgstr "Publique (dans l'export et dans l'application)" -#: core/constants.py:133 +#: core/constants.py:137 msgid "Hidden (exported but not visible in the application)" msgstr "Caché (dans l'export mais pas visible dans l'application)" -#: core/constants.py:134 +#: core/constants.py:138 msgid "Private (not exported and not in the application)" msgstr "Privé (pas dans l'export ni dans l'application)" -#: core/constants.py:137 +#: core/constants.py:141 msgid "True" msgstr "Vrai" -#: core/constants.py:137 +#: core/constants.py:141 msgid "False" msgstr "Faux" diff --git a/questions/migrations/0022_question_language_migration.py b/questions/migrations/0022_question_language_migration.py new file mode 100644 index 000000000..eedd051be --- /dev/null +++ b/questions/migrations/0022_question_language_migration.py @@ -0,0 +1,29 @@ +# Generated by Django 4.1.5 on 2023-02-18 19:54 + +from django.db import migrations + + +def migrate_question_language(apps, schema_editor): + Question = apps.get_model("questions", "Question") + Question.objects.filter(language="Français").update(language="FRENCH") + Question.objects.filter(language="English").update(language="ENGLISH") + Question.objects.filter(language="Deutsch").update(language="GERMAN") + + +def migrate_historical_question_language(apps, schema_editor): + HistoricalQuestion = apps.get_model("questions", "HistoricalQuestion") + HistoricalQuestion.objects.filter(language="Français").update(language="FRENCH") + HistoricalQuestion.objects.filter(language="English").update(language="ENGLISH") + HistoricalQuestion.objects.filter(language="Deutsch").update(language="GERMAN") + + +class Migration(migrations.Migration): + + dependencies = [ + ("questions", "0021_alter_historicalquestion_answer_audio_url_and_more"), + ] + + operations = [ + migrations.RunPython(migrate_question_language), + migrations.RunPython(migrate_historical_question_language), + ] diff --git a/questions/migrations/0023_alter_historicalquestion_difficulty_and_more.py b/questions/migrations/0023_alter_historicalquestion_difficulty_and_more.py new file mode 100644 index 000000000..b1e8a06fa --- /dev/null +++ b/questions/migrations/0023_alter_historicalquestion_difficulty_and_more.py @@ -0,0 +1,107 @@ +# Generated by Django 4.1.5 on 2023-02-18 21:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("questions", "0022_question_language_migration"), + ] + + operations = [ + migrations.AlterField( + model_name="historicalquestion", + name="difficulty", + field=models.IntegerField( + choices=[(0, "Junior"), (1, "Easy"), (2, "Medium"), (3, "Hard"), (4, "Expert")], + default=1, + verbose_name="Difficulty level", + ), + ), + migrations.AlterField( + model_name="historicalquestion", + name="language", + field=models.CharField( + choices=[("FRENCH", "French"), ("ENGLISH", "English"), ("GERMAN", "German")], + default="FRENCH", + max_length=50, + verbose_name="Language", + ), + ), + migrations.AlterField( + model_name="historicalquestion", + name="type", + field=models.CharField( + choices=[ + ("QCM", "Multiple choice questionnaire"), + ("QCM-RM", "Multiple choice questionnaire with multiple answers"), + ("VF", "True or False"), + ], + default="QCM", + max_length=50, + verbose_name="Type", + ), + ), + migrations.AlterField( + model_name="historicalquestion", + name="visibility", + field=models.CharField( + choices=[ + ("PUBLIC", "Public (exported and the application)"), + ("HIDDEN", "Hidden (exported but not visible in the application)"), + ("PRIVATE", "Private (not exported and not in the application)"), + ], + default="PUBLIC", + max_length=50, + verbose_name="Visibility", + ), + ), + migrations.AlterField( + model_name="question", + name="difficulty", + field=models.IntegerField( + choices=[(0, "Junior"), (1, "Easy"), (2, "Medium"), (3, "Hard"), (4, "Expert")], + default=1, + verbose_name="Difficulty level", + ), + ), + migrations.AlterField( + model_name="question", + name="language", + field=models.CharField( + choices=[("FRENCH", "French"), ("ENGLISH", "English"), ("GERMAN", "German")], + default="FRENCH", + max_length=50, + verbose_name="Language", + ), + ), + migrations.AlterField( + model_name="question", + name="type", + field=models.CharField( + choices=[ + ("QCM", "Multiple choice questionnaire"), + ("QCM-RM", "Multiple choice questionnaire with multiple answers"), + ("VF", "True or False"), + ], + default="QCM", + max_length=50, + verbose_name="Type", + ), + ), + migrations.AlterField( + model_name="question", + name="visibility", + field=models.CharField( + choices=[ + ("PUBLIC", "Public (exported and the application)"), + ("HIDDEN", "Hidden (exported but not visible in the application)"), + ("PRIVATE", "Private (not exported and not in the application)"), + ], + default="PUBLIC", + max_length=50, + verbose_name="Visibility", + ), + ), + ] diff --git a/quizs/migrations/0021_quiz_language_migration.py b/quizs/migrations/0021_quiz_language_migration.py new file mode 100644 index 000000000..90c1b43bb --- /dev/null +++ b/quizs/migrations/0021_quiz_language_migration.py @@ -0,0 +1,29 @@ +# Generated by Django 4.1.5 on 2023-02-18 19:54 + +from django.db import migrations + + +def migrate_quiz_language(apps, schema_editor): + Quiz = apps.get_model("quizs", "Quiz") + Quiz.objects.filter(language="Français").update(language="FRENCH") + Quiz.objects.filter(language="English").update(language="ENGLISH") + Quiz.objects.filter(language="Deutsch").update(language="GERMAN") + + +def migrate_historical_quiz_language(apps, schema_editor): + HistoricalQuiz = apps.get_model("quizs", "HistoricalQuiz") + HistoricalQuiz.objects.filter(language="Français").update(language="FRENCH") + HistoricalQuiz.objects.filter(language="English").update(language="ENGLISH") + HistoricalQuiz.objects.filter(language="Deutsch").update(language="GERMAN") + + +class Migration(migrations.Migration): + + dependencies = [ + ("quizs", "0020_remove_historicalquiz_author_and_more"), + ] + + operations = [ + migrations.RunPython(migrate_quiz_language), + migrations.RunPython(migrate_historical_quiz_language), + ] diff --git a/quizs/migrations/0022_alter_historicalquiz_language_and_more.py b/quizs/migrations/0022_alter_historicalquiz_language_and_more.py new file mode 100644 index 000000000..4f5b89820 --- /dev/null +++ b/quizs/migrations/0022_alter_historicalquiz_language_and_more.py @@ -0,0 +1,61 @@ +# Generated by Django 4.1.5 on 2023-02-18 21:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("quizs", "0021_quiz_language_migration"), + ] + + operations = [ + migrations.AlterField( + model_name="historicalquiz", + name="language", + field=models.CharField( + choices=[("FRENCH", "French"), ("ENGLISH", "English"), ("GERMAN", "German")], + default="FRENCH", + max_length=50, + verbose_name="Langue", + ), + ), + migrations.AlterField( + model_name="historicalquiz", + name="visibility", + field=models.CharField( + choices=[ + ("PUBLIC", "Public (exported and the application)"), + ("HIDDEN", "Hidden (exported but not visible in the application)"), + ("PRIVATE", "Private (not exported and not in the application)"), + ], + default="PUBLIC", + max_length=50, + verbose_name="Visibilité", + ), + ), + migrations.AlterField( + model_name="quiz", + name="language", + field=models.CharField( + choices=[("FRENCH", "French"), ("ENGLISH", "English"), ("GERMAN", "German")], + default="FRENCH", + max_length=50, + verbose_name="Langue", + ), + ), + migrations.AlterField( + model_name="quiz", + name="visibility", + field=models.CharField( + choices=[ + ("PUBLIC", "Public (exported and the application)"), + ("HIDDEN", "Hidden (exported but not visible in the application)"), + ("PRIVATE", "Private (not exported and not in the application)"), + ], + default="PUBLIC", + max_length=50, + verbose_name="Visibilité", + ), + ), + ] diff --git a/stats/utilities.py b/stats/utilities.py index 88fe7a6ce..fb1a8b5a7 100644 --- a/stats/utilities.py +++ b/stats/utilities.py @@ -272,16 +272,19 @@ def language_aggregate(): ) languages = [] - for language in constants.LANGUAGE_CHOICE_LIST: + for value, name, code, emoji in constants.LANGUAGE_OPTIONS: languages.append( { - "name": language, + "name": str(name), # force gettext_lazy evaluation + "value": value, + "code": code, + "emoji": emoji, "question_count": next( - (item["question_count"] for item in question_languages if item["language"] == language), + (item["question_count"] for item in question_languages if item["language"] == value), 0, ), "quiz_count": next( - (item["quiz_count"] for item in quiz_languages if item["language"] == language), + (item["quiz_count"] for item in quiz_languages if item["language"] == value), 0, ), }