1
from django.utils import translation
3
class PybbMiddleware(object):
4
def process_request(self, request):
5
if request.user.is_authenticated():
6
profile = request.user.pybb_profile
7
language = translation.get_language_from_request(request)
9
if not profile.language:
10
profile.language = language
12
#print 'Just now set profile language', profile.language
14
if profile.language and profile.language != language:
15
request.session['django_language'] = profile.language
16
translation.activate(profile.language)
17
request.LANGUAGE_CODE = translation.get_language()
18
#print 'Setuping request language', profile.language