localization config and url

This commit is contained in:
Thomas Nahuel Rusiecki 2024-11-26 17:52:27 -03:00
parent bd2705c86b
commit 449fdacd02
2 changed files with 24 additions and 3 deletions

View file

@ -65,7 +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 = [
@ -119,7 +121,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',
}
},
},
]
@ -172,8 +180,9 @@ if TIME_ZONE == "UTC":
USE_L10N = True
LANGUAGES = [
('es', 'Spanish'),
('en', 'English'),
('es', 'spanish'),
('en', 'english'),
('ca', 'català'),
]
# Static files (CSS, JavaScript, Images)

View file

@ -16,6 +16,10 @@ Including another URLconf
"""
from django.conf import settings
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')),
@ -35,3 +39,11 @@ if settings.DPP:
path('dpp/', include('dpp.urls')),
path('did/', include('did.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)