Simple language select as custom template tag
"django.middleware.locale.LocaleMiddleware"inMIDDLEWARE_CLASSES/MIDDLEWARE"django.core.context_processors.request"inTEMPLATE_CONTEXT_PROCESSORS/TEMPLATES['OPTIONS']['context_processors']
To use django_languageselect in a project, add it to INSTALLED_APPS
INSTALLED_APPS = [
*INSTALLED_APPS,
'django_languageselect',
]Then add its endpoint to your urls.py. It's important to keep the languageselect_index name when using the provided template tag!
from django.urls import path
from django_languageselect.views import IndexView
urlpatterns = [
path("languageselect", IndexView.as_view(), name="languageselect_index"),
]Use the languageselect template tag where you wish to show the language selection:
{% load languageselect %}
{% languageselect %}This will render all languages in your LANGUAGES setting to select from.
languageis the only required parameter expecting a two-letter ISO 639 language code.next- optionally pass the URL to redirect to after the language has been changed. The template tag redirects to the current URL.
Feel free to use your own template, just add languageselect/layer.html to the template folder of an app that is earlier in your INSTALLED_APPS than django_languageselect.
Tests will be automatically run by travis on commit to master.
They can also be executed locally using docker-compose by running docker-compose up
This project makes use of RegioHelden's reusable GitHub workflows.
Make a new release by manually triggering the Open release PR workflow.