Question

Am Working on Arabic-English Translation using 'Model Translation'.Once i login and change to arabic and then logout language changes to english.

This is my logout code:,I have activated language after logout and it prints language as 'ar' but it displays english.Please help me

def profile_logout(request,mode=None, **kwars):
    lang = request.LANGUAGE_CODE
    response = logout(request, **kwars)
    translation.activate(lang)
    print "langggggggggggggggggggggggggggggggggg",request.LANGUAGE_CODE

    return response
Was it helpful?

Solution

I made some changes to my views by creating sessions.Hope someone will find use with this.This Worked for me.

def profile_logout(request,mode=None, **kwars):
    lang = request.LANGUAGE_CODE
    translation.activate(lang)
    language=request.session.get('django_language')
    print "languageeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",language
    response = logout(request, **kwars)
    if language is not None:
         request.session['django_language'] = language
         print 

"request.session['django_language']request.session['django_language']request.session['django_language']",request.session['django_language']
        return response

Or Refer:

``https://github.com/ludwiktrammer/django/commit/adfb2c114f94df4a77a9424001e300f0552c6e20

OTHER TIPS

You should activate the translation before processing the template, e.g. before calling logout. something like:

def profile_logout(request,mode=None, **kwars):
    lang = request.LANGUAGE_CODE
    translation.activate(lang)
    response = logout(request, **kwars)
    print "langggggggggggggggggggggggggggggggggg",request.LANGUAGE_CODE

    return response
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top