src/ldt/ldt/ldt_utils/middleware/userprofile.py
author cavaliet
Wed, 09 Oct 2013 10:14:55 +0200
changeset 1240 a9d953866a50
parent 1191 b6e0b1811723
permissions -rw-r--r--
Added tag V01.51.05 for changeset 150a76f0f05c

from django.utils import translation
from django.conf import settings

class LanguageMiddleware(object):

    def process_request(self, request):
        
        if request.user.is_authenticated():
            language = request.user.language
        else:
            language = settings.LANGUAGE_CODE[:2]
            request.user.is_regular = False
            
        translation.activate(language)
        request.LANGUAGE_CODE = translation.get_language()