jenkins-bot has submitted this change and it was merged. Change subject: Special page TranslationStash ......................................................................
Special page TranslationStash Change-Id: Ia112b86a07f75c476139f92fde8941559bfb6799 --- M Resources.php M Translate.alias.php M Translate.php M TranslateHooks.php M TranslateSandbox.i18n.php M _autoload.php A resources/css/ext.translate.special.translationstash.css A resources/js/ext.translate.special.translationstash.js A specials/SpecialTranslationStash.php 9 files changed, 315 insertions(+), 5 deletions(-) Approvals: Nikerabbit: Looks good to me, approved jenkins-bot: Verified diff --git a/Resources.php b/Resources.php index 8367a80..ae4acf8 100644 --- a/Resources.php +++ b/Resources.php @@ -359,6 +359,15 @@ ) ) + $resourcePaths; +$wgResourceModules['ext.translate.special.translationstash'] = array( + 'scripts' => 'resources/js/ext.translate.special.translationstash.js', + 'styles' => 'resources/css/ext.translate.special.translationstash.css', + 'dependencies' => array( + 'ext.translate.editor', + 'ext.translate.messagetable', + ), +) + $resourcePaths; + $wgResourceModules['ext.translate.special.translationstats'] = array( 'scripts' => 'resources/js/ext.translate.special.translationstats.js', 'dependencies' => array( diff --git a/Translate.alias.php b/Translate.alias.php index 495c10d..51e7f63 100644 --- a/Translate.alias.php +++ b/Translate.alias.php @@ -26,6 +26,7 @@ 'AggregateGroups' => array( 'AggregateGroups' ), 'SearchTranslations' => array( 'SearchTranslations' ), 'TranslateSandbox' => array( 'ManageTranslatorSandbox', 'TranslateSandbox' ), + 'TranslationStash' => array( 'TranslationStash' ), ); /** Afrikaans (Afrikaans) */ @@ -1136,4 +1137,4 @@ 'AggregateGroups' => array( '聚合組' ), 'SearchTranslations' => array( '搜尋翻譯' ), 'TranslateSandbox' => array( '管理翻譯者沙盒' ), -); \ No newline at end of file +); diff --git a/Translate.php b/Translate.php index e6a47d2..2e160db 100644 --- a/Translate.php +++ b/Translate.php @@ -92,6 +92,8 @@ $wgSpecialPages['SearchTranslations'] = 'SpecialSearchTranslations'; $wgSpecialPageGroups['SearchTranslations'] = 'wiki'; $wgSpecialPages['TranslateSandbox'] = 'SpecialTranslateSandbox'; +$wgSpecialPages['TranslationStash'] = 'SpecialTranslationStash'; +$wgSpecialPageGroups['TranslationStash'] = 'wiki'; // API $wgAPIGeneratorModules['messagecollection'] = 'ApiQueryMessageCollection'; diff --git a/TranslateHooks.php b/TranslateHooks.php index d15578e..178b42c 100644 --- a/TranslateHooks.php +++ b/TranslateHooks.php @@ -512,7 +512,9 @@ if ( SpecialTranslate::isBeta( $request ) && $title->isSpecialPage() - && ( $alias === 'Translate' || $alias === 'SearchTranslations' ) + && ( $alias === 'Translate' + || $alias === 'TranslationStash' + || $alias === 'SearchTranslations' ) ) { global $wgTranslateDocumentationLanguageCode, $wgTranslatePermissionUrl; $vars['TranslateRight'] = $out->getUser()->isAllowed( 'translate' ); diff --git a/TranslateSandbox.i18n.php b/TranslateSandbox.i18n.php index 38ab96e..f2de410 100644 --- a/TranslateSandbox.i18n.php +++ b/TranslateSandbox.i18n.php @@ -24,6 +24,10 @@ access. Please come to $2 and make some more translations.', + 'translationstash' => 'Welcome', + 'translate-translationstash-welcome' => 'Thank you {{GENDER:$1|$1}}, you are a new translator', + 'translate-translationstash-welcome-note' => 'Become familiar with the translation tools by translating some randomly selected messages.', + 'translate-translationstash-initialtranslation' => 'Your initial translation', ); /** Message documentation (Message documentation) @@ -36,9 +40,14 @@ Followed by a list of the pending requests.', 'tsb-reminder-title-generic' => 'Subject of an email', - 'tsb-reminder-content-generic' => 'Body of an email. Parameters: + 'tsb-reminder-content-generic' => 'Body of an email. * $1 - user name of the recipient * $2 - URL to the website', + 'translationstash' => 'Page title for [[Special:TranslationStash|Special page]].', + 'translate-translationstash-welcome' => 'Title text shown for the [[Special:TranslationStash|Special page]] + * $1 - user name of the new translator', + 'translate-translationstash-welcome-note' => 'Title note for the [[Special:TranslationStash|Special page]]', + 'translate-translationstash-initialtranslation' => 'Header for messages showing the progress of translations in [[Special:TranslationStash|Special page]]', ); /** Afrikaans (Afrikaans) @@ -50,7 +59,7 @@ 'tsb-reminder-title-generic' => "Voltooi u bekendstelling om 'n geverifieerde vertaler te word", 'tsb-reminder-content-generic' => "Hallo $1, -Dankie dat u op {{SITENAME}} geregistreer het. As u u toesvertalings voltooi, sal die administrateurs spoedig volle regte aan u toeken. +Dankie dat u op {{SITENAME}} geregistreer het. As u u toesvertalings voltooi, sal die administrateurs spoedig volle regte aan u toeken. Gaan asseblief na $2 om 'n paar vertalings te maak.", ); @@ -349,7 +358,7 @@ 'tsb-reminder-title-generic' => 'Завершіть своє представлення, щоб стати перевіреним перекладачем', 'tsb-reminder-content-generic' => 'Привіт, $1! -Дякуємо за реєстрацію у проекті {{SITENAME}}. Якщо Ви завершите свої тестові +Дякуємо за реєстрацію у проекті {{SITENAME}}. Якщо Ви завершите свої тестові переклади, адміністратори зможуть скоро надати Вам повні права на переклад. Будь ласка, перейдіть на $2 і зробіть ще декілька перекладів.', diff --git a/_autoload.php b/_autoload.php index 8e8c290..dc23b60 100644 --- a/_autoload.php +++ b/_autoload.php @@ -49,6 +49,7 @@ $wgAutoloadClasses['SpecialTranslateSandbox'] = "$dir/specials/SpecialTranslateSandbox.php"; $wgAutoloadClasses['SpecialTranslationStats'] = "$dir/specials/SpecialTranslationStats.php"; $wgAutoloadClasses['SpecialTranslations'] = "$dir/specials/SpecialTranslations.php"; +$wgAutoloadClasses['SpecialTranslationStash'] = "$dir/specials/SpecialTranslationStash.php"; /**@}*/ /** diff --git a/resources/css/ext.translate.special.translationstash.css b/resources/css/ext.translate.special.translationstash.css new file mode 100644 index 0000000..2b4e7a8 --- /dev/null +++ b/resources/css/ext.translate.special.translationstash.css @@ -0,0 +1,54 @@ +/** + * @author Santhosh Thottingal + * @license GPL-2.0+ + * @since 2013.10 + */ + +h1.firstHeading { + display: none; +} + +.translate-welcome-header > h1 { + text-decoration: none; + border-bottom: none; +} + +.translate-welcome-header > p { + color: #555555; + font-size: 1.2em; +} + +.translate-welcome-header { + background-color: #F6F6F6; + padding: 10px; +} + +.translate-stash-control { + padding: 10px; + font-size: 1.5em; +} + +.ext-translate-language-selector-label { + color: #555555; +} + +.ext-translate-language-selector { + text-align: right; +} + +.ext-translate-language-selector .uls { + cursor: pointer; +} + +/* The triangle shaped down-pointing callout after the language name + * in the target language selector + */ +.ext-translate-language-selector:after { + margin-left: 4px; + border-left: 4px solid transparent; + border-right: 4px solid transparent; + border-top: 4px solid #0645AD; + content: ""; + display: inline-block; + vertical-align: middle; +} diff --git a/resources/js/ext.translate.special.translationstash.js b/resources/js/ext.translate.special.translationstash.js new file mode 100644 index 0000000..949f31a --- /dev/null +++ b/resources/js/ext.translate.special.translationstash.js @@ -0,0 +1,130 @@ +/** + * TranslationStash front-end logic + * @author Santhosh Thottingal + * @license GPL-2.0+ + * @since 2013.10 + */ + +( function ( $, mw ) { + 'use strict'; + + function getMessages( messageGroup, language, offset, limit ) { + var api = new mw.Api(); + + return api.get( { + action: 'query', + list: 'messagecollection', + mcgroup: messageGroup, + format: 'json', + mclanguage: language, + mcoffset: offset, + mclimit: limit, + mcprop: 'definition|translation|tags|properties' + } ); + } + + function addMessage( message ) { + var $messageWrapper, $message, + $messageTable = $( '.tux-messagelist' ), + sourceLanguage = $messageTable.data( 'sourcelangcode' ), + sourceLanguageDir = $.uls.data.getDir( sourceLanguage ), + targetLanguage = $messageTable.data( 'targetlangcode' ), + targetLanguageDir = $.uls.data.getDir( targetLanguage ), + status = message.properties.status, + statusClass = 'tux-status-' + status; + + $messageWrapper = $( '<div>' ) + .addClass( 'row tux-message' ); + + $message = $( '<div>' ) + .addClass( 'row message tux-message-item ' + status ) + .append( + $( '<div>' ) + .addClass( 'eight columns tux-list-message' ) + .append( + $( '<span>' ) + .addClass( 'tux-list-source' ) + .attr( { + lang: sourceLanguage, + dir: sourceLanguageDir + } ) + .text( message.definition ), + // Bidirectional isolation. + // This should be removed some day when proper + // unicode-bidi: isolate + // is supported everywhere + $( '<span>' ) + .html( $( 'body' ).hasClass( 'rtl' ) ? '‏' : '‎' ), + $( '<span>' ) + .addClass( 'tux-list-translation' ) + .attr( { + lang: targetLanguage, + dir: targetLanguageDir + } ) + .text( message.translation || '' ) + ), + $( '<div>' ) + .addClass( 'two columns tux-list-status text-center' ) + .append( + $( '<span>' ) + .addClass( statusClass ) + ), + $( '<div>' ) + .addClass( 'two column tux-list-edit text-right' ) + .append( + $( '<a>' ) + .attr( { + title: mw.msg( 'translate-edit-title', message.key ) + } ) + .text( mw.msg( 'tux-edit' ) ) + ) + ); + + $messageWrapper.append( $message ); + $messageTable.append( $messageWrapper ); + // Attach translate editor to the message + $messageWrapper.translateeditor( { + message: message + } ); + } + + function loadMessages() { + var $messageTable = $( '.tux-messagelist' ), + messagegroup = '!recent'; // FIXME + + getMessages( messagegroup, $messageTable.data( 'targetLang' ), 0, 5 ) + .done( function ( result ) { + var messages = result.query.messagecollection; + $.each( messages, function ( index, message ) { + message.group = messagegroup; + addMessage( message ); + if ( index === 0 ) { + // Show the editor for the first message. + $( '.tux-message:first' ).data( 'translateeditor' ).show(); + } + } ); + } ).fail( function ( errorCode, response ) { + $messageTable.empty().addClass( 'error' ) + .text( 'Error: '+ errorCode + ' - ' + response.error.info ); + } ); + } + + $( 'document' ).ready( function () { + var $messageTable = $( '.tux-messagelist' ); + + $( '.ext-translate-language-selector .uls' ).uls( { + onSelect: function ( language ) { + $( '.ext-translate-language-selector > .uls' ) + .text( $.uls.data.getAutonym( language ) ) + .attr( { + lang: language, + dir: $.uls.data.getDir( language ) + } ); + $messageTable.empty(); + $messageTable.data( 'targetLang', language ); + loadMessages(); + } + } ); + loadMessages(); + } ); +}( jQuery, mediaWiki ) ); diff --git a/specials/SpecialTranslationStash.php b/specials/SpecialTranslationStash.php new file mode 100644 index 0000000..fbec3e7 --- /dev/null +++ b/specials/SpecialTranslationStash.php @@ -0,0 +1,102 @@ +<?php +/** + * TranslationStash - Translator screening page + * + * @file + * @author Santhosh Thottingal + * @license GPL-2.0+ + */ + +/** + * Special page for new users to translate example messages. + * + * @ingroup SpecialPage TranslateSpecialPage + */ +class SpecialTranslationStash extends SpecialPage { + function __construct() { + parent::__construct( 'TranslationStash' ); + } + + public function execute( $params ) { + $this->setHeaders(); + $out = $this->getOutput(); + $out->addModules( 'ext.translate.special.translationstash' ); + $this->showPage(); + } + + /** + * Generates the whole page html and appends it to output + */ + protected function showPage() { + // Easier to do this way than in JS + $out = $this->getOutput(); + + $name = $this->getUser()->getName(); + + $out->addHtml( <<<HTML +<div class="grid"> + <div class="row translate-welcome-header"> + <h1> + {$this->msg( 'translate-translationstash-welcome', $name )->parse()} + </h1> + <p> + {$this->msg( 'translate-translationstash-welcome-note' )->parse()} + </p> + </div> + <div class="row translate-stash-control"> + <div class="six columns stash-stats"> + {$this->msg( 'translate-translationstash-initialtranslation' )->parse()} + </div> + <div class="six columns ext-translate-language-selector right" + {$this->tuxLanguageSelector()} + </div> + </div> + {$this->getMessageTable()} +</div> +HTML + ); + } + + protected function getMessageTable() { + $sourceLang = Language::factory('en'); + $targetLang = $this->getLanguage(); + + $list = Html::element( 'div', array( + 'class' => 'row tux-messagelist', + 'data-sourcelangcode' => $sourceLang->getCode(), + 'data-sourcelangdir' => $sourceLang->getDir(), + 'data-targetlangcode' => $targetLang->getCode(), + 'data-targetlangdir' => $targetLang->getDir(), + ) ); + + return $list; + } + + protected function tuxLanguageSelector() { + // The name will be displayed in the UI language, + // so use for lang and dir + $language = $this->getLanguage(); + $targetLangName = Language::fetchLanguageName( $language->getCode() ); + + $label = Html::element( + 'span', + array( 'class' => 'ext-translate-language-selector-label' ), + $this->msg( 'tux-languageselector' )->text() + ); + + $trigger = Html::element( + 'span', + array( + 'class' => 'uls', + 'lang' => $language->getCode(), + 'dir' => $language->getDir(), + ), + $targetLangName + ); + + // No-break space is added for spacing after the label + // and to ensure separation of words (in Arabic, for example) + return "$label $trigger"; + } + +} -- To view, visit https://gerrit.wikimedia.org/r/69285 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia112b86a07f75c476139f92fde8941559bfb6799 Gerrit-PatchSet: 11 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: Siebrand <siebr...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits