<commit_before>from django.views.generic.base import View
from django.http.response import HttpResponseRedirect
from django.utils.http import is_safe_url
from django.core.urlresolvers import reverse_lazy
from django.utils import translation

from urljects import U, URLView

class ChangeLanguage(View, URLView):
    url = U / 'lang' / r'(?P<code>\w+)'
    url_name = 'change_language'

    def get(self, request, code):
        if translation.check_for_language(code):
            request.session[translation.LANGUAGE_SESSION_KEY] = code
        return HttpResponseRedirect(reverse_lazy('www:index'))<commit_msg>fix language switching<commit_after>from django.views.generic.base import View
from django.http.response import HttpResponseRedirect
from django.utils.http import is_safe_url
from django.core.urlresolvers import reverse
from django.utils import translation

from urljects import U, URLView

class ChangeLanguage(View, URLView):
    url = U / 'lang' / r'(?P<code>\w+)'
    url_name = 'change_language'

    def get(self, request, code):
        if translation.check_for_language(code):
            request.session[translation.LANGUAGE_SESSION_KEY] = code
            translation.activate(code)
        return HttpResponseRedirect(reverse('www:index'))
{'fraction_non_alphanumeric': 0.09112519809825674, 'fraction_numerical': 0.0, 'mean_word_length': 4.467532467532467, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7536399', 'n_tokens_mistral': 357, 'n_tokens_neox': 354, 'n_words': 90}