Bsitu has uploaded a new change for review. https://gerrit.wikimedia.org/r/81170
Change subject: archive page and overlay should respect ?uselang=xxx ...................................................................... archive page and overlay should respect ?uselang=xxx This has not been fully tested yet and this is just a draft implentation bug: 52992 Change-Id: I3585f28d4ec97b86a467958bdfd603791f293d52 --- M Echo.php M api/ApiEchoNotifications.php M formatters/BasicFormatter.php M formatters/PageLinkFormatter.php M includes/EmailFormatter.php M modules/overlay/ext.echo.overlay.js M modules/special/ext.echo.special.js 7 files changed, 37 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo refs/changes/70/81170/1 diff --git a/Echo.php b/Echo.php index 897baec..4a27caf 100644 --- a/Echo.php +++ b/Echo.php @@ -143,6 +143,7 @@ 'dependencies' => array( 'jquery.ui.button', 'mediawiki.api', + 'mediawiki.Uri' ), 'messages' => array( 'cancel', diff --git a/api/ApiEchoNotifications.php b/api/ApiEchoNotifications.php index 25ddb83..2d5c67c 100644 --- a/api/ApiEchoNotifications.php +++ b/api/ApiEchoNotifications.php @@ -199,6 +199,7 @@ ), 'index' => false, 'continue' => null, + 'uselang' => null ); } @@ -211,6 +212,7 @@ 'index' => 'If specified, a list of notification IDs, in order, will be returned.', 'limit' => 'The maximum number of notifications to return.', 'continue' => 'When more results are available, use this to continue', + 'uselang' => 'the desired language to format the output' ); } diff --git a/formatters/BasicFormatter.php b/formatters/BasicFormatter.php index 5c7ed92..9e28f94 100644 --- a/formatters/BasicFormatter.php +++ b/formatters/BasicFormatter.php @@ -237,15 +237,12 @@ $userLanguage = $user->getOption( 'language' ); $dismissTitle = wfMessage( 'echo-category-title-' . $event->getCategory() ) - ->inLanguage( $userLanguage ) ->numParams( 1 ) ->text(); $dismissMessage = wfMessage( 'echo-dismiss-message', $dismissTitle ) - ->inLanguage( $userLanguage ) ->escaped(); $dismiss = Xml::tags( 'div', array( 'class' => 'mw-echo-dismiss-message' ), $dismissMessage ) . "\n"; $prefsMessage = wfMessage( 'echo-dismiss-prefs-message' ) - ->inLanguage( $userLanguage ) ->escaped(); $dismiss .= Xml::tags( 'div', array( 'class' => 'mw-echo-prefs-dismiss-message' ), $prefsMessage ) . "\n"; $dismiss = Xml::tags( 'div', array( 'class' => 'mw-echo-dismiss', 'style' => 'display:none;' ), $dismiss ) . "\n"; @@ -339,11 +336,14 @@ * @param $details array An i18n message and parameters to pass to the message * @param $event EchoEvent that the notification is for. * @param $user User to format the notification for. + * @param $lang string The language to format the message to * @return string */ - public function formatFragment( $details, $event, $user ) { - $message = wfMessage( $details['message'] ) - ->inLanguage( $user->getOption( 'language' ) ); + public function formatFragment( $details, $event, $user, $lang = '' ) { + $message = wfMessage( $details['message'] ); + if ( $lang ) { + $message->inLanguage( $lang ); + } $this->processParams( $details['params'], $event, $message, $user ); @@ -627,7 +627,7 @@ * 'border: 1px solid green; text-decoration: none;' (optional) * @return String URL for link, or HTML for anchor tag, or empty string */ - public function getLink( $event, $user, $rank = 'primary', $local = true, $urlOnly = false, $style = '' ) { + public function getLink( $event, $user, $rank = 'primary', $local = true, $urlOnly = false, $style = '', $inUserLang = false ) { $destination = $event->getLinkDestination( $rank ); if ( !$destination ) { return ''; @@ -645,7 +645,11 @@ return $target->getFullURL( $query, false, PROTO_HTTPS ); } } else { - $message = wfMessage( $event->getLinkMessage( $rank ) )->inLanguage( $user->getOption( 'language' ) )->text(); + $message = wfMessage( $event->getLinkMessage( $rank ) ); + if ( $inUserLang ) { + $message->inLanguage( $user->getOption( 'language' ) ); + } + $message->text(); $attribs = array( 'class' => "mw-echo-notification-{$rank}-link" ); if ( $style ) { $attribs['style'] = $style; @@ -753,7 +757,6 @@ if ( $this->bundleData['agent-other-count'] > $wgEchoMaxNotificationCount ) { $message->params( wfMessage( 'echo-notification-count' ) - ->inLanguage( $user->getOption( 'language' ) ) ->params( $wgEchoMaxNotificationCount ) ->text() ); diff --git a/formatters/PageLinkFormatter.php b/formatters/PageLinkFormatter.php index a718be6..81c6595 100644 --- a/formatters/PageLinkFormatter.php +++ b/formatters/PageLinkFormatter.php @@ -146,7 +146,6 @@ if ( $this->bundleData['link-from-page-other-count'] > $wgEchoMaxNotificationCount ) { $message->params( wfMessage( 'echo-notification-count' ) - ->inLanguage( $user->getOption( 'language' ) ) ->params( $wgEchoMaxNotificationCount ) ->text() ); diff --git a/includes/EmailFormatter.php b/includes/EmailFormatter.php index 21a7076..fecf793 100644 --- a/includes/EmailFormatter.php +++ b/includes/EmailFormatter.php @@ -241,7 +241,8 @@ $message = $this->notifFormatter->formatFragment( $detail, $this->event, - $this->user + $this->user, + $this->user->getOption( 'language' ) ); return $this->decorator->decorateIntro( $message ); @@ -659,7 +660,7 @@ * {@inheritDoc} */ public function decorateSingleAction( $notifFormatter, $event, $user, $rank, $message ) { - $url = $notifFormatter->getLink( $event, $user, $rank, false, true ); + $url = $notifFormatter->getLink( $event, $user, $rank, false, true, '', true ); return EchoEmailMode::message( $message, $user )->text() . EchoEmailMode::message( 'colon-separator', $user )->text() @@ -753,7 +754,7 @@ $style = $this->getSecondaryLinkCSS(); } - return $notifFormatter->getLink( $event, $user, $rank, false, false, $style ); + return $notifFormatter->getLink( $event, $user, $rank, false, false, $style, true ); } /** diff --git a/modules/overlay/ext.echo.overlay.js b/modules/overlay/ext.echo.overlay.js index f03f5ca..adb5c7c 100644 --- a/modules/overlay/ext.echo.overlay.js +++ b/modules/overlay/ext.echo.overlay.js @@ -23,6 +23,7 @@ $overlay = $( '<div></div>' ).addClass( 'mw-echo-overlay' ), $prefLink = $( '#pt-preferences a' ), count = 0, + apiData, api = new mw.Api( { ajax: { cache: false } } ); // Set notification limit based on height of the window @@ -34,13 +35,19 @@ notificationLimit = 8; } - api.get( { + apiData = { 'action' : 'query', 'meta' : 'notifications', 'notformat' : 'flyout', 'notlimit' : notificationLimit, 'notprop' : 'index|list|count' - } ).done( function ( result ) { + } + + if ( typeof mw.Uri().query.uselang !== 'undefined' ) { + apiData.uselang = mw.Uri().query.uselang; + } + + api.get( apiData ).done( function ( result ) { var notifications = result.query.notifications, unread = [], unreadTotalCount = result.query.notifications.count, diff --git a/modules/special/ext.echo.special.js b/modules/special/ext.echo.special.js index 8903930..094d778 100644 --- a/modules/special/ext.echo.special.js +++ b/modules/special/ext.echo.special.js @@ -60,16 +60,22 @@ * Load more notification records. */ loadMore: function () { - var api = new mw.Api( { ajax: { cache: false } } ), notifications, data, container, $li, that = this, unread = []; + var api = new mw.Api( { ajax: { cache: false } } ), notifications, data, container, $li, that = this, unread = [], apiData; - api.get( { + apiData = { 'action' : 'query', 'meta' : 'notifications', 'notformat' : 'html', 'notprop' : 'index|list', 'notcontinue': this.notcontinue, 'notlimit': mw.config.get( 'wgEchoDisplayNum' ) - } ).done( function ( result ) { + } + + if ( typeof mw.Uri().query.uselang !== 'undefined' ) { + apiData.uselang = mw.Uri().query.uselang; + } + + api.get( apiData ).done( function ( result ) { container = $( '#mw-echo-special-container' ); notifications = result.query.notifications; unread = []; -- To view, visit https://gerrit.wikimedia.org/r/81170 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3585f28d4ec97b86a467958bdfd603791f293d52 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Bsitu <bs...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits