(bug 37176) Localize autosummary of page protecting
authorLiangent <liangent@gmail.com>
Fri, 2 Nov 2012 12:37:20 +0000 (20:37 +0800)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 4 Jan 2013 11:09:18 +0000 (11:09 +0000)
Including parentheses, brackets, edit=sysop text, etc. A new message
'protect-summary-desc' has been added.

Change-Id: I888c616ea896bb2585d79ef8ecb6f34fab196191

includes/WikiPage.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messageTypes.inc
maintenance/language/messages.inc

index 4086a20..7620b3a 100644 (file)
@@ -2277,23 +2277,38 @@ class WikiPage extends Page implements IDBAccessObject {
                foreach ( $limit as $action => $restrictions ) {
                        $encodedExpiry[$action] = $dbw->encodeExpiry( $expiry[$action] );
                        if ( $restrictions != '' ) {
-                               $protectDescription .= $wgContLang->getDirMark() . "[$action=$restrictions] (";
+                               # $action is one of $wgRestrictionTypes = array( 'create', 'edit', 'move', 'upload' ).
+                               # All possible message keys are listed here for easier grepping:
+                               # * restriction-create
+                               # * restriction-edit
+                               # * restriction-move
+                               # * restriction-upload
+                               $actionText = wfMessage( 'restriction-' . $action )->inContentLanguage()->text();
+                               # $restrictions is one of $wgRestrictionLevels = array( '', 'autoconfirmed', 'sysop' ),
+                               # with '' filtered out. All possible message keys are listed below:
+                               # * protect-level-autoconfirmed
+                               # * protect-level-sysop
+                               $restrictionsText = wfMessage( 'protect-level-' . $restrictions )->inContentLanguage()->text();
                                if ( $encodedExpiry[$action] != 'infinity' ) {
-                                       $protectDescription .= wfMessage(
+                                       $expiryText = wfMessage(
                                                'protect-expiring',
                                                $wgContLang->timeanddate( $expiry[$action], false, false ) ,
                                                $wgContLang->date( $expiry[$action], false, false ) ,
                                                $wgContLang->time( $expiry[$action], false, false )
                                        )->inContentLanguage()->text();
                                } else {
-                                       $protectDescription .= wfMessage( 'protect-expiry-indefinite' )
+                                       $expiryText = wfMessage( 'protect-expiry-indefinite' )
                                                ->inContentLanguage()->text();
                                }
 
-                               $protectDescription .= ') ';
+                               if ( $protectDescription !== '' ) {
+                                       $protectDescription .= wfMessage( 'word-separator' )->inContentLanguage()->text();
+                               }
+                               $protectDescription .= wfMessage( 'protect-summary-desc' )
+                                       ->params( $actionText, $restrictionsText, $expiryText )
+                                       ->inContentLanguage()->text();
                        }
                }
-               $protectDescription = trim( $protectDescription );
 
                if ( $id ) { # Protection of existing page
                        if ( !wfRunHooks( 'ArticleProtect', array( &$this, &$user, $limit, $reason ) ) ) {
@@ -2338,12 +2353,14 @@ class WikiPage extends Page implements IDBAccessObject {
                                $editComment .= ": $reason";
                        }
                        if ( $protectDescription ) {
-                               $editComment .= " ($protectDescription)";
+                               $editComment .= wfMessage( 'word-separator' )->inContentLanguage()->text();
+                               $editComment .= wfMessage( 'parentheses' )->params( $protectDescription )->inContentLanguage()->text();
                        }
                        if ( $cascade ) {
-                               // FIXME: Should use 'brackets' message.
-                               $editComment .= ' [' . wfMessage( 'protect-summary-cascade' )
-                                       ->inContentLanguage()->text() . ']';
+                               $editComment .= wfMessage( 'word-separator' )->inContentLanguage()->text();
+                               $editComment .= wfMessage( 'brackets' )->params(
+                                       wfMessage( 'protect-summary-cascade' )->inContentLanguage()->text()
+                               )->inContentLanguage()->text();
                        }
 
                        # Insert a null revision
index 422a4e5..bb8f4cf 100644 (file)
@@ -3015,6 +3015,7 @@ You can change this page's protection level, but it will not affect the cascadin
 'protect-fallback'            => 'Require "$1" permission',
 'protect-level-autoconfirmed' => 'Block new and unregistered users',
 'protect-level-sysop'         => 'Administrators only',
+'protect-summary-desc'        => '[$1=$2] ($3)', # only translate this message to other languages if you have to change it
 'protect-summary-cascade'     => 'cascading',
 'protect-expiring'            => 'expires $1 (UTC)',
 'protect-expiring-local'      => 'expires $1',
index d8ef2df..a992044 100644 (file)
@@ -4660,6 +4660,10 @@ Also used in [[Special:ProtectedPages]] when a page is cascade protected. See ex
 See also:
 *{{msg-mw|Restriction-level-sysop}}
 *{{msg-mw|Restriction-level-autoconfirmed}}',
+'protect-summary-desc' => 'Used in edit summary for description of a protecting restriction.
+* $1 is action, taken from restriction-*
+* $2 is restriction, taken from protect-level-*
+* $3 is {{msg-mw|protect-expiring}} or {{msg-mw|protect-expiry-indefinite}}',
 'protect-expiring' => 'Used in page history, and in [[Special:Protectedtitles]], [[Special:Protectedpages]], and extension FlaggedRevs.
 * $1 is a date and time
 * $2 is a date (optional)
index d22070f..960ead9 100644 (file)
@@ -365,6 +365,7 @@ $wgOptionalMessages = array(
        'exif-maxaperturevalue-value',
        'exif-subjectnewscode-value',
        'booksources-isbn',
+       'protect-summary-desc',
        'sp-contributions-explain',
        'sorbs',
        'video-dims',
index fad1da1..16e7546 100644 (file)
@@ -2036,6 +2036,7 @@ $wgMessageStructure = array(
                'protect-fallback',
                'protect-level-autoconfirmed',
                'protect-level-sysop',
+               'protect-summary-desc',
                'protect-summary-cascade',
                'protect-expiring',
                'protect-expiring-local',