I'm trying to fix translations for a little Django project of mine. Unsing Django 2.2.12.
Current status is, that I can switch translations by setting LANGUAGE_CODE to different values. But I would like to switch translations by means of accept-language of browser - which does not seem to work. My suspicion is, that for some reason the middleware is not configured correctly.
This is what I have set for middlewares:
MIDDLEWARE_CLASSES = [
'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',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
And languges:
LANGUAGES = (
('de', 'German'),
('tr', 'Turkish'),
('en', 'English'),
('it', 'Italian'),
('fr', 'French'),
)
From the documentation I conclude, that if setting of LANGUAGE_CODE changes the translation - as is the case for me - then all other means of determining the proper translation have failed (including cookies). Because LANGUAGE_CODE is evaluated in the last step.
I would like to know how I could check it the middleware is doing it's thing correclty - and why it seems to ignore accept-language. Any hints on this are highly appreciated!