def to_javascript(rule):
 to_js = _JavaScriptCompiler().compile
 result = ['(function(n) { return ']
 for (tag, ast) in PluralRule.parse(rule).abstract:
  result.append(('%s ? %r : ' % (to_js(ast), tag)))
 result.append(('%r; })' % _fallback_tag))
 return ''.join(result)

def to_javascript ( rule ) : to_js = _JavaScriptCompiler ( ) . compile result = [ '(function(n) { return ' ] for ( tag , ast ) in PluralRule . parse ( rule ) . abstract : result . append ( ( '%s ? %r : ' % ( to_js ( ast ) , tag ) ) ) result . append ( ( '%r; })' % _fallback_tag ) ) return '' . join ( result )
convert a list/dict of rules or a pluralrule object into a javascript function .