Translation support and minor login view changes #35

Open
rskthomas wants to merge 20 commits from feature/translation into main
2 changed files with 24 additions and 2 deletions
Showing only changes of commit 37caeeb6be - Show all commits

View file

@ -65,6 +65,9 @@ ENABLE_EMAIL = config("ENABLE_EMAIL", default=True, cast=bool)
EVIDENCES_DIR = config("EVIDENCES_DIR", default=os.path.join(BASE_DIR, "db")) EVIDENCES_DIR = config("EVIDENCES_DIR", default=os.path.join(BASE_DIR, "db"))
LOCALE_PATHS = [
os.path.join(BASE_DIR, 'locale'),
]
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
@ -116,7 +119,13 @@ TEMPLATES = [
"django.template.context_processors.request", "django.template.context_processors.request",
"django.contrib.auth.context_processors.auth", "django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages", "django.contrib.messages.context_processors.messages",
"django.template.context_processors.i18n",
], ],
'libraries':{
'get_language_code': 'dashboard.templatetags.language_code',
}
}, },
}, },
] ]
@ -169,8 +178,9 @@ if TIME_ZONE == "UTC":
USE_L10N = True USE_L10N = True
LANGUAGES = [ LANGUAGES = [
('es', 'Spanish'), ('es', 'spanish'),
('en', 'English'), ('en', 'english'),
('ca', 'català'),
] ]
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)

View file

@ -16,6 +16,10 @@ Including another URLconf
""" """
from django.urls import path, include from django.urls import path, include
from django.conf.urls.i18n import i18n_patterns
from django.conf import settings
from django.conf.urls.static import static
from django.views.i18n import set_language
urlpatterns = [ urlpatterns = [
# path('api/', include('snapshot.urls')), # path('api/', include('snapshot.urls')),
@ -28,3 +32,11 @@ urlpatterns = [
path("lot/", include("lot.urls")), path("lot/", include("lot.urls")),
path('api/', include('api.urls')), path('api/', include('api.urls')),
] ]
urlpatterns += i18n_patterns(
path("language/", set_language, name='set_language'),
)
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)