feat: Add basic translation support

This commit is contained in:
moanos [he/him] 2024-04-12 23:37:03 +02:00
parent 4767fb4e76
commit 8942d029d1
8 changed files with 680 additions and 6 deletions

View File

@ -12,8 +12,8 @@ from notfellchen.settings import host
def mail_admins_new_report(report): def mail_admins_new_report(report):
subject = _("New report") subject = _("New report")
for moderator in Member.objects.filter(Q(trust_level=Member.MODERATOR) | Q(trust_level=Member.ADMIN)): for moderator in Member.objects.filter(Q(trust_level=Member.MODERATOR) | Q(trust_level=Member.ADMIN)):
greeting = _("Moin,\r\n") greeting = _("Moin,") + "\r\n"
new_report_text = "es wurde eine Vermittlung gemeldet.\r\n" new_report_text = _("es wurde eine Vermittlung gemeldet.") + "\r\n"
if len(report.reported_broken_rules.all()) > 0: if len(report.reported_broken_rules.all()) > 0:
reported_rules_text = f"Ein Verstoß gegen die folgenden Regeln wurde gemeldet [{', '.join(report.reported_broken_rules.all())}]\r\n" reported_rules_text = f"Ein Verstoß gegen die folgenden Regeln wurde gemeldet [{', '.join(report.reported_broken_rules.all())}]\r\n"
else: else:

View File

@ -22,9 +22,26 @@
<button type="submit">Ausloggen</button> <button type="submit">Ausloggen</button>
</form> </form>
</div> </div>
{% else %} {% else %}
<a href="{% url "django_registration_register" %}">Registrieren</a> <a href="{% url "django_registration_register" %}">Registrieren</a>
<a href="{% url "login" %}">Einloggen</a> <a href="{% url "login" %}">Einloggen</a>
{% endif %} {% endif %}
<form action="{% url 'change-language' %}" method="post" onchange='this.form.submit()'>
{% csrf_token %}
<select name="language" onchange='this.form.submit()'>
{% get_current_language as LANGUAGE_CODE_CURRENT %}
{% get_available_languages as LANGUAGES %}
{% for language in LANGUAGES %}
<option value="{{ language.0 }}" {% if language.0 == LANGUAGE_CODE_CURRENT %} selected{% endif %}>
{{ language.0|language_name_local }}
</option>
<!--<option value="{{ language.0 }}" {% if language.0 == LANGUAGE_CODE %} selected{% endif %}>
{{ language.0|language_name_local }} ({{ language.0 }})
</option>-->
{% endfor %}
</select>
<!--<input type="submit" value={% translate "change" %}>-->
</form>
</div> </div>
</div> </div>

View File

@ -47,4 +47,6 @@ urlpatterns = [
path('accounts/', include('django_registration.backends.activation.urls')), path('accounts/', include('django_registration.backends.activation.urls')),
path('accounts/', include('django.contrib.auth.urls')), path('accounts/', include('django.contrib.auth.urls')),
path('change-language', views.change_language, name="change-language")
] ]

View File

@ -1,6 +1,9 @@
from django.http import HttpResponseRedirect
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.urls import reverse from django.urls import reverse
from django.contrib.auth.decorators import login_required
from .mail import mail_admins_new_report from .mail import mail_admins_new_report
from notfellchen import settings
from fellchensammlung.models import AdoptionNotice, MarkdownContent, Animal, Rule, Image, Report, ModerationAction, \ from fellchensammlung.models import AdoptionNotice, MarkdownContent, Animal, Rule, Image, Report, ModerationAction, \
Member Member
@ -15,6 +18,24 @@ def index(request):
return render(request, 'fellchensammlung/index.html', context=context) return render(request, 'fellchensammlung/index.html', context=context)
def change_language(request):
if request.method == 'POST':
language_code = request.POST.get('language')
if language_code:
if language_code != settings.LANGUAGE_CODE and language_code in list(zip(*settings.LANGUAGES))[0]:
redirect_path = f'/{language_code}/'
elif language_code == settings.LANGUAGE_CODE:
redirect_path = '/'
else:
response = HttpResponseRedirect('/')
return response
from django.utils import translation
translation.activate(language_code)
response = HttpResponseRedirect(redirect_path)
response.set_cookie(settings.LANGUAGE_COOKIE_NAME, language_code)
return response
def adoption_notice_detail(request, adoption_notice_id): def adoption_notice_detail(request, adoption_notice_id):
adoption_notice = AdoptionNotice.objects.get(id=adoption_notice_id) adoption_notice = AdoptionNotice.objects.get(id=adoption_notice_id)
context = {"adoption_notice": adoption_notice} context = {"adoption_notice": adoption_notice}
@ -33,6 +54,7 @@ def search(request):
return render(request, 'fellchensammlung/search.html', context=context) return render(request, 'fellchensammlung/search.html', context=context)
@login_required
def add_adoption(request): def add_adoption(request):
if request.method == 'POST': if request.method == 'POST':
form = AdoptionNoticeForm(request.POST, request.FILES) form = AdoptionNoticeForm(request.POST, request.FILES)
@ -45,6 +67,7 @@ def add_adoption(request):
return render(request, 'fellchensammlung/forms/form_add_adoption.html', {'form': form}) return render(request, 'fellchensammlung/forms/form_add_adoption.html', {'form': form})
@login_required
def add_animal_to_adoption(request, adoption_notice_id): def add_animal_to_adoption(request, adoption_notice_id):
if request.method == 'POST': if request.method == 'POST':
form = AnimalForm(request.POST) form = AnimalForm(request.POST)

View File

@ -0,0 +1,315 @@
# 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: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-04-12 20:50+0000\n"
"PO-Revision-Date: 2024-04-12 23:05+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de\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.2\n"
#: build/lib/notfellchen/settings.py:214 src/notfellchen/settings.py:223
msgid "English"
msgstr "Englisch"
#: build/lib/notfellchen/settings.py:215 src/notfellchen/settings.py:224
msgid "German"
msgstr "Deutsch"
#: src/fellchensammlung/mail.py:13
msgid "New report"
msgstr "Neue Meldung"
#: src/fellchensammlung/mail.py:15
msgid "Moin,"
msgstr ""
#: src/fellchensammlung/mail.py:16
msgid "es wurde eine Vermittlung gemeldet."
msgstr ""
#: src/fellchensammlung/models.py:26
msgid "Enter a animal species"
msgstr "Gib die Tierart an"
#: src/fellchensammlung/models.py:27
msgid "Name"
msgstr "Name"
#: src/fellchensammlung/models.py:34 src/fellchensammlung/models.py:35
msgid "Species"
msgstr "Tierart"
#: src/fellchensammlung/models.py:54 src/fellchensammlung/models.py:82
#: src/fellchensammlung/models.py:146
msgid "Description"
msgstr "Beschreibung"
#: src/fellchensammlung/models.py:62
msgid "Trusted"
msgstr "Vertrauenswürdig"
#: src/fellchensammlung/models.py:64
msgid "Instagram profile"
msgstr "Instagram Profil"
#: src/fellchensammlung/models.py:65
msgid "Facebook profile"
msgstr "Facebook Profil"
#: src/fellchensammlung/models.py:66
msgid "Fediverse profile"
msgstr "Fediverse Profil"
#: src/fellchensammlung/models.py:67
msgid "Website"
msgstr "Website"
#: src/fellchensammlung/models.py:79
msgid "Created at"
msgstr "Veröffentlicht am"
#: src/fellchensammlung/models.py:80
msgid "Searching for a home since"
msgstr "Sucht nach einem Zuhause seit"
#: src/fellchensammlung/models.py:84
msgid "Organization"
msgstr "Organisation"
#: src/fellchensammlung/models.py:85
msgid "Link to further information"
msgstr "Link zur mehr Informationen"
#: src/fellchensammlung/models.py:86
msgid "Only group adoption"
msgstr "Ausschließlich Adoption der ganzen Gruppe möglich"
#: src/fellchensammlung/models.py:144
msgid "Date of birth"
msgstr "Geburtstag"
#: src/fellchensammlung/models.py:222
msgid "ID dieses reports"
msgstr "ID des Reports"
#: src/fellchensammlung/models.py:223
msgid "ID"
msgstr "ID"
#: src/fellchensammlung/models.py:273
msgid "Enter a natural languages name (e.g. English, French, Japanese etc.)."
msgstr "Gib den Namen einer natürlichen Sprache ein (Detusch, Englisch etc..)"
#: src/fellchensammlung/models.py:279
msgid ""
"Enter the language code for this language. For further information see "
"http://www.i18nguy.com/unicode/language-identifiers.html"
msgstr ""
"Gib den Language Code der Sprache ein. Mehr Informationen: http://www."
"i18nguy.com/unicode/language-identifiers.html"
#: src/fellchensammlung/models.py:280
msgid "Language code"
msgstr ""
#: src/fellchensammlung/models.py:287
#: src/fellchensammlung/templates/fellchensammlung/details/detail-member.html:11
msgid "Language"
msgstr "Sprache"
#: src/fellchensammlung/models.py:288
msgid "Languages"
msgstr "Sprachen"
#: src/fellchensammlung/models.py:323
msgid "User"
msgstr "Nutzer*in"
#: src/fellchensammlung/models.py:325
msgid "Preferred language"
msgstr "Bevorzugte Sprache"
#: src/fellchensammlung/models.py:329
msgid "Member"
msgstr ""
#: src/fellchensammlung/models.py:330
msgid "Members"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/details/detail-member.html:7
msgid "Username"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/details/detail-member.html:8
msgid "E-Mail"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/details/detail-member.html:13
msgid "No preferred language set."
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/index.html:5
msgid "Notfellchen - Vermittlungen finden"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/index.html:6
msgid ""
"Alle Tiere brauchen ein liebendes Zuhause. Damit keins vergessen wird gibt "
"es diese Seite. Entwickelt und betreut von "
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/index.html:8
msgid "Aktuelle Vermittlungen"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/modqueue.html:5
msgid "Modqueue"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/modqueue.html:6
msgid ""
"Erlaube oder blockiere Vermittlungsanzeigen die bisher noch zurückgehaltemn "
"werden "
msgstr ""
#: src/templates/django_registration/activate.html:6
msgid "Account activation failed"
msgstr ""
#: src/templates/django_registration/activation_complete.html:5
msgid "You are now activated. Have fun."
msgstr ""
#: src/templates/django_registration/activation_email_body.txt:2
msgid "Activate account at"
msgstr ""
#: src/templates/django_registration/activation_email_body.txt:4
msgid "Activate by clicking this link"
msgstr ""
#: src/templates/django_registration/activation_email_body.txt:5
msgid "or open the following link in your browser"
msgstr ""
#: src/templates/django_registration/activation_email_body.txt:8
#, python-format
msgid "Link is valid for %(expiration_days)s days."
msgstr ""
#: src/templates/django_registration/activation_email_subject.txt:1
msgid "Account activation on"
msgstr ""
#: src/templates/django_registration/activation_failed.html:5
msgid ""
"Activation failed. Please send an e-mail to info@notfellchen.org to get an "
"account."
msgstr ""
#: src/templates/django_registration/registration_closed.html:5
msgid "Registration is currently closed."
msgstr ""
#: src/templates/django_registration/registration_complete.html:5
msgid "You are now registered. Activation email sent."
msgstr ""
#: src/templates/django_registration/registration_form.html:10
msgid "Submit"
msgstr ""
#: src/templates/django_registration/registration_form.html:13
#: src/templates/registration/login.html:11
msgid "You're already logged in."
msgstr ""
#: src/templates/registration/logged_out.html:5
msgid "Logged out"
msgstr ""
#: src/templates/registration/logged_out.html:6
msgid "Click here to login again."
msgstr ""
#: src/templates/registration/login.html:7
msgid "Your username and password didn't match. Please try again."
msgstr ""
#: src/templates/registration/login.html:13
msgid "Please login to see this page."
msgstr ""
"Bitte logg dich ein oder erstelle einen Account um diese Seite zu sehen."
#: src/templates/registration/login.html:30
msgid "login"
msgstr ""
#: src/templates/registration/login.html:34
msgid "Lost password?"
msgstr ""
#: src/templates/registration/password_reset_complete.html:5
msgid "The password has been changed!"
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:6
msgid "Please enter (and confirm) your new password."
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:12
msgid "New password"
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:17
msgid "Confirm password"
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:22
msgid "Change my password"
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:27
msgid "Password reset failed"
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:28
msgid ""
"The password reset link was invalid, possibly because it has already been "
"used. Please request a new password reset."
msgstr ""
#: src/templates/registration/password_reset_done.html:5
msgid ""
"We've emailed you instructions for setting your password. If they haven't "
"arrived in a few minutes, check your spam folder."
msgstr ""
#: src/templates/registration/password_reset_email.html:2
msgid "Someone asked for password reset for your email. Follow the link below:"
msgstr ""
#: src/templates/registration/password_reset_form.html:10
msgid "Password reset"
msgstr ""
#: src/templates/registration/password_reset_form.html:11
msgid "Provide the e-mail address that is connected with your account"
msgstr ""
#: src/templates/registration/password_reset_form.html:13
msgid "Reset"
msgstr ""

View File

@ -0,0 +1,311 @@
# 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-04-12 20:50+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#: build/lib/notfellchen/settings.py:214 src/notfellchen/settings.py:223
msgid "English"
msgstr ""
#: build/lib/notfellchen/settings.py:215 src/notfellchen/settings.py:224
msgid "German"
msgstr ""
#: src/fellchensammlung/mail.py:13
msgid "New report"
msgstr ""
#: src/fellchensammlung/mail.py:15
msgid "Moin,"
msgstr ""
#: src/fellchensammlung/mail.py:16
msgid "es wurde eine Vermittlung gemeldet."
msgstr ""
#: src/fellchensammlung/models.py:26
msgid "Enter a animal species"
msgstr ""
#: src/fellchensammlung/models.py:27
msgid "Name"
msgstr ""
#: src/fellchensammlung/models.py:34 src/fellchensammlung/models.py:35
msgid "Species"
msgstr ""
#: src/fellchensammlung/models.py:54 src/fellchensammlung/models.py:82
#: src/fellchensammlung/models.py:146
msgid "Description"
msgstr ""
#: src/fellchensammlung/models.py:62
msgid "Trusted"
msgstr ""
#: src/fellchensammlung/models.py:64
msgid "Instagram profile"
msgstr ""
#: src/fellchensammlung/models.py:65
msgid "Facebook profile"
msgstr ""
#: src/fellchensammlung/models.py:66
msgid "Fediverse profile"
msgstr ""
#: src/fellchensammlung/models.py:67
msgid "Website"
msgstr ""
#: src/fellchensammlung/models.py:79
msgid "Created at"
msgstr ""
#: src/fellchensammlung/models.py:80
msgid "Searching for a home since"
msgstr ""
#: src/fellchensammlung/models.py:84
msgid "Organization"
msgstr ""
#: src/fellchensammlung/models.py:85
msgid "Link to further information"
msgstr ""
#: src/fellchensammlung/models.py:86
msgid "Only group adoption"
msgstr ""
#: src/fellchensammlung/models.py:144
msgid "Date of birth"
msgstr ""
#: src/fellchensammlung/models.py:222
msgid "ID dieses reports"
msgstr ""
#: src/fellchensammlung/models.py:223
msgid "ID"
msgstr ""
#: src/fellchensammlung/models.py:273
msgid "Enter a natural languages name (e.g. English, French, Japanese etc.)."
msgstr ""
#: src/fellchensammlung/models.py:279
msgid ""
"Enter the language code for this language. For further information see "
"http://www.i18nguy.com/unicode/language-identifiers.html"
msgstr ""
#: src/fellchensammlung/models.py:280
msgid "Language code"
msgstr ""
#: src/fellchensammlung/models.py:287
#: src/fellchensammlung/templates/fellchensammlung/details/detail-member.html:11
msgid "Language"
msgstr ""
#: src/fellchensammlung/models.py:288
msgid "Languages"
msgstr ""
#: src/fellchensammlung/models.py:323
msgid "User"
msgstr ""
#: src/fellchensammlung/models.py:325
msgid "Preferred language"
msgstr ""
#: src/fellchensammlung/models.py:329
msgid "Member"
msgstr ""
#: src/fellchensammlung/models.py:330
msgid "Members"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/details/detail-member.html:7
msgid "Username"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/details/detail-member.html:8
msgid "E-Mail"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/details/detail-member.html:13
msgid "No preferred language set."
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/index.html:5
msgid "Notfellchen - Vermittlungen finden"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/index.html:6
msgid ""
"Alle Tiere brauchen ein liebendes Zuhause. Damit keins vergessen wird gibt "
"es diese Seite. Entwickelt und betreut von "
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/index.html:8
msgid "Aktuelle Vermittlungen"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/modqueue.html:5
msgid "Modqueue"
msgstr ""
#: src/fellchensammlung/templates/fellchensammlung/modqueue.html:6
msgid ""
"Erlaube oder blockiere Vermittlungsanzeigen die bisher noch zurückgehaltemn "
"werden "
msgstr ""
#: src/templates/django_registration/activate.html:6
msgid "Account activation failed"
msgstr ""
#: src/templates/django_registration/activation_complete.html:5
msgid "You are now activated. Have fun."
msgstr ""
#: src/templates/django_registration/activation_email_body.txt:2
msgid "Activate account at"
msgstr ""
#: src/templates/django_registration/activation_email_body.txt:4
msgid "Activate by clicking this link"
msgstr ""
#: src/templates/django_registration/activation_email_body.txt:5
msgid "or open the following link in your browser"
msgstr ""
#: src/templates/django_registration/activation_email_body.txt:8
#, python-format
msgid "Link is valid for %(expiration_days)s days."
msgstr ""
#: src/templates/django_registration/activation_email_subject.txt:1
msgid "Account activation on"
msgstr ""
#: src/templates/django_registration/activation_failed.html:5
msgid ""
"Activation failed. Please send an e-mail to info@notfellchen.org to get an "
"account."
msgstr ""
#: src/templates/django_registration/registration_closed.html:5
msgid "Registration is currently closed."
msgstr ""
#: src/templates/django_registration/registration_complete.html:5
msgid "You are now registered. Activation email sent."
msgstr ""
#: src/templates/django_registration/registration_form.html:10
msgid "Submit"
msgstr ""
#: src/templates/django_registration/registration_form.html:13
#: src/templates/registration/login.html:11
msgid "You're already logged in."
msgstr ""
#: src/templates/registration/logged_out.html:5
msgid "Logged out"
msgstr ""
#: src/templates/registration/logged_out.html:6
msgid "Click here to login again."
msgstr ""
#: src/templates/registration/login.html:7
msgid "Your username and password didn't match. Please try again."
msgstr ""
#: src/templates/registration/login.html:13
msgid "Please login to see this page."
msgstr ""
#: src/templates/registration/login.html:30
msgid "login"
msgstr ""
#: src/templates/registration/login.html:34
msgid "Lost password?"
msgstr ""
#: src/templates/registration/password_reset_complete.html:5
msgid "The password has been changed!"
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:6
msgid "Please enter (and confirm) your new password."
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:12
msgid "New password"
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:17
msgid "Confirm password"
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:22
msgid "Change my password"
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:27
msgid "Password reset failed"
msgstr ""
#: src/templates/registration/password_reset_confirmation.html:28
msgid ""
"The password reset link was invalid, possibly because it has already been "
"used. Please request a new password reset."
msgstr ""
#: src/templates/registration/password_reset_done.html:5
msgid ""
"We've emailed you instructions for setting your password. If they haven't "
"arrived in a few minutes, check your spam folder."
msgstr ""
#: src/templates/registration/password_reset_email.html:2
msgid "Someone asked for password reset for your email. Follow the link below:"
msgstr ""
#: src/templates/registration/password_reset_form.html:10
msgid "Password reset"
msgstr ""
#: src/templates/registration/password_reset_form.html:11
msgid "Provide the e-mail address that is connected with your account"
msgstr ""
#: src/templates/registration/password_reset_form.html:13
msgid "Reset"
msgstr ""

View File

@ -138,12 +138,13 @@ MIDDLEWARE = [
# Static file serving & caching # Static file serving & caching
'whitenoise.middleware.WhiteNoiseMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
# Needs to be after SessionMiddleware and before CommonMiddleware
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'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 = 'notfellchen.urls' ROOT_URLCONF = 'notfellchen.urls'
@ -211,6 +212,7 @@ AUTH_PASSWORD_VALIDATORS = [
# https://docs.djangoproject.com/en/3.2/topics/i18n/ # https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = config.get('locale', 'default', fallback='en') LANGUAGE_CODE = config.get('locale', 'default', fallback='en')
LANGUAGE_COOKIE_NAME = "selected-language"
TIME_ZONE = config.get('locale', 'timezone', fallback='UTC') TIME_ZONE = config.get('locale', 'timezone', fallback='UTC')
USE_I18N = True USE_I18N = True
@ -220,7 +222,7 @@ USE_L10N = True
USE_TZ = True USE_TZ = True
LANGUAGES = ( LANGUAGES = (
('en-us', _('English')), ('en', _('English')),
('de', _('German')), ('de', _('German')),
) )

View File

@ -14,6 +14,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
from django.conf import settings from django.conf import settings
@ -21,10 +22,13 @@ from django.conf import settings
from django.conf.urls.static import static from django.conf.urls.static import static
urlpatterns = [ urlpatterns = [
path("", include("fellchensammlung.urls")),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
] ]
urlpatterns += i18n_patterns (
path("", include("fellchensammlung.urls")),
)
if settings.DEBUG: if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, urlpatterns += static(settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT) document_root=settings.MEDIA_ROOT)