User:DavRosen/SidebarReorderTranslate.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:DavRosen/SidebarReorderTranslate. |
//
// Changes sidebar language links to use Google Translate, rearranges them in a specific order, & displays their English names.
//
// The order was chosen based roughly on how many translation engines (of three I knew) support the language, then
// translatability/relatedness to English (Romance ahead of Germanic due to difficulty of verb grammar differences),
// and then some quirky measures based on avg edits per article, active users, etc.
// No doubt you would choose a different order. If you wonder why some small wikipedias are so high on the list,
// remember that it only shows up on a page when that language *does* have an article; how many *other* articles it has is
// less important than the likelihood that this one is good. A WP with very few articles will seldom have a link at all,
// no matter how high it may be on the overall list here.
// (Originally from DavRosen's bookmarklet WpSortLangLinks+LinksToGoogTranslV2draft)
//
// Bugs:
// o Removes the special bullets that identify languages having particularly good articles
// o When clicking on the edit link of a specific section, it has you editing the *next* section instead.
// o On articles with no language links, this script messes up the "Add links" link.
// o On certain pages such as the main page, it doesn't behave as expected...
//
addOnloadHook // for use as bookmarklet, comment out this line and uncomment the next
// javascript:
(function (){
var i, anchors;
var ul = document.querySelectorAll('div#p-lang')[0].querySelectorAll('ul')[0];
ul.insertAdjacentHTML('afterbegin', "<li><a id='SRTL-en'>English</a></li><li><a id='SRTL-simple'>Simple English</a></li><li><a id='SRTL-es'>Spanish</a></li><li><a id='SRTL-fr'>French</a></li><li><a id='SRTL-pt'>Portuguese</a></li><li><a id='SRTL-it'>Italian</a></li><li><a id='SRTL-nl'>Dutch</a></li><li><a id='SRTL-de'>German</a></li><li><a id='SRTL-ro'>Romanian</a></li><li><a id='SRTL-da'>Danish</a></li><li><a id='SRTL-no'>Norwegian</a></li><li><a id='SRTL-sv'>Swedish</a></li><li><a id='SRTL-ru'>Russian</a></li><li><a id='SRTL-cs'>Czech</a></li><li><a id='SRTL-bg'>Bulgarian</a></li><li><a id='SRTL-pl'>Polish</a></li><li><a id='SRTL-el'>Greek</a></li><li><a id='SRTL-ar'>Arabic</a></li><li><a id='SRTL-zh'>Chinese</a></li><li><a id='SRTL-tr'>Turkish</a></li><li><a id='SRTL-he'>Hebrew</a></li><li><a id='SRTL-th'>Thai</a></li><li><a id='SRTL-ja'>Japanese</a></li><li><a id='SRTL-ko'>Korean</a></li><li><a id='SRTL-hu'>Hungarian</a></li><li><a id='SRTL-fi'>Finnish</a></li><li><a id='SRTL-ht'>Haitian</a></li><li><a id='SRTL-lv'>Latvian</a></li><li><a id='SRTL-sr'>Serbian</a></li><li><a id='SRTL-sl'>Slovenian</a></li><li><a id='SRTL-sk'>Slovak</a></li><li><a id='SRTL-lt'>Lithuanian</a></li><li><a id='SRTL-fa'>Persian</a></li><li><a id='SRTL-ur'>Urdu</a></li><li><a id='SRTL-hi'>Hindi</a></li><li><a id='SRTL-zh-classical'>Classical Chinese</a></li><li><a id='SRTL-et'>Estonian</a></li><li><a id='SRTL-ca'>Catalan</a></li><li><a id='SRTL-af'>Afrikaans</a></li><li><a id='SRTL-yi'>Yiddish</a></li><li><a id='SRTL-bs'>Bosnian</a></li><li><a id='SRTL-uk'>Ukrainian</a></li><li><a id='SRTL-hr'>Croatian</a></li><li><a id='SRTL-mk'>Macedonian</a></li><li><a id='SRTL-ha'>Hausa</a></li><li><a id='SRTL-lo'>Lao</a></li><li><a id='SRTL-bn'>Bengali</a></li><li><a id='SRTL-id'>Indonesian</a></li><li><a id='SRTL-mt'>Maltese</a></li><li><a id='SRTL-so'>Somali</a></li><li><a id='SRTL-km'>Khmer</a></li><li><a id='SRTL-kn'>Kannada</a></li><li><a id='SRTL-ta'>Tamil</a></li><li><a id='SRTL-hy'>Armenian</a></li><li><a id='SRTL-ps'>Pashto</a></li><li><a id='SRTL-sq'>Albanian</a></li><li><a id='SRTL-az'>Azerbaijani</a></li><li><a id='SRTL-is'>Icelandic</a></li><li><a id='SRTL-mr'>Marathi</a></li><li><a id='SRTL-ka'>Georgian</a></li><li><a id='SRTL-be'>Belarusian</a></li><li><a id='SRTL-ga'>Irish</a></li><li><a id='SRTL-te'>Telugu</a></li><li><a id='SRTL-tl'>Tagalog</a></li><li><a id='SRTL-eo'>Esperanto</a></li><li><a id='SRTL-gl'>Galician</a></li><li><a id='SRTL-gu'>Gujarati</a></li><li><a id='SRTL-vi'>Vietnamese</a></li><li><a id='SRTL-cy'>Welsh</a></li><li><a id='SRTL-sw'>Swahili</a></li><li><a id='SRTL-la'>Latin</a></li><li><a id='SRTL-nn'>Norwegian (Nynorsk)</a></li><li><a id='SRTL-ms'>Malay</a></li><li><a id='SRTL-jv'>Javanese</a></li><li><a id='SRTL-eu'>Basque</a></li><li><a id='SRTL-ceb'>Cebuano</a></li><li><a id='SRTL-hmn'>Hmong</a></li><li><a id='SRTL-xh'>Xhosa</a></li><li><a id='SRTL-cr'>Cree</a></li><li><a id='SRTL-ch'>Chamorro</a></li><li><a id='SRTL-tw'>Twi</a></li><li><a id='SRTL-ak'>Akan</a></li><li><a id='SRTL-ee'>Ewe</a></li><li><a id='SRTL-ff'>Fula</a></li><li><a id='SRTL-tum'>Tumbuka</a></li><li><a id='SRTL-st'>Sesotho</a></li><li><a id='SRTL-ny'>Chichewa</a></li><li><a id='SRTL-ik'>Inupiak</a></li><li><a id='SRTL-dz'>Dzongkha</a></li><li><a id='SRTL-rn'>Kirundi</a></li><li><a id='SRTL-ve'>Venda</a></li><li><a id='SRTL-cdo'>Min Dong</a></li><li><a id='SRTL-fj'>Fijian</a></li><li><a id='SRTL-ts'>Tsonga</a></li><li><a id='SRTL-lg'>Luganda</a></li><li><a id='SRTL-sg'>Sango</a></li><li><a id='SRTL-cu'>Old Church Slavonic</a></li><li><a id='SRTL-chr'>Cherokee</a></li><li><a id='SRTL-iu'>Inuktitut</a></li><li><a id='SRTL-bm'>Bambara</a></li><li><a id='SRTL-bxr'>Buryat (Russia)</a></li><li><a id='SRTL-zu'>Zulu</a></li><li><a id='SRTL-got'>Gothic</a></li><li><a id='SRTL-ang'>Anglo-Saxon</a></li><li><a id='SRTL-roa-rup'>Aromanian</a></li><li><a id='SRTL-om'>Oromo</a></li><li><a id='SRTL-ab'>Abkhazian</a></li><li><a id='SRTL-pih'>Norfolk</a></li><li><a id='SRTL-ti'>Tigrinya</a></li><li><a id='SRTL-ks'>Kashmiri</a></li><li><a id='SRTL-bi'>Bislama</a></li><li><a id='SRTL-chy'>Cheyenne</a></li><li><a id='SRTL-ss'>Swati</a></li><li><a id='SRTL-as'>Assamese</a></li><li><a id='SRTL-pnt'>Pontic</a></li><li><a id='SRTL-sm'>Samoan</a></li><li><a id='SRTL-sd'>Sindhi</a></li><li><a id='SRTL-ki'>Kikuyu</a></li><li><a id='SRTL-tn'>Tswana</a></li><li><a id='SRTL-kaa'>Karakalpak</a></li><li><a id='SRTL-ace'>Acehnese</a></li><li><a id='SRTL-wuu'>Wu</a></li><li><a id='SRTL-av'>Avar</a></li><li><a id='SRTL-ig'>Igbo</a></li><li><a id='SRTL-rmy'>Romani</a></li><li><a id='SRTL-na'>Nauruan</a></li><li><a id='SRTL-ml'>Malayalam</a></li><li><a id='SRTL-jbo'>Lojban</a></li><li><a id='SRTL-wo'>Wolof</a></li><li><a id='SRTL-dsb'>Lower Sorbian</a></li><li><a id='SRTL-eml'>Emilian-Romagnol</a></li><li><a id='SRTL-arz'>Egyptian Arabic</a></li><li><a id='SRTL-lbe'>Lak</a></li><li><a id='SRTL-pap'>Papiamentu</a></li><li><a id='SRTL-kg'>Kongo</a></li><li><a id='SRTL-cbk-zam'>Zamboanga Chavacano</a></li><li><a id='SRTL-bar'>Bavarian</a></li><li><a id='SRTL-mwl'>Mirandese</a></li><li><a id='SRTL-or'>Oriya</a></li><li><a id='SRTL-diq'>Zazaki</a></li><li><a id='SRTL-tpi'>Tok Pisin</a></li><li><a id='SRTL-mn'>Mongolian</a></li><li><a id='SRTL-kab'>Kabyle</a></li><li><a id='SRTL-szl'>Silesian</a></li><li><a id='SRTL-arc'>Aramaic</a></li><li><a id='SRTL-zh-yue'>Cantonese</a></li><li><a id='SRTL-crh'>Crimean Tatar</a></li><li><a id='SRTL-ty'>Tahitian</a></li><li><a id='SRTL-kl'>Greenlandic</a></li><li><a id='SRTL-ext'>Extremaduran</a></li><li><a id='SRTL-tet'>Tetum</a></li><li><a id='SRTL-ksh'>Ripuarian</a></li><li><a id='SRTL-mdf'>Moksha</a></li><li><a id='SRTL-kbd'>Kabardian Circassian</a></li><li><a id='SRTL-si'>Sinhalese</a></li><li><a id='SRTL-pdc'>Pennsylvania German</a></li><li><a id='SRTL-ltg'>Latgalian</a></li><li><a id='SRTL-bjn'>Banjar</a></li><li><a id='SRTL-ay'>Aymara</a></li><li><a id='SRTL-mhr'>Meadow Mari</a></li><li><a id='SRTL-ce'>Chechen</a></li><li><a id='SRTL-rw'>Kinyarwanda</a></li><li><a id='SRTL-za'>Zhuang</a></li><li><a id='SRTL-frp'>Franco-Provençal/Arpitan</a></li><li><a id='SRTL-lad'>Ladino</a></li><li><a id='SRTL-als'>Alemannic</a></li><li><a id='SRTL-gn'>Guarani</a></li><li><a id='SRTL-lez'>Lezgian</a></li><li><a id='SRTL-ie'>Interlingue</a></li><li><a id='SRTL-hak'>Hakka</a></li><li><a id='SRTL-myv'>Erzya</a></li><li><a id='SRTL-sc'>Sardinian</a></li><li><a id='SRTL-gag'>Gagauz</a></li><li><a id='SRTL-fur'>Friulian</a></li><li><a id='SRTL-kw'>Cornish</a></li><li><a id='SRTL-xal'>Kalmyk</a></li><li><a id='SRTL-pfl'>Palatinate German</a></li><li><a id='SRTL-gan'>Gan</a></li><li><a id='SRTL-sn'>Shona</a></li><li><a id='SRTL-rm'>Romansh</a></li><li><a id='SRTL-krc'>Karachay-Balkar</a></li><li><a id='SRTL-srn'>Sranan</a></li><li><a id='SRTL-ckb'>Sorani</a></li><li><a id='SRTL-lij'>Ligurian</a></li><li><a id='SRTL-nds-nl'>Dutch Low Saxon</a></li><li><a id='SRTL-nso'>Northern Sotho</a></li><li><a id='SRTL-ug'>Uyghur</a></li><li><a id='SRTL-ln'>Lingala</a></li><li><a id='SRTL-dv'>Divehi</a></li><li><a id='SRTL-fo'>Faroese</a></li><li><a id='SRTL-pa'>Punjabi</a></li><li><a id='SRTL-nv'>Navajo</a></li><li><a id='SRTL-vec'>Venetian</a></li><li><a id='SRTL-pcd'>Picard</a></li><li><a id='SRTL-stq'>Saterland Frisian</a></li><li><a id='SRTL-gv'>Manx</a></li><li><a id='SRTL-sco'>Scots</a></li><li><a id='SRTL-csb'>Kashubian</a></li><li><a id='SRTL-vls'>West Flemish</a></li><li><a id='SRTL-tk'>Turkmen</a></li><li><a id='SRTL-sa'>Sanskrit</a></li><li><a id='SRTL-kv'>Komi</a></li><li><a id='SRTL-to'>Tongan</a></li><li><a id='SRTL-hsb'>Upper Sorbian</a></li><li><a id='SRTL-haw'>Hawaiian</a></li><li><a id='SRTL-udm'>Udmurt</a></li><li><a id='SRTL-bo'>Tibetan</a></li><li><a id='SRTL-li'>Limburgish</a></li><li><a id='SRTL-bh'>Bihari</a></li><li><a id='SRTL-os'>Ossetian</a></li><li><a id='SRTL-zh-min-nan'>Min Nan</a></li><li><a id='SRTL-an'>Aragonese</a></li><li><a id='SRTL-bcl'>Central_Bicolano</a></li><li><a id='SRTL-co'>Corsican</a></li><li><a id='SRTL-ast'>Asturian</a></li><li><a id='SRTL-vep'>Vepsian</a></li><li><a id='SRTL-ku'>Kurdish</a></li><li><a id='SRTL-hif'>Fiji Hindi</a></li><li><a id='SRTL-zea'>Zeelandic</a></li><li><a id='SRTL-nov'>Novial</a></li><li><a id='SRTL-nrm'>Norman</a></li><li><a id='SRTL-fiu-vro'>Võro</a></li><li><a id='SRTL-be-x-old'>Belarusian (Taraškievica)</a></li><li><a id='SRTL-sh'>Serbo-Croatian</a></li><li><a id='SRTL-koi'>Komi-Permyak</a></li><li><a id='SRTL-am'>Amharic</a></li><li><a id='SRTL-ia'>Interlingua</a></li><li><a id='SRTL-gd'>Scottish Gaelic</a></li><li><a id='SRTL-xmf'>Mingrelian</a></li><li><a id='SRTL-sah'>Sakha</a></li><li><a id='SRTL-rue'>Rusyn</a></li><li><a id='SRTL-ilo'>Ilokano</a></li><li><a id='SRTL-se'>Northern Sami</a></li><li><a id='SRTL-ne'>Nepali</a></li><li><a id='SRTL-fy'>West Frisian</a></li><li><a id='SRTL-nds'>Low Saxon</a></li><li><a id='SRTL-glk'>Gilaki</a></li><li><a id='SRTL-frr'>North Frisian</a></li><li><a id='SRTL-pam'>Kapampangan</a></li><li><a id='SRTL-lb'>Luxembourgish</a></li><li><a id='SRTL-wa'>Walloon</a></li><li><a id='SRTL-br'>Breton</a></li><li><a id='SRTL-bat-smg'>Samogitian</a></li><li><a id='SRTL-nah'>Nahuatl</a></li><li><a id='SRTL-tg'>Tajik</a></li><li><a id='SRTL-nap'>Neapolitan</a></li><li><a id='SRTL-scn'>Sicilian</a></li><li><a id='SRTL-su'>Sundanese</a></li><li><a id='SRTL-qu'>Quechua</a></li><li><a id='SRTL-mi'>Maori</a></li><li><a id='SRTL-cv'>Chuvash</a></li><li><a id='SRTL-pag'>Pangasinan</a></li><li><a id='SRTL-lmo'>Lombard</a></li><li><a id='SRTL-io'>Ido</a></li><li><a id='SRTL-mzn'>Mazandarani</a></li><li><a id='SRTL-ky'>Kirghiz</a></li><li><a id='SRTL-my'>Burmese</a></li><li><a id='SRTL-pi'>Pali</a></li><li><a id='SRTL-mrj'>Hill Mari</a></li><li><a id='SRTL-roa-tara'>Tarantino</a></li><li><a id='SRTL-ba'>Bashkir</a></li><li><a id='SRTL-oc'>Occitan</a></li><li><a id='SRTL-tt'>Tatar</a></li><li><a id='SRTL-pnb'>Western Panjabi</a></li><li><a id='SRTL-map-bms'>Banyumasan</a></li><li><a id='SRTL-kk'>Kazakh</a></li><li><a id='SRTL-yo'>Yoruba</a></li><li><a id='SRTL-uz'>Uzbek</a></li><li><a id='SRTL-bpy'>Bishnupriya Manipuri</a></li><li><a id='SRTL-bug'>Buginese</a></li><li><a id='SRTL-mg'>Malagasy</a></li><li><a id='SRTL-pms'>Piedmontese</a></li><li><a id='SRTL-vo'>Volapük</a></li><li><a id='SRTL-new'>Newar / Nepal Bhasa</a></li><li><a id='SRTL-war'>Waray-Waray</a></li><li><a id='SRTL-aa'>Afar</a></li><li><a id='SRTL-cho'>Choctaw</a></li><li><a id='SRTL-ho'>Hiri Motu</a></li><li><a id='SRTL-kr'>Kanuri</a></li><li><a id='SRTL-kj'>Kuanyama</a></li><li><a id='SRTL-mh'>Marshallese</a></li><li><a id='SRTL-mo'>Moldovan</a></li><li><a id='SRTL-mus'>Muscogee</a></li><li><a id='SRTL-ng'>Ndonga</a></li><li><a id='SRTL-ii'>Sichuan Yi</a></li>");
anchors=ul.querySelectorAll('a');
for (i=anchors.length; --i >= 0;){
var x=anchors[i];
var hsplit=x.hostname.split(".");
var lang=hsplit[0];
if (!x.title && !x.href) x.parentNode.style.display="none";
if ( hsplit.length==3 && hsplit[1]=="wikipedia" && hsplit[2]=="org"){
if (a=document.getElementById('SRTL-'+lang)){
var hr=x.href;
var ti=x.title+' ('+(x.textContent||'')+', '+lang+')';
x.removeAttribute('href');
x.parentNode.style.display="none";
a.href=hr;
if(!(a.title&&a.title!=''))a.title=ti;
a.parentNode.setAttribute('class','interwiki-'+lang);
a.parentNode.style.display=null;
if(!(a.parentNode.getAttribute('style')&&a.parentNode.getAttribute('style')!='')) a.parentNode.removeAttribute('style');}}}
/*javascript:*/
/*wpLinksToMsTransl*/(function(){
var i;for (i=document.links.length; --i >= 0;) {
var x=document.links[i], hsplit=x.hostname.split("."), lang=hsplit[0];
if (hsplit.length==3 && hsplit[1]=="wikipedia" && hsplit[2]=="org" && lang!="en" && lang!='simple' && x.hostname!=window.location.hostname) {
var e=(document.charset||document.characterSet);
/* x.appendChild(document.createTextNode(" ("+lang+")")); */ /*append parenthesized language code*/
x.setAttribute('href','http://translate.google.com/translate?u='+encodeURI(
'http://'+x.host+x.pathname+x.hash+x.search)+'&hl=en&langpair=auto|en&tbb=1&ie='+e);}}})()
});
//();
// uncomment line above only for bookmarklet