diff --git a/musician/mixins.py b/musician/mixins.py index ba54587..6368467 100644 --- a/musician/mixins.py +++ b/musician/mixins.py @@ -1,6 +1,7 @@ from django.contrib.auth.mixins import UserPassesTestMixin from django.utils.translation import gettext_lazy as _ from django.views.generic.base import ContextMixin +from django.conf import settings from . import api, get_version from .auth import SESSION_KEY_TOKEN @@ -20,6 +21,7 @@ class CustomContextMixin(ContextMixin): context.update({ 'services_menu': services_menu, 'version': get_version(), + 'languages': settings.LANGUAGES, }) return context diff --git a/musician/templates/musician/base.html b/musician/templates/musician/base.html index beca2b9..b049cb0 100644 --- a/musician/templates/musician/base.html +++ b/musician/templates/musician/base.html @@ -81,9 +81,9 @@ {% trans "Language" %}
diff --git a/musician/urls.py b/musician/urls.py index b549a59..9b4c0ca 100644 --- a/musician/urls.py +++ b/musician/urls.py @@ -19,7 +19,7 @@ urlpatterns = [ path('billing/', views.BillingView.as_view(), name='billing'), path('bills/', views.ProfileSetLang, name='profile-set-lang'),
path('address/', views.MailView.as_view(), name='address-list'),
path('address/new/', views.MailCreateView.as_view(), name='address-create'),
path('address//', views.MailUpdateView.as_view(), name='address-update'),
diff --git a/musician/views.py b/musician/views.py
index 58d8819..38cb794 100644
--- a/musician/views.py
+++ b/musician/views.py
@@ -126,12 +126,12 @@ class ProfileView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
return context
-def ProfileSetLang(request, lang):
+def ProfileSetLang(request, code):
# set user language as active language
- if any(x[0] == lang for x in settings.LANGUAGES):
+ if any(x[0] == code for x in settings.LANGUAGES):
# http://127.0.0.1:8080/profile/setLang/es
- user_language = lang
+ user_language = code
translation.activate(user_language)
response = HttpResponseRedirect('/dashboard')