diff --git a/dhub/settings.py b/dhub/settings.py index 0dc3d84..07b0713 100644 --- a/dhub/settings.py +++ b/dhub/settings.py @@ -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")) +LOCALE_PATHS = [ + os.path.join(BASE_DIR, 'locale'), +] # Application definition INSTALLED_APPS = [ @@ -116,7 +119,13 @@ TEMPLATES = [ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "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 LANGUAGES = [ - ('es', 'Spanish'), - ('en', 'English'), + ('es', 'spanish'), + ('en', 'english'), + ('ca', 'catalĂ '), ] # Static files (CSS, JavaScript, Images) diff --git a/dhub/urls.py b/dhub/urls.py index fba9bd3..4012f51 100644 --- a/dhub/urls.py +++ b/dhub/urls.py @@ -16,6 +16,10 @@ Including another URLconf """ 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 = [ # path('api/', include('snapshot.urls')), @@ -28,3 +32,11 @@ urlpatterns = [ path("lot/", include("lot.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)