diff --git a/.gitignore b/.gitignore index 94defc0..aee3139 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ db.sqlite3 *.webm .venv .envrc +*.mo diff --git a/eqy_fr/settings.py b/eqy_fr/settings.py index f150db1..bcb70ba 100644 --- a/eqy_fr/settings.py +++ b/eqy_fr/settings.py @@ -12,6 +12,9 @@ https://docs.djangoproject.com/en/5.0/ref/settings/ from pathlib import Path +from django.utils.translation import gettext_lazy as _ + + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -43,6 +46,7 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', @@ -124,6 +128,12 @@ MEDIA_URL = 'media/' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +LANGUAGES = [ + ("fr", _("French")), + ("en", _("English")), +] + + try: from local_settings import * except ImportError: diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po new file mode 100644 index 0000000..70cf06d --- /dev/null +++ b/locale/fr/LC_MESSAGES/django.po @@ -0,0 +1,27 @@ +# 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 , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-12-20 15:58+0000\n" +"PO-Revision-Date: 2023-12-20 16:59+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: fr\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" +"X-Generator: Poedit 3.4.1\n" + +#: eqy_fr/settings.py:132 +msgid "French" +msgstr "Français" + +#: eqy_fr/settings.py:133 +msgid "English" +msgstr "Anglais" diff --git a/photos/locale/fr/LC_MESSAGES/django.po b/photos/locale/fr/LC_MESSAGES/django.po new file mode 100644 index 0000000..59e3ef8 --- /dev/null +++ b/photos/locale/fr/LC_MESSAGES/django.po @@ -0,0 +1,37 @@ +# 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 , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-12-20 15:58+0000\n" +"PO-Revision-Date: 2023-12-20 17:00+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: fr\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" +"X-Generator: Poedit 3.4.1\n" + +#: photos/templates/photos/index.html:13 +msgid "This is the subtitle." +msgstr "Ceci est un sous-titre." + +#: photos/templates/photos/index.html:27 +msgid "" +"\n" +" Blah blah blah blah blah blah\n" +" " +msgstr "" +"\n" +" Bouhaha Brouhaha brouhaha\n" +" " + +#: photos/views.py:8 +msgid "Title" +msgstr "Titre" diff --git a/photos/templates/photos/index.html b/photos/templates/photos/index.html index 966819e..3dd8fa1 100644 --- a/photos/templates/photos/index.html +++ b/photos/templates/photos/index.html @@ -1,3 +1,5 @@ +{% load i18n %} + @@ -6,6 +8,10 @@ photos +
+

{{title}}

+

{% translate "This is the subtitle." %}

+
{% for media in medias %}
@@ -17,5 +23,10 @@
{% endfor %}
+ diff --git a/photos/views.py b/photos/views.py index 33c4757..7a21dc7 100644 --- a/photos/views.py +++ b/photos/views.py @@ -1,7 +1,9 @@ from django.shortcuts import render +from django.utils.translation import gettext as _ from photos.models import Media def index(request): - return render(request, "photos/index.html", context={"medias": Media.objects.all()}) + title = _("Title") + return render(request, "photos/index.html", context={"title": title, "medias": Media.objects.all()})