def langnames_to_langcodes(names):
 iso639 = _load_iso639()
 translate = _
 ans = {}
 names = set(names)
 for (k, v) in iso639['by_3t'].iteritems():
  tv = translate(v)
  if (tv in names):
   names.remove(tv)
   ans[tv] = k
  if (not names):
   break
 for x in names:
  ans[x] = None
 return ans

def langnames_to_langcodes ( names ) : iso639 = _load_iso639 ( ) translate = _ ans = { } names = set ( names ) for ( k , v ) in iso639 [ 'by_3t' ] . iteritems ( ) : tv = translate ( v ) if ( tv in names ) : names . remove ( tv ) ans [ tv ] = k if ( not names ) : break for x in names : ans [ x ] = None return ans
given a list of localized language names return a mapping of the names to 3 letter iso 639 language codes .