From 10887c290b9ea4520932718351dc0a7c933ec387 Mon Sep 17 00:00:00 2001 From: Laura Porter Date: Thu, 15 Sep 2022 15:26:22 +0100 Subject: [PATCH] Prevent users from being able to choose their own locale/language A user on the team, who is based in the USA, noticed that the i18n strings in the application were not being translated. We realised their browser is set up to send en-US as the locale in an Accept header, and as a result django is trying (and failing) to find an en-US locale file. This is despite the application being set up to use en-GB as the default. Additionally, other country locales do not have the same issue (e.g ca-ES) One way to attempt to resolve this is to prevent users from being able to select their language, by removing the `LocaleMiddleware`. We currently do not have any other locales to offer, and we have no current plans to add any. If/when we decide to add more locales to the application, we can look into reinstating the middleware and figuring out why en-GB is not being treated as the default when a user's locale is set to en-US https://docs.djangoproject.com/en/4.1/topics/i18n/translation/#how-django-discovers-language-preference --- config/settings/base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/config/settings/base.py b/config/settings/base.py index b20e62cc9..231aace32 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -121,7 +121,6 @@ "django.middleware.security.SecurityMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", - "django.middleware.locale.LocaleMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",