activate i18n per url

This commit is contained in:
Christoph J. Scherr 2023-05-29 23:40:13 +02:00
parent 381945d60d
commit f43c506538
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
7 changed files with 102 additions and 6 deletions

View File

@ -53,6 +53,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.locale.LocaleMiddleware',
] ]
ROOT_URLCONF = 'gawa.urls' ROOT_URLCONF = 'gawa.urls'
@ -115,6 +116,8 @@ AUTH_PASSWORD_VALIDATORS = [
# https://docs.djangoproject.com/en/3.2/topics/i18n/ # https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'de-De' LANGUAGE_CODE = 'de-De'
# treat this ^^^ as the default
prefix_default_language = False
TIME_ZONE = 'CET' TIME_ZONE = 'CET'

View File

@ -13,6 +13,7 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path 1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin from django.contrib import admin
from django.urls import include, path from django.urls import include, path
@ -21,3 +22,8 @@ urlpatterns = [
path("blog/", include("blog.urls")), path("blog/", include("blog.urls")),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
] ]
urlpatterns += i18n_patterns(
path("", include("start.urls")),
path("blog/", include("blog.urls")),
path('admin/', admin.site.urls),
)

Binary file not shown.

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-05-29 22:26+0200\n" "POT-Creation-Date: 2023-05-29 23:20+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,10 +17,54 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: start/templates/start/base.html:21
#: start/templates/start/base.html:16 start/templates/start/index.html:5
msgid "cscherr.de"
msgstr "cscherr.de"
#: start/templates/start/base.html:24
msgid "Start" msgid "Start"
msgstr "Start" msgstr "Start"
#: start/templates/start/base.html:24 #: start/templates/start/base.html:27
msgid "Blog" msgid "Blog"
msgstr "Blog" msgstr "Blog"
#: start/templates/start/base.html:80
msgid ""
"\n"
" Ich habe diese Website selbst programmiert und "
"gehostet. \n"
" Falls Sie einen Fehler belibiger Art finden, "
"würde ich mich freuen, \n"
" wenn Sie mich darüber benachrichtigen.\n"
" <br><br>\n"
" Die Suche nach Schwachstellen und Fehlern auf "
"dieser Website ist für \n"
" diesen Zweck ausdrücklich erlaubt.\n"
" "
msgstr ""
"\n"
"Ich habe diese Website selbst programmiert und gehostet.\n"
"Falls Sie einen Fehler belibiger Art finden\n"
"würde ich mich freuen, wenn Sie mich darüber benachrichtigen.\n"
"<br><br>\n"
"Die Suche nach Schwachstellen und Fehlern auf\n"
"dieser Website ist für diesen Zweck ausdrücklich erlaubt.\n"
" "
#: start/templates/start/base.html:101
msgid "Quellcode dieser Website"
msgstr "Quellcode dieser Website"
#: start/templates/start/base.html:110
msgid "Contact"
msgstr "Kontakt"
#: start/templates/start/base.html:115
msgid "Deutschland"
msgstr "Deutschland"
#: start/templates/start/index.html:5
msgid "startpage"
msgstr "Startseite"

Binary file not shown.

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-05-29 22:26+0200\n" "POT-Creation-Date: 2023-05-29 23:20+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,10 +17,50 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: start/templates/start/base.html:21
#: start/templates/start/base.html:16 start/templates/start/index.html:5
msgid "cscherr.de"
msgstr "cscherr.de"
#: start/templates/start/base.html:24
msgid "Start" msgid "Start"
msgstr "Start" msgstr "Start"
#: start/templates/start/base.html:24 #: start/templates/start/base.html:27
msgid "Blog" msgid "Blog"
msgstr "Blog" msgstr "Blog"
#: start/templates/start/base.html:80
msgid ""
"\n"
" Ich habe diese Website selbst programmiert und "
"gehostet. \n"
" Falls Sie einen Fehler belibiger Art finden, "
"würde ich mich freuen, \n"
" wenn Sie mich darüber benachrichtigen.\n"
" <br><br>\n"
" Die Suche nach Schwachstellen und Fehlern auf "
"dieser Website ist für \n"
" diesen Zweck ausdrücklich erlaubt.\n"
" "
msgstr ""
"I have programmed and hosted this Website by myself. If you find any issues or bugs,\n"
"please contact me about it.\n"
"<br><br>\n"
"I specifically allow the search for any issues this website might have.\n"
#: start/templates/start/base.html:101
msgid "Quellcode dieser Website"
msgstr "Source code of this website"
#: start/templates/start/base.html:110
msgid "Contact"
msgstr "Contakt"
#: start/templates/start/base.html:115
msgid "Deutschland"
msgstr "Germany"
#: start/templates/start/index.html:5
msgid "startpage"
msgstr "startpage"

View File

@ -97,6 +97,9 @@
<p> <p>
<a href="https://git.cscherr.de" class="text-reset">Selfhosted Git</a> <a href="https://git.cscherr.de" class="text-reset">Selfhosted Git</a>
</p> </p>
<p>
<a href="https://git.cscherr.de/PlexSheep/gawa" class="text-reset">{% trans "Quellcode dieser Website" %}</a>
</p>
</div> </div>
<div class="col-md-3 col-lg-2 col-xl-2 mx-auto mb-4"> <div class="col-md-3 col-lg-2 col-xl-2 mx-auto mb-4">
<h6 class="text-uppercase fw-bold mb-4"> <h6 class="text-uppercase fw-bold mb-4">