MediaWiki:DeepLTranslate/code.js

$(function {   var supportedLangs = [        "en",        "de",        "es",        "fr",        "it",        "nl",        "pl"    ],    config = mw.config.get([ 'wgAction', 'wgPageContentLanguage', 'wgUserLanguage' ]);

if (supportedLangs.indexOf(config.wgPageContentLanguage) === -1 || supportedLangs.indexOf(config.wgUserLanguage) === -1) return;

if (window.UseTranslator === false || config.wgAction === 'edit') return; window.UseTranslator = false;

var articleText = $('#mw-content-text p').text, encodedText = encodeURIComponent(articleText); var $button = $('', {       id: 'DeepLButton',        'class': 'wds-button wds-is-secondary',        text: 'Translate'    }); $('.page-header__contribution-buttons').append($button);

$button.click(function {       window.open('https://www.deepl.com/translator#' + config.wgPageContentLanguage + '/' + config.wgUserLanguage + '/' + encodedText);    }); });