~widelands-dev/widelands-website/add_DISPLAY_hint

« back to all changes in this revision

Viewing changes to pybb/middleware.py

  • Committer: Holger Rapp
  • Date: 2009-02-25 16:55:36 UTC
  • Revision ID: sirver@kallisto.local-20090225165536-3abfhjx8qsgtzyru
- Added my hacked version of pybb. Remerging new versions is very difficult at this point :(

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from django.utils import translation
 
2
 
 
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)
 
8
 
 
9
            if not profile.language:
 
10
                profile.language = language
 
11
                profile.save()
 
12
                #print 'Just now set profile language', profile.language
 
13
 
 
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