// TODO: Does this still need $wgTitle?
global $wgParser, $wgTitle;
- // Currently unnecessary, code to act as a safeguard against any change in current behaviour of uselang breaks
+ // Currently unnecessary, code to act as a safeguard against any change in current behaviour of uselang
$oldLang = null;
if ( isset( $params['uselang'] ) && $params['uselang'] != $this->getContext()->getLanguage()->getCode() ) {
$oldLang = $this->getContext()->getLanguage(); // Backup language
$res = array( 'title' => $title->getPrefixedText() );
+ // Currently unnecessary, code to act as a safeguard against any change in current behaviour of uselang
+ // Copy from ApiParse
+ $oldLang = null;
+ if ( isset( $params['uselang'] ) && $params['uselang'] != $this->getContext()->getLanguage()->getCode() ) {
+ $oldLang = $this->getContext()->getLanguage(); // Backup language
+ $this->getContext()->setLanguage( Language::factory( $params['uselang'] ) );
+ }
+
if ( $params['unwatch'] ) {
$res['unwatched'] = '';
$res['message'] = $this->msg( 'removedwatchtext', $title->getPrefixedText() )->title( $title )->parseAsBlock();
$res['message'] = $this->msg( 'addedwatchtext', $title->getPrefixedText() )->title( $title )->parseAsBlock();
$success = WatchAction::doWatch( $title, $user );
}
+
+ if ( !is_null( $oldLang ) ) {
+ $this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
+ }
+
if ( !$success ) {
$this->dieUsageMsg( 'hookaborted' );
}
ApiBase::PARAM_REQUIRED => true
),
'unwatch' => false,
+ 'uselang' => null,
'token' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true
return array(
'title' => 'The page to (un)watch',
'unwatch' => 'If set the page will be unwatched rather than watched',
+ 'uselang' => 'Language to show the message in',
'token' => 'A token previously acquired via prop=info',
);
}
$.extend( mw.Api.prototype, {
/**
- * Convinience method for 'action=watch'.
+ * Convenience method for 'action=watch'.
*
* @param page {String|mw.Title} Full page name or instance of mw.Title
* @param success {Function} Callback to which the watch object will be passed.
return doWatchInternal.call( this, page, success, err );
},
/**
- * Convinience method for 'action=watch&unwatch=1'.
+ * Convenience method for 'action=watch&unwatch=1'.
*
* @param page {String|mw.Title} Full page name or instance of mw.Title
* @param success {Function} Callback to which the watch object will be passed.