def to_language(locale):
 if ('_' in locale):
  return to_language(translation.trans_real.to_language(locale))
 elif ('-' in locale):
  (lang, region) = locale.lower().split('-')
  if (region == 'latn'):
   region = region.capitalize()
  else:
   region = region.upper()
  return ('%s-%s' % (lang, region))
 else:
  return translation.trans_real.to_language(locale)

def to_language ( locale ) : if ( '_' in locale ) : return to_language ( translation . trans_real . to_language ( locale ) ) elif ( '-' in locale ) : ( lang , region ) = locale . lower ( ) . split ( '-' ) if ( region == 'latn' ) : region = region . capitalize ( ) else : region = region . upper ( ) return ( '%s-%s' % ( lang , region ) ) else : return translation . trans_real . to_language ( locale )
turns a locale name into a language name .