def to_locale(language):
 p = language.find('-')
 if (p >= 0):
  if (len(language[(p + 1):]) > 2):
   return (((language[:p].lower() + '_') + language[(p + 1)].upper()) + language[(p + 2):].lower())
  return ((language[:p].lower() + '_') + language[(p + 1):].upper())
 else:
  return language.lower()

def to_locale ( language ) : p = language . find ( '-' ) if ( p >= 0 ) : if ( len ( language [ ( p + 1 ) : ] ) > 2 ) : return ( ( ( language [ : p ] . lower ( ) + '_' ) + language [ ( p + 1 ) ] . upper ( ) ) + language [ ( p + 2 ) : ] . lower ( ) ) return ( ( language [ : p ] . lower ( ) + '_' ) + language [ ( p + 1 ) : ] . upper ( ) ) else : return language . lower ( )
turns a language name into a locale name .