MediaWiki:TranslateForm.js

/* @ Created By Lil' Miss Rarity, customized by Joeytje50 (i18n compatibility upgrade and dropdown languages) @ Some functions added by Jr Mime (pop-up layout, variables) @ Adds a pop up modal form for wlb.wikia.com @ License: CC-BY-NC-SA @ License Jurisdiction: International // Variables for later on // Keep these in an object for organization var _tr = { edittoken: mw.user.tokens.values.editToken, namespace: mw.config.get('wgNamespaceNumber'), pagename: mw.config.get('wgPageName'), server: mw.config.get('wgServer'), signature:  + , language: mw.config.get('wgUserLanguage') };

var $ = this.jQuery, mw = this.mediaWiki, i,   msg = messages = { get: function(name) { return (messages[_tr.language.toUpperCase]||messages['EN'])[name]; },       languages: { EN: 'English', BS: 'Bosanski', CA: 'Català', DE: 'Deutsch', ES: 'Español', FR: 'Français', GL: 'Galego', IT: 'Italiano', JA: '日本語', MS: 'Malay', NL: 'Nederlands', PL: 'Polski', PT: 'Português', RU: 'Русский' },   };

// English / default messages['EN'] = { button: "Create request", "save-wiki": "Wiki", "community-url": "community", "form-name": "Request Form", "form-header": "Title of the request:", "form-header-placeholder": "Replace this with the title", "form-language": "Translate from:", "form-language-to": "To:", "form-language-after": "", "form-language-choose": "Choose language", "form-url": "URL of the wiki:", "form-information-header": "Information of your request:", "form-information-request": "More information on how to file in your request can be found at the top of the page.", "form-items": "Items", "form-items-placeholder": "", "form-extrainfo": "Extra information", "form-extrainfo-placeholder": "", "form-signature": "Signature", }

// Bosanian messages['BS'] = { button: "U&#269;inite zahtjev", "save-wiki": "Wiki", "community-url": "bs.community", "form-name": "Traziti formu", "form-header": "Naslov zahtjeva:", "form-header-placeholder": "Zamjeniti ovo sa naslovom", "form-language": "Translate form:", // Needs translation "form-language-to": "To:", // Needs translation "form-language-after": "", "form-language-choose": "Choose language", // Needs translation "form-url": "Wiki's url:", "form-information-header": "Informacije za tvoj zahtjev:", "form-information-request": "Vise informacija za kako traziti dokumenat u tvoj zahtjev mozete naci gore na ekranu.", "form-items": "Stvari", "form-items-placeholder": "", "form-extrainfo": "Dodatne informacije", "form-extrainfo-placeholder": "", "form-signature": "Signature", // Needs translation }

// Catalan messages['CA'] = { button: "Nova soŀlicitud", "save-wiki": "Wiki", "community-url": "ca.community", "form-name": "Forma de petició", "form-header": "Títol de la petició:", "form-header-placeholder": "Reemplaça això amb el títol", "form-language": "Traduir de:", "form-language-to": "A:", "form-language-after": "", "form-language-choose": "Tria idioma", "form-url": "URL del wiki:", "form-information-header": "Informació de la teva petició:", "form-information-request": "Més informació de com fer la teva petició es pot trobar a la part superior de la pàgina.", "form-items": "Items", "form-items-placeholder": "", "form-extrainfo": "Informació extra", "form-extrainfo-placeholder": "", "form-signature": "Signatura", }

// German messages['DE'] = { button: "Korrekturanfrage stellen", "save-wiki": "Wiki", "community-url": "de.community", "form-name": "Formular", "form-header": "Anfragetitel:", "form-header-placeholder": "Geben Sie hier den Titel an", "form-language": "Von:", "form-language-to": "Nach:", "form-language-after": " übersetzen", "form-language-choose": "Sprache wählen", "form-url": "Wiki-URL hier angeben:", "form-information-header": "Informationen zur Anfrage:", "form-information-request": "Weitere Informationen darüber, wie das Formular auszufüllen ist können auf der Seite \"Translate\" gefunden werden.", "form-items": "Items", "form-items-placeholder": "", // Needs translation "form-extrainfo": "Weitere Informationen", "form-extrainfo-placeholder": "", "form-signature": "Signatur", }

// Spanish messages['ES'] = { button: "Nueva solicitud", "save-wiki": "Wiki", "community-url": "es.community", "form-name": "Formulario de solicitud de", "form-header": "Título de la petición:", "form-header-placeholder": "Sustituye esto con el título", "form-language": "Traducir desde:", "form-language-to": "A:", "form-language-after": "", "form-language-choose": "Elige idioma", "form-url": "Url de la wiki:", "form-information-header": "Información de tu petición:", "form-information-request": "Más información sobre como hacer tu petición se puede encontrar en la parte superior de la página.", "form-items": "Items", "form-items-placeholder": "", "form-extrainfo": "Información extra", "form-extrainfo-placeholder": " ", "form-signature": "Firma", }

// French messages['FR'] = { button: "Nouvelle requête", "save-wiki": "Wiki", "community-url": "fr.community", "form-name": "Formulaire de demande", "form-header": "Titre de votre requête:", "form-header-placeholder": "Remplacez ceci avec votre titre", "form-language": "Traduire de:", "form-language-to": "À:", "form-language-after": "", "form-language-choose": "Choisir une langue", "form-url": "L'URL du wiki:", "form-information-header": "Information de vôtre requête:", "form-information-request": "Plus d'information sur comment remplir votre requête ce retrouve en haut de cette page.", "form-items": "Items", "form-items-placeholder": "", "form-extrainfo": "Information suplémentaire", "form-extrainfo-placeholder": "", "form-signature": "Signature", }

// GL messages['GL'] = { button: "Nova solicitude", "save-wiki": "Wiki", "community-url": "gl.community", "form-name": "Formulario de solicitude", "form-header": "Título da solicitude:", "form-header-placeholder": "Substitúe isto co título", "form-language": "Traducir de:", "form-language-to": "A:", "form-language-after": "", "form-language-choose": "Escolle o idioma", "form-url": "Url da wiki:", "form-information-header": "Información da túa solicitude:", "form-information-request": "Máis información sobre como facer a túa solicitude pódense atopar na parte superior da páxina.", "form-items": "Elementos", "form-items-placeholder": "", "form-extrainfo": "Información extra", "form-extrainfo-placeholder": "", "form-signature": "Firma", }

// Italian messages['IT'] = { button: "Crea nuova richiesta", "community-url": "it.community", "form-name": "Forma di Richiesta", "form-header": "Titolo della richiesta:", "form-header-placeholder": "Rimpiazzare questa linea con il titolo", "form-language": "Traduci da:", "form-language-to": "A:", "form-language-after": "", "form-language-choose": "Scegli lingua", "form-url": "L'url della wiki:", "form-information-header": "Informazioni sulla tua richiesta:", "form-information-request": "Più informazioni su come compilare la tua richiesta possono essere trovate all'inizio della pagina.", "form-items": "Elementi", "form-items-placeholder": "", "form-extrainfo": "Informazioni aggiuntive", "form-extrainfo-placeholder": "", "form-signature": "Firma", }

// Japanese messages['JA'] = { button: "直すリクエストを新規作成", "save-wiki": "ウィキ", "community-url": "ja.community", "form-name": "伺い書", "form-header": "リクエストのタイトル", "form-header-placeholder": "こちらをタイトルに変更しなさい", "form-language": "Translate from:", // Needs translation "form-language-to": "To:", // Needs translation "form-language-after": "", "form-language-choose": 'Choose language', //Needs translation "form-url": "項目:", "form-information-header": "リクエストの情報. ", "form-information-request": "リクエストの記入についての他の情報は、ページの上の方に書いています. ", "form-items": "その他の情報", "form-items-placeholder": "＜その他の情報を追加してください（任意）＞", // Needs translation "form-extrainfo": "placeholder", // Needs translation "form-extrainfo-placeholder": "placeholder", // Needs translation "form-signature": "Signature", // Needs translation }

//Malay messages['MS'] = { button: "Permintaan Baru", "save-wiki": "Wiki", "community-url": "ms.community", "form-name": "Borang Permintaan", "form-header": "Tajuk:", "form-header-placeholder": "Gantikan ini dengan tajuk anda", "form-language": "Bahasa yang ingin diterjemah:", "form-language-to": "Untuk:", "form-language-after": "", "form-language-choose:": "Pilih bahasa", "form-url": "URL atau laman wiki yang ingin diterjemah:", "form-information-header": "Keterangan:", "form-information-request": "Untuk keterangan lanjut, sila rujuk kepada segmen atas laman ini.", "form-items": "Sumber-sumber", "form-items-placeholder": "<artikel-artikel untuk diterjemah (maksimum: 3)>", "form-extrainfo": "Maklumat tambahan", "form-extrainfo-placeholder": "<masukkan maklumat tambahan sini (tidak wajib)>", "form-signature": "Tandatangan", }

// Dutch messages['NL'] = { button: "Verbetering aanvragen", "save-wiki": "Wiki", "community-url": "nl.community", "form-name": "Aanvraagformulier", "form-header": "Onderwerp van de aanvraag", "form-header-placeholder": "Vervang dit met het onderwerp", "form-language": "Vertaal vanuit:", "form-language-to": "Naar:", "form-language-after": "", "form-language-choose": "Kies taal", "form-url": "Plaats hier de url van de wiki:", "form-information-header": "Informatie over de aanvraag:", "form-information-request": "Meer informatie over hoe je de aanvraag kan invullen staat aan de bovenkant van de pagina.", "form-items": "Items", "form-items-placeholder": "<te verbeteren pagina's (tot 3)>", "form-extrainfo": "Extra informatie", "form-extrainfo-placeholder": "<andere informatie (optioneel)", "form-signature": "Handtekening", }

// Polish messages['PL'] = { button: "Utwórz wniosek", "save-wiki": "Wiki", "community-url": "pl.community", "form-name": "Formularz wniosku", "form-header": "Tytuł wniosku:", "form-header-placeholder": "Zastąp ten tytuł", "form-language": "Przetłumacz z:", "form-language-to": "Na:", "form-language-after": "", "form-language-choose": "Wybierz język", "form-url": "Podaj adres url wiki:", "form-information-header": "Informacje o Twoim wniosku:", "form-information-request": "Więcej informacji na temat plików, można znaleźć na górze strony.", "form-items": "Items", "form-items-placeholder": "<elementy do poprawy (do 3)>", "form-extrainfo": "Dodatkowe informacje", "form-extrainfo-placeholder": "<wprowadź dodatkowe informacje (opcjonalne)>", "form-signature": "Podpis", }

// Portuguese messages['PT'] = { button: "Novo pedido", "save-wiki": "Wiki", "community-url": "pt.community", "form-name": "Formulário de solicitação", "form-header": "Título do pedido:", "form-header-placeholder": "Substitui isto com o título", "form-language": "Traduzir de:", "from-language-to": "A:", "form-language-after": "", "form-language-choose": "Escolhe a língua", "form-url": "Url da wiki:", "form-information-header": "Informação do teu pedido:", "form-information-request": "Mais informações sobre como fazer o teu pedido podem-se encontrar na parte superior da página.", "form-items": "Itens", "form-items-placeholder": "<coisas para traduzir (até 3)>", "form-extrainfo": "Informação extra", "form-extrainfo-placeholder": "<adiciona informção extra (opcional)>", "form-signature": "Assinatura", }

// Russian messages['RU'] = { button: "Создать запрос", "save-wiki": "Вики", "community-url": "ru.community", "form-name": "Форма запроса", "from-header": "Название запроса:", "form-header-placeholder": "Введите сюда название", "form-language": "Translate from:", // Needs translation "form-language-to": "To:", // Needs translation "form-language-after": "", "form-language-choose": "Choose language", // Needs translation "form-url": "Url адрес викии:", "form-information-header": "Информация по запросу:", "form-information-request": "Более подробную информацию о том, как оставить запрос, можно найти в верхней части страницы.", "form-items": "Статьи", "form-items-placeholder": "<статьи для перевода (до 3-ех)>", "form-extrainfo": "Дополнительная информация", "form-extrainfo-placeholder": "<укажите дополнительную информацию (необязательно)>", }

if(_tr.pagename === 'Translate') { var buttonappend = '<a class="wikia-button" id="wlb-submit" onclick="openFormTranslate">' + msg.get('button') + '</a>'; document.getElementById("lang-" + _tr.language.toUpperCase).innerHTML = buttonappend;

window.dropdown = '<select name="language" id="language" value="'+mw.config.get('wgUserLanguage').toUpperCase+'">'; dropdown += '<option value="" selected disabled>' + msg.get('form-language-choose') + ' '; for (var i in msg.languages) { dropdown += '<option value="'+i+'">'+msg.languages[i]+' '; }   dropdown += ' ';

window.dropdown2 = '<select name="language2" id="language2" value="'+mw.config.get('wgUserLanguage').toUpperCase+'">'; dropdown2 += '<option value="" selected disabled>' + msg.get('form-language-choose') + ' '; for (var i in msg.languages) { dropdown2 += '<option value="'+i+'">'+msg.languages[i]+' '; }   dropdown2 += ' ';

// This opens the form for the users to fill out

function openFormTranslate { $.showCustomModal(msg.get('form-name'), '<form class="WikiaForm" method="" name="" id="translationForm"> ' + msg.get('form-header') + ' <input id="request-header" type="text" placeholder="' + msg.get('form-header-placeholder') + '" style="width: 450px"/> ' + msg.get('form-information-header') + ' <span title="' + msg.get('form-information-request') + '" style="cursor:help; float:right; font-size:12pt; border-bottom:1px dotted">[?]   ', {        id: "requestWindow",        width: 650,        buttons: [{    id: "cancel",    message: "Cancel",    handler: function  {        cancelformTranslate;    }        }, {    id: "submit",    defaultButton: true,    message: "Submit",    handler: function  {        submitformTranslate;    }        }]    }); } } // Closes the form function cancelformTranslate { $("#requestWindow").closeModal; } // Submits the form

function submitformTranslate { var $form = $('#translationForm'), header = $form.find('#request-header').val, lang = $form.find('#language').val, lang2 = $form.find('#language2').val, wikiurl = $form.find('#wiki-url').val, items = $form.find('#items').val, extrainfo = $form.find('#extrainfo').val, signatureplace = $form.find('#signature-place').val, page = ' \n\n\n\'\'\ + msg.get('save-wiki') + '\'\'\': w:c:' + wikiurl + '\n\n\'\'\ + msg.get('form-items') + '\'\'\': ' + items + '\n\n\'\'\ + msg.get('form-extrainfo') + '\'\'\': ' + extrainfo + '\n\n\'\'\ + msg.get('form-signature') + '\'\'\': ' + signatureplace + '\n '; // Making sure the header isn't blank, and a language has been filled in   if (!header) { alert("Please title your request!"); return; }   if (!lang||!lang2) { alert('Please select a language!'); return; }   // Ajax URL var url = _tr.server + '/api.php?action=edit&title=' + encodeURIComponent(_tr.pagename) + '&section=new&sectiontitle=' + encodeURIComponent(header) + '&text=' + encodeURIComponent(page) + '&token=' + encodeURIComponent(_tr.edittoken); $.post(url, function {        window.location.reload;    }); setTimeout(cancelformTranslate, 1000); }