From 541170b9b364ddd59b4dc05e085a8cd85c3df4af Mon Sep 17 00:00:00 2001 From: Liangent Date: Fri, 2 Nov 2012 20:37:20 +0800 Subject: [PATCH] (bug 37176) Localize autosummary of page protecting Including parentheses, brackets, edit=sysop text, etc. A new message 'protect-summary-desc' has been added. Change-Id: I888c616ea896bb2585d79ef8ecb6f34fab196191 --- includes/WikiPage.php | 35 ++++++++++++++++++++------- languages/messages/MessagesEn.php | 1 + languages/messages/MessagesQqq.php | 4 +++ maintenance/language/messageTypes.inc | 1 + maintenance/language/messages.inc | 1 + 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 4086a20d87..7620b3adc5 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -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 diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 422a4e5dee..bb8f4cf919 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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', diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index d8ef2dfbcd..a992044606 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -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) diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index d22070f446..960ead90a0 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -365,6 +365,7 @@ $wgOptionalMessages = array( 'exif-maxaperturevalue-value', 'exif-subjectnewscode-value', 'booksources-isbn', + 'protect-summary-desc', 'sp-contributions-explain', 'sorbs', 'video-dims', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index fad1da1cb7..16e7546298 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -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', -- 2.20.1