default back to English @ "/" - internationalization

Hello everyone,

I’ve got an app that runs on an iPad in our lobby - it’s basically part of a visitor manager system. The application offers to choose from 3 languages, English being the default.

When users have checked-in/out the app automatically redirects to “/” in order to have a smooth user experience. Additionally I’d like to change the language back to English if one of the other 2 languages were chosen.

I’ve tried to approach this via my index_view and also via custom middleware, but I always ended up having one if two issues:

  1. Changing the language works - but it doesn’t reset back to English on reload/redirect
  2. I can’t change the language at all.

Anyone with a solution or a hint for me?
Thanks in advance!

Hello there!
First of all it would be good for us to know your urls.py configuration, the one that have i18n_patterns probably.

from django.conf.urls.i18n import i18n_patterns
from django.views.i18n import set_language

urlpatterns = [
    ...
    path("", Guestbook.views.index, name="index"),
    path('i18n/', include('django.conf.urls.i18n')),
]

urlpatterns += i18n_patterns(
    path('set_language/', set_language, name='set_language'),
)