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