Move list of wiki names from header to body in cross-wiki notification item

Using wiki names in the header is problematic because the messages
we were using weren't designed to be used in a sentence, only in headings.
This removes the wiki names from the sentence in the header, and
instead puts a comma-separated list (with "and") of wikis in the body.

The messages keep $3 and $4 for backwards compatibility, so translations
of the form "from Commons and 2 other wikis" will keep working.

Bug: T121936
Change-Id: Ideeba794e260b3c388fa29226b53197c050162ef
This commit is contained in:
Roan Kattouw 2016-02-29 23:11:09 -08:00
parent e08d3e604c
commit c466a5ef5c
3 changed files with 24 additions and 8 deletions

View file

@ -159,8 +159,9 @@
"echo-email-batch-body-intro-weekly": "Hi $1,\nHere's a summary of this week's activity on {{SITENAME}} for you.",
"echo-email-batch-link-text-view-all-notifications": "View all notifications",
"echo-rev-deleted-text-view": "This page revision has been suppressed.",
"notification-header-foreign-alert": "More alerts from $3 {{PLURAL:$4|and one other wiki|and $4 other wikis|0=}}",
"notification-header-foreign-message": "More messages from $3 {{PLURAL:$4|and one other wiki|and $4 other wikis|0=}}",
"notification-header-foreign-alert": "More alerts from {{PLURAL:$5|another wiki|$5 other wikis}}",
"notification-header-foreign-message": "More messages from {{PLURAL:$5|another wiki|$5 other wikis}}",
"notification-body-foreign": "$1",
"echo-foreign-wiki-lang": "$1 - $2",
"apihelp-echomarkread-description": "Mark notifications as read for the current user.",
"apihelp-echomarkread-param-list": "A list of notification IDs to mark as read.",

View file

@ -180,8 +180,9 @@
"echo-email-batch-body-intro-weekly": "Introduction text for weekly email digest. Parameters:\n* $1 - a username\nSee also:\n* {{msg-mw|Echo-email-batch-body-intro-daily}}",
"echo-email-batch-link-text-view-all-notifications": "The link text for the primary action in daily and weekly email digest",
"echo-rev-deleted-text-view": "Short message displayed instead of edit content when revision text is suppressed.",
"notification-header-foreign-alert": "Flyout-specific format for displaying notification header of having alert notifications on foreign wikis.\n\nParameters:\n* $1 - the formatted username of the current user.\n* $2 - the username for GENDER\n* $3 - 1 of the foreign wikis you have notifications on\n* $4 - the amount of remaining other wikis you have notifications on",
"notification-header-foreign-message": "Flyout-specific format for displaying notification header of having message notifications on foreign wikis.\n\nParameters:\n* $1 - the formatted username of the current user.\n* $2 - the username for GENDER\n* $3 - 1 of the foreign wikis you have notifications on\n* $4 - the amount of remaining other wikis you have notifications on",
"notification-header-foreign-alert": "Flyout-specific format for displaying notification header of having alert notifications on foreign wikis.\n\nParameters:\n* $1 - the formatted username of the current user.\n* $2 - the username for GENDER\n* $3 (deprecated) - 1 of the foreign wikis you have notifications on\n* $4 (deprecated) - the number of remaining other wikis you have notifications on\n*$5 - the number of other wikis you have notifications on",
"notification-header-foreign-message": "Flyout-specific format for displaying notification header of having message notifications on foreign wikis.\n\nParameters:\n* $1 - the formatted username of the current user.\n* $2 - the username for GENDER\n* $3 (deprecated) - 1 of the foreign wikis you have notifications on\n* $4 (deprecated) - the number of remaining other wikis you have notifications on\n*$5 - the number of other wikis you have notifications on",
"notification-body-foreign": "{{notranslate}}",
"echo-foreign-wiki-lang": "Title of the wiki for which you're seeing foreign notifications:\n\nParameters:\n* $1 - the name of the site (e.g. 'Wikipedia', 'Wikiversity', ...)\n* $2 - the language of the website (e.g. 'English', 'Deutsch', ...)",
"apihelp-echomarkread-description": "{{doc-apihelp-description|echomarkread}}",
"apihelp-echomarkread-param-list": "{{doc-apihelp-param|echomarkread|list}}",

View file

@ -20,15 +20,29 @@ class EchoForeignPresentationModel extends EchoEventPresentationModel {
$msg = parent::getHeaderMessage();
$data = $this->event->getExtra();
$msg->params( $this->getWikiName( reset( $data['wikis'] ) ) );
$firstWiki = reset( $data['wikis'] );
$names = $this->getWikiNames( array( $firstWiki ) );
$msg->params( $names[0] );
$msg->numParams( count( $data['wikis'] ) - 1 );
$msg->numParams( count( $data['wikis'] ) );
return $msg;
}
protected function getWikiName( $wiki ) {
public function getBodyMessage() {
$data = $this->event->getExtra();
$msg = wfMessage( "notification-body-{$this->type}" );
$msg->params( $this->language->listToText( $this->getWikiNames( $data['wikis'] ) ) );
return $msg;
}
protected function getWikiNames( array $wikis ) {
$foreign = new EchoForeignNotifications( new User );
$data = $foreign->getApiEndpoints( array( $wiki ) );
return $data[$wiki]['title'];
$data = $foreign->getApiEndpoints( $wikis );
$names = array();
foreach ( $wikis as $wiki ) {
$names[] = $data[$wiki]['title'];
}
return $names;
}
}