def _get_translator(lang, graceful_fail=False, **kwargs):
 from pylons import config
 if (not isinstance(lang, list)):
  lang = [lang]
 try:
  translator = translation(config['pylons.package'], I18N_PATH, languages=lang, **kwargs)
 except IOError as ioe:
  if graceful_fail:
   translator = NullTranslations()
  else:
   raise LanguageError(('IOError: %s' % ioe))
 translator.pylons_lang = lang
 return translator

def _get_translator ( lang , graceful_fail = False , ** kwargs ) : from pylons import config if ( not isinstance ( lang , list ) ) : lang = [ lang ] try : translator = translation ( config [ 'pylons.package' ] , I18N_PATH , languages = lang , ** kwargs ) except IOError as ioe : if graceful_fail : translator = NullTranslations ( ) else : raise LanguageError ( ( 'IOError: %s' % ioe ) ) translator . pylons_lang = lang return translator
utility method to get a valid translator object from a language name .