MediaWiki:Gadget-WiktSidebarTranslation.js
Let op! Nadat u de veranderingen heeft opgeslagen, moet u de cache van uw browser nog legen om ze daadwerkelijk te zien.
Mozilla (incl. Firefox) | Ctrl+Shift+R |
Internet Explorer | Ctrl+F5 |
Opera | F5 |
Safari | Cmd+R |
Konqueror | F5 |
/////////////////////////////////////////////////////////////////////////
// Translates the 'in other languages' list in the sidebar to English. //
// //
// By Tra, Voice_of_All, bequw //
/////////////////////////////////////////////////////////////////////////
importScript('MediaWiki:langcode2name.js');
function languagereplace () {
//Can be caused by delay in timing
if(typeof(langcode2name) == 'undefined'){
if(! document.callbacks_langcode )
document.callbacks_langcode = new Object();
document.callbacks_langcode['sidebartranslate'] = languagereplace;
return false;
}
function sortByLang(a, b) {
var x = a.Lang.toLowerCase();
var y = b.Lang.toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
function LangItem(Lang, className, href, innerHTML, title) {
this.Lang = Lang;
this.className = className;
this.href = href;
this.innerHTML = innerHTML;
this.title = title;
}
if (document.getElementById('p-lang')) {
var LangNodes=document.getElementById('p-lang').getElementsByTagName('ul')[0].getElementsByTagName('li');
var myData = new Array();
for( var x = 0; x < LangNodes.length; x++ ) {
LangNodes[x].getElementsByTagName('a')[0].innerHTML = localtoEnglish(LangNodes[x].getElementsByTagName('a')[0].innerHTML);
myData[myData.length++] = new LangItem(LangNodes[x].getElementsByTagName('a')[0].innerHTML, LangNodes[x].className, LangNodes[x].getElementsByTagName('a')[0].href, LangNodes[x].getElementsByTagName('a')[0].innerHTML, LangNodes[x].getElementsByTagName('a')[0].title);
}
myData.sort(sortByLang);
for( var x = 0; x < myData.length; x++ ) {
LangNodes[x].className = myData[x].className;
LangNodes[x].getElementsByTagName('a')[0].href = myData[x].href;
LangNodes[x].getElementsByTagName('a')[0].innerHTML = myData[x].innerHTML;
LangNodes[x].getElementsByTagName('a')[0].title = myData[x].title;
}
}
}
$(languagereplace);
function localtoEnglish(localname) {
lcode = FLname2code(localname)
return ((typeof(lcode) == 'undefined') ? localname : langcode2name(lcode))
}