def try_set_language(lang):
 try:
  django.utils.translation.activate(lang)
  if (trans_real.catalog()._catalog is None):
   raise Exception('Invalid language!')
 except Exception:
  django.utils.translation.activate('en')

def try_set_language ( lang ) : try : django . utils . translation . activate ( lang ) if ( trans_real . catalog ( ) . _catalog is None ) : raise Exception ( 'Invalid language!' ) except Exception : django . utils . translation . activate ( 'en' )
tries to activate language .