def translation_set_language(request, select_language):
 select_language = translation_allowed_language(select_language)
 if translation.check_for_language(select_language):
  fallback = False
 else:
  select_language = django_settings.LANGUAGES[0][0]
  fallback = True
 translation.activate(select_language)
 request.LANGUAGE_CODE = translation.get_language()
 if hasattr(request, u'session'):
  if (select_language != request.session.get(LANGUAGE_SESSION_KEY)):
   request.session[LANGUAGE_SESSION_KEY] = select_language
 elif ((request.method == u'GET') and (not fallback)):
  response = HttpResponseRedirect(request.get_full_path())
  response.set_cookie(str(LANGUAGE_COOKIE_NAME), select_language)
  return response

def translation_set_language ( request , select_language ) : select_language = translation_allowed_language ( select_language ) if translation . check_for_language ( select_language ) : fallback = False else : select_language = django_settings . LANGUAGES [ 0 ] [ 0 ] fallback = True translation . activate ( select_language ) request . LANGUAGE_CODE = translation . get_language ( ) if hasattr ( request , u'session' ) : if ( select_language != request . session . get ( LANGUAGE_SESSION_KEY ) ) : request . session [ LANGUAGE_SESSION_KEY ] = select_language elif ( ( request . method == u'GET' ) and ( not fallback ) ) : response = HttpResponseRedirect ( request . get_full_path ( ) ) response . set_cookie ( str ( LANGUAGE_COOKIE_NAME ) , select_language ) return response
set and activate a language .