Add MWTimestamp::getTimezoneString(), use it in file revert message
MWTimestamp::getTimezoneString() returns the timezone name as a message, that supports wiki localization. The code is moved from Parser::pstPass2. The default file revert message is currently always in UTC. This patch sets the default timestamp to be in the wiki timezone (similar to ~~~~). The timezone is passed as a new parameter to the message, with the date / time parameters being merged and handled by $wgContentLang->timeanddate Bug: T36948 Change-Id: I48772f5f3b1635d33b6185776cedfc4ee1882494
This commit is contained in:
parent
b1ef4a066a
commit
90e1b22166
6 changed files with 35 additions and 16 deletions
|
|
@ -70,6 +70,9 @@ production.
|
|||
* Caches that need purging ability now use the WANObjectCache interface.
|
||||
This corresponds to a new $wgMainWANCache setting, which defaults to using
|
||||
the $wgMainCacheType settings.
|
||||
* Added MWTimestamp::getTimezoneString() which returns the localized timezone
|
||||
string, if available. To localize this string, see the comments of
|
||||
$wgLocaltimezone in includes/DefaultSettings.php.
|
||||
* Callers needing fast light-weight data stores use $wgMainStash to select
|
||||
the store type from $wgObjectCaches. The default is the local database.
|
||||
* Interface message overrides in the MediaWiki namespace will now be cached in
|
||||
|
|
@ -198,6 +201,8 @@ changes to languages because of Phabricator reports.
|
|||
* Watchlist tokens, SpecialResetTokens, and User::getTokenFromOption()
|
||||
are deprecated. Applications using those can work via the OAuth
|
||||
extension instead. New tokens types should not be added.
|
||||
* (T36948) The default file revert message's timestamp is now in $wgLocaltimezone,
|
||||
instead of UTC.
|
||||
* DatabaseBase::errorCount() was removed (unused).
|
||||
* $wgDeferredUpdateList was removed.
|
||||
* DeferredUpdates::addHTMLCacheUpdate() was removed.
|
||||
|
|
|
|||
|
|
@ -367,6 +367,26 @@ class MWTimestamp {
|
|||
return $this->timestamp->getTimezone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the localized timezone message, if available.
|
||||
*
|
||||
* Premade translations are not shipped as format() may return whatever the
|
||||
* system uses, localized or not, so translation must be done through wiki.
|
||||
*
|
||||
* @since 1.25
|
||||
* @return Message The localized timezone message
|
||||
*/
|
||||
public function getTimezoneMessage() {
|
||||
$tzMsg = $this->format( 'T' ); // might vary on DST changeover!
|
||||
$key = 'timezone-' . strtolower( trim( $tzMsg ) );
|
||||
$msg = wfMessage( $key );
|
||||
if ( $msg->exists() ) {
|
||||
return $msg;
|
||||
} else {
|
||||
return new RawMessage( $tzMsg );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the timestamp in a given format.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -82,8 +82,11 @@ class RevertAction extends FormAction {
|
|||
$lang = $this->getLanguage();
|
||||
$userDate = $lang->userDate( $timestamp, $user );
|
||||
$userTime = $lang->userTime( $timestamp, $user );
|
||||
$siteDate = $wgContLang->date( $timestamp, false, false );
|
||||
$siteTime = $wgContLang->time( $timestamp, false, false );
|
||||
$siteTs = MWTimestamp::getLocalInstance( $timestamp );
|
||||
$ts = $siteTs->format( 'YmdHis' );
|
||||
$siteDate = $wgContLang->date( $ts, false, false );
|
||||
$siteTime = $wgContLang->time( $ts, false, false );
|
||||
$tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text();
|
||||
|
||||
return array(
|
||||
'intro' => array(
|
||||
|
|
@ -100,8 +103,8 @@ class RevertAction extends FormAction {
|
|||
'comment' => array(
|
||||
'type' => 'text',
|
||||
'label-message' => 'filerevert-comment',
|
||||
'default' => $this->msg( 'filerevert-defaultcomment', $siteDate, $siteTime
|
||||
)->inContentLanguage()->text()
|
||||
'default' => $this->msg( 'filerevert-defaultcomment', $siteDate, $siteTime,
|
||||
$tzMsg )->inContentLanguage()->text()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4842,16 +4842,7 @@ class Parser {
|
|||
$ts = $this->mOptions->getTimestamp();
|
||||
$timestamp = MWTimestamp::getLocalInstance( $ts );
|
||||
$ts = $timestamp->format( 'YmdHis' );
|
||||
$tzMsg = $timestamp->format( 'T' ); # might vary on DST changeover!
|
||||
|
||||
# Allow translation of timezones through wiki. format() can return
|
||||
# whatever crap the system uses, localised or not, so we cannot
|
||||
# ship premade translations.
|
||||
$key = 'timezone-' . strtolower( trim( $tzMsg ) );
|
||||
$msg = wfMessage( $key )->inContentLanguage();
|
||||
if ( $msg->exists() ) {
|
||||
$tzMsg = $msg->text();
|
||||
}
|
||||
$tzMsg = $timestamp->getTimezoneMessage()->inContentLanguage()->text();
|
||||
|
||||
$d = $wgContLang->timeanddate( $ts, false, false ) . " ($tzMsg)";
|
||||
|
||||
|
|
|
|||
|
|
@ -1550,7 +1550,7 @@
|
|||
"filerevert-legend": "Revert file",
|
||||
"filerevert-intro": "You are about to revert the file <strong>[[Media:$1|$1]]</strong> to the [$4 version as of $3, $2].",
|
||||
"filerevert-comment": "Reason:",
|
||||
"filerevert-defaultcomment": "Reverted to version as of $2, $1",
|
||||
"filerevert-defaultcomment": "Reverted to version as of $2, $1 ($3)",
|
||||
"filerevert-submit": "Revert",
|
||||
"filerevert-success": "<strong>[[Media:$1|$1]]</strong> has been reverted to the [$4 version as of $3, $2].",
|
||||
"filerevert-badversion": "There is no previous local version of this file with the provided timestamp.",
|
||||
|
|
|
|||
|
|
@ -1723,7 +1723,7 @@
|
|||
"filerevert-legend": "{{Identical|Revert}}",
|
||||
"filerevert-intro": "Message displayed when you try to revert a version of a file.\n* $1 is the name of the media\n* $2 is a date\n* $3 is a time\n* $4 is a URL and must follow square bracket: [$4\n{{Identical|Revert}}",
|
||||
"filerevert-comment": "{{Identical|Reason}}",
|
||||
"filerevert-defaultcomment": "Parameters:\n* $1 - a date\n* $2 - a time\n{{Identical|Revert}}",
|
||||
"filerevert-defaultcomment": "Parameters:\n* $1 - a date\n* $2 - a time\n* $3 - a timezone\n{{Identical|Revert}}",
|
||||
"filerevert-submit": "{{Identical|Revert}}",
|
||||
"filerevert-success": "Message displayed when you succeed in reverting a version of a file.\n* $1 is the name of the media\n* $2 is a date\n* $3 is a time\n* $4 is an URL and must follow square bracket: [$4\n{{Identical|Revert}}",
|
||||
"filerevert-badversion": "Used as error message.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue