def regularize_locales(locales):
 locales = [regularize_locale(loc) for loc in locales]
 locales_set = set(locales)
 for loc in locales:
  (yield loc)
  parts = loc.split(u'_')
  if ((len(parts) > 1) and (parts[0] not in locales_set)):
   (yield parts[0])
  alias = ALIASES.get(loc)
  if (alias and (alias not in locales_set)):
   (yield alias)
 if ((u'en' not in locales_set) and (u'en_us' not in locales_set)):
  (yield u'en')
  (yield u'en_us')

def regularize_locales ( locales ) : locales = [ regularize_locale ( loc ) for loc in locales ] locales_set = set ( locales ) for loc in locales : ( yield loc ) parts = loc . split ( u'_' ) if ( ( len ( parts ) > 1 ) and ( parts [ 0 ] not in locales_set ) ) : ( yield parts [ 0 ] ) alias = ALIASES . get ( loc ) if ( alias and ( alias not in locales_set ) ) : ( yield alias ) if ( ( u'en' not in locales_set ) and ( u'en_us' not in locales_set ) ) : ( yield u'en' ) ( yield u'en_us' )
yield locale strings in the same format as they are in locales .