def select_lang(cache, function):
 if (function.argument_types() not in ([u'STRING'], [u'IDENT'])):
  raise ExpressionError((u'Expected a single string or ident for :lang(), got %r' % function.arguments))
 lang = function.arguments[0].value
 if lang:
  lang = ascii_lower(lang)
  lp = (lang + u'-')
  for (tlang, elem_set) in cache.lang_map.iteritems():
   if ((tlang == lang) or ((tlang is not None) and tlang.startswith(lp))):
    for elem in elem_set:
     (yield elem)

def select_lang ( cache , function ) : if ( function . argument_types ( ) not in ( [ u'STRING' ] , [ u'IDENT' ] ) ) : raise ExpressionError ( ( u'Expected a single string or ident for :lang(), got %r' % function . arguments ) ) lang = function . arguments [ 0 ] . value if lang : lang = ascii_lower ( lang ) lp = ( lang + u'-' ) for ( tlang , elem_set ) in cache . lang_map . iteritems ( ) : if ( ( tlang == lang ) or ( ( tlang is not None ) and tlang . startswith ( lp ) ) ) : for elem in elem_set : ( yield elem )
implement :lang() .