r111997 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111996‎ | r111997 | r111998 >
Date:09:59, 21 February 2012
Author:nikerabbit
Status:ok (Comments)
Tags:i18nreview 
Comment:
Committing this from git so that Siebrand can review it using CR tool.
Modified paths:
  • /trunk/extensions/Translate/lcadft (added) (history)
  • /trunk/extensions/Translate/lcadft/LCADFT.alias.php (added) (history)
  • /trunk/extensions/Translate/lcadft/LCADFT.i18n.php (added) (history)
  • /trunk/extensions/Translate/lcadft/LCADFT.php (added) (history)
  • /trunk/extensions/Translate/lcadft/SpecialTranslatorSignup.php (added) (history)

Diff [purge]

Index: trunk/extensions/Translate/lcadft/LCADFT.i18n.php
@@ -0,0 +1,56 @@
 2+<?php
 3+/**
 4+ * Translations for the translator outreach features.
 5+ *
 6+ * @file
 7+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 8+ */
 9+
 10+$messages = array();
 11+
 12+/** English
 13+ * @author Niklas Laxström
 14+ */
 15+$messages['en'] = array(
 16+ 'translatorsignup' => 'Translator signup',
 17+ 'lcadft-desc' => 'Allows translators sign up for translation notifications',
 18+ 'lcadft-info' => 'Info',
 19+ 'lcadft-username' => 'Username',
 20+ 'lcadft-emailstatus' => 'E-mail status',
 21+ 'lcadft-email-confirmed' => 'Your e-mail address is confirmed',
 22+ 'lcadft-email-unconfirmed' => 'Your e-mail address is not confirmed. $1',
 23+ 'lcadft-email-notset' => 'You have not provided an e-mail address. You can do that in your [[Special:Preferences|preferences]].',
 24+ 'lcadft-contact' => 'Preferred contact methods',
 25+ 'lcadft-cmethod-email' => 'E-mail',
 26+ 'lcadft-cmethod-talkpage' => 'Talk page',
 27+ 'lcadft-cmethod-talkpage-elsewhere' => 'Talk page on other wiki',
 28+ 'lcadft-cmethod-feed' => 'Feed',
 29+ 'lcadft-frequency' => 'Contact frequency',
 30+ 'lcadft-freq-always' => 'When there is something new to translate',
 31+ 'lcadft-freq-week' => 'At most once a week',
 32+ 'lcadft-freq-month' => 'At most once a month',
 33+ 'lcadft-freq-weekly' => 'Weekly digest',
 34+ 'lcadft-freq-monthly' => 'Monthly digest',
 35+ 'lcadft-submit' => 'Sign up',
 36+);
 37+
 38+$messages['qqq'] = array(
 39+ 'lcadft' => 'Special page header',
 40+ 'lcadft-desc' => '{{desct}}',
 41+ 'lcadft-info' => 'Fieldset header',
 42+ 'lcadft-username' => 'Label followed by username',
 43+ 'lcadft-emailstatus' => 'Label',
 44+ 'lcadft-email-unconfirmed' => '$1 is a button which can be used to send confirmation email. Button text is in Mediawiki:confirmemail_send message.',
 45+ 'lcadft-contact' => 'Fieldset header',
 46+ 'lcadft-cmethod-email' => 'Check option label',
 47+ 'lcadft-cmethod-talkpage' => 'Check option label',
 48+ 'lcadft-cmethod-talkpage-elsewhere' => 'Check option label',
 49+ 'lcadft-cmethod-feed' => 'Check option label',
 50+ 'lcadft-frequency' => 'Fieldset header',
 51+ 'lcadft-freq-always' => 'Radio option label',
 52+ 'lcadft-freq-week' => 'Radio option label',
 53+ 'lcadft-freq-month' => 'Radio option label',
 54+ 'lcadft-freq-weekly' => 'Radio option label',
 55+ 'lcadft-freq-monthly' => 'Radio option label',
 56+ 'lcadft-submit' => 'Submit button text',
 57+);
Property changes on: trunk/extensions/Translate/lcadft/LCADFT.i18n.php
___________________________________________________________________
Added: svn:eol-style
158 + native
Index: trunk/extensions/Translate/lcadft/LCADFT.php
@@ -0,0 +1,37 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
 4+/**
 5+ * An extension to keep in touch with translators
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ *
 10+ * @author Niklas Laxström
 11+ * @copyright Copyright © 2012, Niklas Laxström
 12+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 13+ */
 14+
 15+/**
 16+ * Extension credits properties.
 17+ */
 18+$wgExtensionCredits['specialpage'][] = array(
 19+ 'path' => __FILE__,
 20+ 'name' => 'LCADFT',
 21+ 'version' => '2012-02-20',
 22+ 'author' => array( 'Niklas Laxström' ),
 23+ 'descriptionmsg' => 'lcadft-desc',
 24+ #'url' => 'https://www.mediawiki.org/wiki/Extension:',
 25+);
 26+
 27+$dir = dirname( __FILE__ );
 28+$wgSpecialPages['TranslatorSignup'] = 'SpecialTranslatorSignup';
 29+$wgExtensionMessagesFiles['LCADFT'] = "$dir/LCADFT.i18n.php";
 30+$wgExtensionMessagesFiles['LCADFT-alias'] = "$dir/LCADFT.alias.php";
 31+$wgAutoloadClasses['SpecialTranslatorSignup'] = "$dir/SpecialTranslatorSignup.php";
 32+
 33+$wgLCADFTContactMethods = array(
 34+ 'email' => true,
 35+ 'talkpage' => true,
 36+ 'talkpage-elsewhere' => false,
 37+ 'feed' => false,
 38+);
Property changes on: trunk/extensions/Translate/lcadft/LCADFT.php
___________________________________________________________________
Added: svn:eol-style
139 + native
Index: trunk/extensions/Translate/lcadft/SpecialTranslatorSignup.php
@@ -0,0 +1,150 @@
 2+<?php
 3+/**
 4+ * Form for translators to register contact methods
 5+ *
 6+ * @file
 7+ * @author Niklas Laxström
 8+ * @copyright Copyright © 2012, Niklas Laxström
 9+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 10+ */
 11+
 12+/**
 13+ * Form for translators to register contact methods
 14+ *
 15+ * @ingroup SpecialPage TranslateSpecialPage
 16+ */
 17+
 18+class SpecialTranslatorSignup extends SpecialPage {
 19+ public function __construct() {
 20+ parent::__construct( 'TranslatorSignup' );
 21+ }
 22+
 23+ public function execute( $parameters ) {
 24+ if ( !$this->getUser()->isLoggedIn() ) {
 25+ throw new PermissionsError( 'read' );
 26+ }
 27+
 28+ $context = $this->getContext();
 29+ $htmlForm = new HtmlForm( $this->getDataModel(), $context, 'lcadft' );
 30+ $htmlForm->setId( 'lcadft-form' );
 31+ $htmlForm->setSubmitText( $context->msg( 'lcadft-submit' )->text() );
 32+ $htmlForm->setSubmitID( 'lcadft-submit' );
 33+ $htmlForm->setSubmitCallback( array( $this, 'formSubmit' ) );
 34+ $htmlForm->show();
 35+
 36+ $this->setHeaders();
 37+ $this->getOutput()->addInlineScript(
 38+<<<JAVASCRIPT
 39+jQuery( function ( $ ) {
 40+ var toggle = function () {
 41+ $( '#mw-input-wpcmethod-talkpage-elsewhere-loc' ).toggle( $( '#mw-input-wpcmethod-talkpage-elsewhere' ).prop( 'checked' ) );
 42+ };
 43+ toggle();
 44+ $( '#mw-input-wpcmethod-talkpage-elsewhere' ).change( toggle );
 45+} );
 46+JAVASCRIPT
 47+ );
 48+ }
 49+ public function getDataModel() {
 50+ global $wgLCADFTContactMethods, $wgScript;
 51+
 52+ $m['username'] = array(
 53+ 'type' => 'info',
 54+ 'label-message' => 'lcadft-username',
 55+ 'default' => $this->getUser()->getName(),
 56+ 'section' => 'info',
 57+ );
 58+
 59+ $user = $this->getUser();
 60+ if ( $user->isEmailConfirmed() ) {
 61+ $status = $this->msg( 'lcadft-email-confirmed' )->parse();
 62+ } elseif ( trim( $user->getEmail() ) !== '' ) {
 63+ $submit = Xml::submitButton( $this->msg( 'confirmemail_send' )->text(), array( 'name' => 'x' ) );
 64+ $status = $this->msg( 'lcadft-email-unconfirmed' )->rawParams( $submit )->parse();
 65+ } else {
 66+ $status = $this->msg( 'lcadft-email-notset' )->parse();
 67+ }
 68+
 69+
 70+ $m['emailstatus'] = array(
 71+ 'type' => 'info',
 72+ 'label-message' => 'lcadft-emailstatus',
 73+ 'default' => $status,
 74+ 'section' => 'info',
 75+ 'raw' => true,
 76+ );
 77+
 78+ foreach ( $wgLCADFTContactMethods as $method => $value ) {
 79+ if ( $value === false ) {
 80+ continue;
 81+ }
 82+
 83+ $m["cmethod-$method"] = array(
 84+ 'type' => 'check',
 85+ 'label-message' => "lcadft-cmethod-$method",
 86+ 'default' => $user->getOption( "lcadft-cmethod-$method" ),
 87+ 'section' => 'contact',
 88+ );
 89+ if ( $method === 'email' ) {
 90+ $m["cmethod-$method"]['disabled'] = !$user-> isEmailConfirmed();
 91+ }
 92+
 93+ if ( $method === 'talkpage-elsewhere' ) {
 94+ $m['cmethod-talkpage-elsewhere-loc'] = array(
 95+ 'type' => 'select',
 96+ 'default' => $user->getOption( 'lcadft-cmethod-talkpage-elsewhere-loc' ),
 97+ 'section' => 'contact',
 98+ 'options' => $this->getOtherWikis(),
 99+ );
 100+ }
 101+ }
 102+
 103+ $m['freq'] = array(
 104+ 'type' => 'radio',
 105+ 'default' => $user->getOption( 'lcadft-freq', 'always' ),
 106+ 'section' => 'frequency',
 107+ 'options' => array(
 108+ $this->msg( 'lcadft-freq-always' )->text() => 'always',
 109+ $this->msg( 'lcadft-freq-week' )->text() => 'week',
 110+ $this->msg( 'lcadft-freq-month' )->text() => 'month',
 111+ $this->msg( 'lcadft-freq-weekly' )->text() => 'weekly',
 112+ $this->msg( 'lcadft-freq-monthly' )->text() => 'monthl',
 113+ ),
 114+ );
 115+ return $m;
 116+ }
 117+
 118+ public function formSubmit( $formData, $form ) {
 119+ global $wgRequest;
 120+ $user = $this->getUser();
 121+
 122+ if ( $wgRequest->getVal( 'x' ) === $this->msg( 'confirmemail_send' )->text() ) {
 123+ $user->sendConfirmationMail( 'set' );
 124+ return;
 125+ }
 126+
 127+ foreach ( $formData as $key => $value ) {
 128+ $user->setOption( "lcadft-$key", $value );
 129+ }
 130+ $user->saveSettings();
 131+ }
 132+
 133+ protected function getOtherWikis() {
 134+ $wikis = array();
 135+ if ( !class_exists( 'CentralAuthUser' ) ) {
 136+ return array();
 137+ }
 138+ $globalUser = new CentralAuthUser( $this->getUser->getName() );
 139+ if ( !$globalUser->exists() ) {
 140+ return array();
 141+ }
 142+
 143+ $stuff = $this->mGlobalUser->queryAttached();
 144+ foreach ( $suff as $dbname => $value ) {
 145+ $wikis[] = $dname;
 146+ }
 147+
 148+ return array_combine( $wikis, $wikis );
 149+ }
 150+
 151+}
Property changes on: trunk/extensions/Translate/lcadft/SpecialTranslatorSignup.php
___________________________________________________________________
Added: svn:eol-style
1152 + native
Index: trunk/extensions/Translate/lcadft/LCADFT.alias.php
@@ -0,0 +1,14 @@
 2+<?php
 3+/**
 4+ * Aliases for special pages of LCADFT extension.
 5+ *
 6+ * @file
 7+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 8+ */
 9+
 10+$specialPageAliases = array();
 11+
 12+/** English (English) */
 13+$specialPageAliases['en'] = array(
 14+ 'TranslatorSignup' => array( 'Translator Signup' ),
 15+);
Property changes on: trunk/extensions/Translate/lcadft/LCADFT.alias.php
___________________________________________________________________
Added: svn:eol-style
116 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r112018Followup r111997...reedy16:19, 21 February 2012
r112048r111997: Register new module for translatewiki.net.raymond21:31, 21 February 2012

Comments

#Comment by Siebrand (talk | contribs)   12:43, 21 February 2012

Looks nice. We did forget a major requirement, though, which is that we should offer users the option to pick between one and three languages they can translate in. I think it's probably a good idea to set the first selector to the user interface language. I choice at least one filled out translation language should be mandatory, I think, because otherwise the messaging that we are to implement later on cannot be well targeted.

#Comment by Siebrand (talk | contribs)   13:05, 21 February 2012

This implements https://mingle.corp.wikimedia.org/projects/internationalization/cards/532

Failed the following acceptance criteria: 2. Which languages can you translate in? 2.1 Inputs for Maximum of three languages that a translator can indicate. Suggested is these are language selector dropdowns 2.2 the first selector is set to the user interface language when there are no user preferences yet. 2.3 Saving the form without having provided any language preference should not be possible. 3.5 I don’t want to be notified

#Comment by Nikerabbit (talk | contribs)   19:45, 22 February 2012

Fixed in followups.

Status & tagging log