14 lines
497 B
Python
14 lines
497 B
Python
|
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)
|