Jump to content

User:Alex Smotrov/iwtranslate.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
addOnloadHook (iwTranslate)

function iwTranslate(){

var iwEng = {
'Deutsch':'German',
'Français':'French',
'Polski':'Polish',
'日本語':'Japanese',
'Nederlands':'Dutch',
'Italiano':'Italian',
'Português':'Portuguese',
'Svenska':'Swedish',
'Español':'Spanish',
'Русский':'Russian',
'中文':'Chinese',
'Suomi':'Finnish',
'Norsk (bokmål)':'Norwegian',
'Esperanto':'Esperanto',
'Slovenčina':'Slovak',
'Dansk':'Danish',
'Česky':'Czech',
'עברית':'Hebrew',
'Català':'Catalan',
'Magyar':'Hungarian',
'Bahasa Indonesia':'Indonesian',
'Română':'Romanian',
'Українська':'Ukrainian',
'Српски / Srpski':'Serbian',
'Türkçe':'Turkish',
'Slovenščina':'Slovenian',
'Lietuvių':'Lithuanian',
'Български':'Bulgarian',
'한국어':'Korean',
'Eesti':'Estonian',
'Hrvatski':'Croatian',
'తెలుగు':'Telugu',
'العربية':'Arabic',
'Galego':'Galician',
'Norsk (nynorsk)':'Nynorsk',
'ไทย':'Thai',
'فارسی':'Persian',
'Ελληνικά':'Greek',
'Bahasa Melayu':'Malay',
'Euskara':'Basque',
'Ido':'Ido',
'Nnapulitano':'Neapolitan',
'বাংলা':'Bengali',
'Íslenska':'Icelandic',
'ქართული':'Georgian',
'Simple English':'Simple English',
'Tiếng Việt':'Vietnamese',
'Bosanski':'Bosnian',
'Lëtzebuergesch':'Luxembourgish',
'Brezhoneg':'Breton',
'Shqip':'Albanian',
'Македонски':'Macedonian',
'Walon':'Walloon',
'Srpskohrvatski / Српскохрватски':'Serbo-Croatian',
'Latina':'Latin',
'Krèyol ayisyen':'Haitian',
'Sicilianu':'Sicilian',
'Kurdî / كوردي':'Kurdish',
'Сибирской':'Siberian/Nort Russian',
'Latviešu':'Latvian',
'मराठी':'Marathi',
'Asturianu':'Asturian',
'Afrikaans':'Afrikaans',
'Basa Sunda':'Sundanese',
'Occitan':'Occitan',
'Ripoarisch':'Ripuarian',
'Беларуская':'Belarusian',
'Cymraeg':'Welsh',
'Tagalog':'Tagalog',
'O\'zbek':'Uzbek',
'தமிழ்':'Tamil',
'Corsu':'Corsican',
'Aragonés':'Aragonese',
'Чăвашла':'Chuvash',
'ಕನ್ನಡ':'Kannada',
'Gàidhlig':'Scottish Gaelic',
'Gaeilge':'Irish Gaelic',
'Tatarça':'Tatar',
'Azərbaycan':'Azeri',
'Vèneto':'Venetian',
'हिन्दी':'Hindi',
'Basa Jawa':'Javanese',
'Тоҷикӣ':'Tajik',
'Frysk':'West Frisian',
'اردو':'Urdu',
'Interlingua':'Interlingua',
'Plattdüütsch':'Low Saxon',
'Lumbaart':'Lombard',
'Alemannisch':'Alemannic',
'Հայերեն':'Armenian',
'Limburgs':'Limburgian',
'ייִדיש':'Yiddish',
'Kiswahili':'Swahili',
'Bân-lâm-gú':'Min Nan',
'Ilokano':'Ilokano',
'Føroyskt':'Faroese',
'Piemontèis':'Piedmontese',
'Nouormand':'Norman',
'Arpitan':'Franco-Provençal/Arpitan',
'Winaray':'Waray-Waray',
'Scots':'Scots',
'Kapampangan':'Kapampangan',
'Иронау':'Ossetian',
'Furlan':'Friulian',
'Cebuano':'Cebuano',
'粵語':'Cantonese',
'Nedersaksisch':'Dutch Low Saxon',
'മലയാളം':'Malayalam',
'Kernewek':'Cornish',
'Deitsch':'Pennsylvania German',
'नेपाल भाषा':'Newar / Nepal Bhasa',
'Oyghurque':'Uyghur',
'Líguru':'Ligurian',
'Novial':'Novial',
'Basa Banyumasan':'Banyumasan',
'Sámegiella':'Northern Sami',
'Ladino':'Ladino',
'Kaszëbsczi':'Kashubian',
'Malti':'Maltese',
'Volapük':'Volapük',
'አማርኛ':'Amharic',
'Anglo Saxon':'Anglo-Saxon',
'پښتو':'Pashto',
'West-Vlaoms':'West Flemish',
'संस्कृत':'Sanskrit',
'Žemaitėška':'Samogitian',
'Võro':'Voro',
'Māori':'Maori',
'Zazaki':'Zazaki',
'Runa Simi':'Quechua',
'Молдовеняскэ':'Moldovan',
'Reo Mā`ohi':'Tahitian',
'Монгол':'Mongolian',
'Lojban':'Lojban',
'कश्मीरी - (كشميري)':'Kashmiri',
'Nahuatl':'Nahuatl',
'Türkmen':'Turkmen',
'Tok Pisin':'Tok Pisin',
'Interlingue':'Interlingue',
'Кыргызча':'Kirghiz',
'नेपाली':'Nepali',
'Rumantsch':'Romansh',
'ܕܥܒܪܸܝܛ':'Assyrian Neo-Aramaic',
'Toki Pona':'Tokipona',
'Lingala':'Lingala',
'Ekakairũ Naoero':'Nauruan',
'faka-Tonga':'Tongan',
'Қазақша':'Kazakh',
'Armâneashti':'Aromanian',
'Удмурт':'Udmurt',
'Wollof':'Wolof',
'ગુજરાતી':'Gujarati',
'Malagasy':'Malagasy',
'བོད་ཡིག':'Tibetan',
'Tetun':'Tetum',
'ދިވެހިބަސް':'Divehi',
'古文 / 文言文':'Classical Chinese',
'Romani':'Romani',
'Sardu':'Sardinian',
'Авар':'Avar',
'Gaelg':'Manx',
'Kongo':'Kongo',
'吴语':'Wu',
'Pangasinan':'Pangasinan',
'Башҡорт':'Bashkir',
'ᏣᎳᎩ':'Cherokee',
'සිංහල':'Sinhalese',
'Bamanankan':'Bambara',
'سنڌي':'Sindhi',
'𐌲𐌿𐍄𐌹𐍃𐌺':'Gothic',
'Emilià':'Emilian-Romagnol',
'Hornjoserbsce':'Upper Sorbian',
'ភាសាខ្មែរ':'Khmer',
'Gagana Samoa':'Samoan',
'isiZulu':'Zulu',
'Boarisch':'Bavarian',
'ᐃᓄᒃᑎᑐᑦ':'Inuktitut',
'Myanmasa':'Burmese',
'Diné bizaad':'Navajo',
'словѣньскъ':'Old Church Slavonic',
'Yorùbá':'Yoruba',
'Kalaallisut':'Greenlandic',
'Аҧсуа':'Abkhazian',
'Hawai`i':'Hawaiian',
'ລາວ':'Lao',
'ਪੰਜਾਬੀ':'Punjabi',
'Soomaaliga':'Somali',
'Mìng-dĕ̤ng-ngṳ̄':'Min Dong',
'seSotho':'Sesotho',
'ইমার ঠার/বিষ্ণুপ্রিয়া মণিপুরী':'Bishnupriya Manipuri',
'Papiamentu':'Papiamentu',
'Avañe\'ẽ':'Guarani',
'Aymar':'Aymara',
'Kinyarwanda':'Kinyarwanda',
'گیلکی':'Gilaki',
'Zeêuws':'Zealandic',
'isiXhosa':'Xhosan',
'Na Vosa Vakaviti':'Fijian',
'Bislama':'Bislama',
'Коми':'Komi',
'Tarandíne':'Tarantino',
'Хальмг':'Kalmyk',
'पािऴ':'Pali',
'Setswana':'Tswana',
'(Cuengh)':'Zhuang',
'Kanuri':'Kanuri',
'Нохчийн':'Chechen',
'Zamboangueño':'Zamboanga Chavacano',
'هَوُسَ':'Hausa',
'chiTumbuka':'Tumbuka',
'Fulfulde':'Peul',
'Twi':'Twi',
'Igbo':'Igbo',
'Nēhiyaw / ᓀᐦᐃᔭᐤ':'Cree',
'ꆇꉙ':'Sichuan Yi',
'Iñupiak':'Inupiak',
'Kirundi':'Kirundi',
'Luganda':'Luganda',
'Afar':'Afar',
'Sängö':'Sango',
'Oromoo':'Oromo',
'Chi-Chewa':'Chichewa',
'chiShona':'Shona',
'Hiri Motu':'Hiri Motu',
'Akana':'Akan',
'Norfuk / Pitkern':'Norfolk',
'ᨅᨔ ᨕᨘᨁᨗ':'Buginese',
'অসমীয়া':'Assamese',
'Xitsonga':'Tsonga',
'Eʋegbe':'Ewe',
'Gĩkũyũ':'Kikuyu',
'Kuanyama':'Kuanyama',
'Tsetsêhestâhese':'Cheyenne',
'Otsiherero':'Herero',
'Ebon':'Marshallese',
'भोजपुरी':'Bihari',
'ትግርኛ':'Tigrinya',
'Oshiwambo':'Ndonga',
'Tshivenda':'Venda',
'ଓଡ଼ିଆ':'Oriya',
'SiSwati':'Swati',
'Chamoru':'Chamorro',
'Choctaw':'Choctaw',
'Muscogee':'Muscogee',
'Буряад':'Buryat (Russia)',
'ཇོང་ཁ':'Dzongkha',
'مَزِروني':'Mazandarani',
'Лакку':'Lak'
}

 var pLang = document.getElementById('p-lang')
 if (!pLang) return
 var ul = pLang.getElementsByTagName('ul')[0] 
 var lis = ul.getElementsByTagName('li')
 var count = lis.length
 var iw = new Array(count)
 var li, lang, name, eng  
 for (var i=0; i < count; i++){
   li = lis[i]  
   name = li.firstChild.innerHTML
   eng = iwEng[name] || ' ' + name
   li.title = name
   li.firstChild.innerHTML = eng
   iw[i] = { eng: eng,	li: lis[i] }
 }	 
 iw.sort(function(a,b){return a.eng > b.eng ? 1 : -1})
 for(i=1; i < count; i++)
   ul.appendChild(iw[i].li)
}