User:AT/langbox.js

function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) { var node = document.getElementById(portlet); if ( !node ) return null; node = node.getElementsByTagName( "ul" )[0]; if ( !node ) return null; var link = document.createElement( "a" ); link.appendChild( document.createTextNode( text ) ); link.href = href; var item = document.createElement( "li" ); item.appendChild( link ); if ( id ) item.id = id; if ( accesskey ) { link.setAttribute( "accesskey", accesskey ); tooltip += " ["+accesskey+"]"; } if ( tooltip ) { link.setAttribute( "title", tooltip ); } if ( accesskey && tooltip ) { updateTooltipAccessKeys( new Array( link ) ); } if ( nextnode && nextnode.parentNode == node ) node.insertBefore( item, nextnode ); else node.appendChild( item ); // IE compatibility (?) return item; }

function addLangSite( name, lang) { var url = 'http://translate.google.com/translate?u=wiki.guildwars.com%2Fwiki%2F' + wgCanonicalNamespace; if(wgCanonicalNamespace != '') { url +='%3A' } url += wgTitle + '&hl=en&ie=UTF8&sl=en&tl=' + lang; addPortletLink('p-lang', url, name, 'lang-link', name, ''); }

function langportlet { document.getElementById('p-tb').innerHTML += ' '+' '+ ' '+ ' other languages '+ ' '+ ' '; }

function langbox { langportlet; addLangSite('Français', 'fr'); addLangSite('Deutsch', 'de'); addLangSite('Español', 'es'); addLangSite('Italiano', 'it'); addLangSite('Nederlands', 'nl'); addLangSite('中文（简体)', 'zh'); addLangSite('中文（繁體）', 'zh-TW');  if ( typeof( userLanguages ) != 'undefined' )     userLanguages; }

addOnloadHook(langbox);