From 24729bf6b75ffb8e3ed40d0362967759586bc0ed Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Thu, 23 Jan 2020 17:28:53 +0100 Subject: [PATCH] Configure languages and enable Locale middleware --- userpanel/settings.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/userpanel/settings.py b/userpanel/settings.py index d14b228..cb5ce35 100644 --- a/userpanel/settings.py +++ b/userpanel/settings.py @@ -13,7 +13,10 @@ https://docs.djangoproject.com/en/2.2/ref/settings/ import os from decouple import config, Csv +from django.utils.translation import gettext_lazy as _ from dj_database_url import parse as db_url + + # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -56,6 +59,7 @@ INSTALLED_APPS = [ MIDDLEWARE = [ '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', @@ -126,7 +130,13 @@ SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies" # Internationalization # https://docs.djangoproject.com/en/2.2/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = config('LANGUAGE_CODE', 'en-us') + +LANGUAGES = [ + ('ca', _('Catalan')), + ('en', _('English')), + ('es', _('Spanish')), +] TIME_ZONE = 'UTC'