#NEWLINE# def make_select_languages( languages ) : #NEWLINE# #INDENT# from uliweb.i18n import get_language , format_locale #NEWLINE# from uliweb.contrib.i18n import LANGUAGES #NEWLINE# lang = get_language ( ) #NEWLINE# s = [ ] #NEWLINE# s . append ( '<script type="text/javascript">\nfunction SetCookie( name, value, expires, path, domain, secure ) \n{\nvar today = new Date();\ntoday.setTime( today.getTime() );\npath=\'/\';\nif ( expires )\n{\nexpires = expires * 1000 * 60 * 60 * 24;\n}\nvar expires_date = new Date( today.getTime() + (expires) );\n\ndocument.cookie = name + "=" +escape( value ) +\n( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + \n( ( path ) ? ";path=" + path : "" ) + \n( ( domain ) ? ";domain=" + domain : "" ) +\n( ( secure ) ? ";secure" : "" );\nwindow.location.reload();\n}\n</script>' ) #NEWLINE# s . append ( '<form class="lang_dropdown" action="javascript:SetCookie(\'uliweb_language\',this.document.changelang.lang.value)" name="changelang" method="post">\n<label for="lang">Change Language:</label>\n<select onchange="this.form.submit()" id="lang" name="lang">' ) #NEWLINE# for k in languages : #NEWLINE# #INDENT# k = format_locale ( k ) #NEWLINE# v = LANGUAGES . get ( k , '' ) #NEWLINE# if ( not v ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( k == lang ) : #NEWLINE# #INDENT# select = 'selected="selected" ' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# select = '' #NEWLINE# #UNINDENT# s . append ( ( '<option %svalue="%s">%s</option>' % ( select , k , v ) ) ) #NEWLINE# #UNINDENT# s . append ( '</select>\n</form>' ) #NEWLINE# return '' . join ( s )