Add language switcher widget

This commit is contained in:
Carl van Tonder
2018-05-19 13:52:19 -04:00
parent 8a68b826d3
commit 0160e58491
4 changed files with 41 additions and 0 deletions

13
ojusomap/views.py Normal file
View File

@ -0,0 +1,13 @@
from django.utils import translation
from django.views.i18n import set_language
from django.views.generic import View
class LanguageDropdownView(View):
def get(self, request, *args, **kwargs):
lang_code = kwargs.get('language', None)
if lang_code is not None and translation.check_for_language(lang_code):
request.POST = request.POST.copy()
request.POST['language'] = lang_code
request.method = 'POST'
return set_language(request)