Configure languages and enable Locale middleware

This commit is contained in:
Santiago Lamora 2020-01-23 17:28:53 +01:00
parent af3bf2cda7
commit 24729bf6b7

View file

@ -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'