From d4661cd3790f5199e2729fab7991ec6074ff66e3 Mon Sep 17 00:00:00 2001 From: bsitu Date: Tue, 20 Aug 2013 16:23:37 -0700 Subject: [PATCH] Add gender support to two i18n messages * thanks-thank-tooltip * logentry-thanks-thank Change-Id: Ib5e17695dda7db5b07db51bb20579d23f88666e5 --- Thanks.hooks.php | 9 ++++++--- Thanks.i18n.php | 11 +++++++---- ThanksLogFormatter.php | 1 + 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Thanks.hooks.php b/Thanks.hooks.php index 055acfaa..0733cbcf 100644 --- a/Thanks.hooks.php +++ b/Thanks.hooks.php @@ -34,7 +34,7 @@ class ThanksHooks { $recipientAllowed = !in_array( 'bot', $recipient->getGroups() ); } if ( $recipientAllowed && !$recipient->isAnon() ) { - $links[] = self::generateThankElement( $rev ); + $links[] = self::generateThankElement( $rev, $recipient ); } } return true; @@ -44,8 +44,9 @@ class ThanksHooks { * Helper for self::insertThankLink * Creates either a thank link or thanked span based on users session * @param $rev Revision object to generate the thank element for + * @param $recipient User the user who receives thanks notification */ - protected static function generateThankElement( $rev ) { + protected static function generateThankElement( $rev, $recipient ) { global $wgUser; // User has already thanked for revision if ( $wgUser->getRequest()->getSessionData( "thanks-thanked-{$rev->getId()}" ) ) { @@ -57,7 +58,9 @@ class ThanksHooks { } // Add 'thank' link - $tooltip = wfMessage( 'thanks-thank-tooltip' )->text(); + $tooltip = wfMessage( 'thanks-thank-tooltip' ) + ->params( $wgUser->getName(), $recipient->getName() ) + ->text(); return Html::element( 'a', diff --git a/Thanks.i18n.php b/Thanks.i18n.php index 5e17890a..56901185 100644 --- a/Thanks.i18n.php +++ b/Thanks.i18n.php @@ -17,7 +17,7 @@ $messages['en'] = array( 'thanks-error-undefined' => 'Thank action failed. Please try again.', 'thanks-error-invalidrevision' => 'Revision ID is not valid.', 'thanks-error-ratelimited' => "You've exceeded your rate limit. Please wait some time and try again.", - 'thanks-thank-tooltip' => 'Send a thank you notification to this user', + 'thanks-thank-tooltip' => '{{GENDER:$1|Send}} a thank you notification to this {{GENDER:$2|user}}', 'thanks-confirmation' => 'Are you sure you want to {{GENDER:$1|thank}} $2 for this edit?', 'echo-pref-subscription-edit-thank' => 'Thanks me for my edit', 'echo-pref-tooltip-edit-thank' => 'Notify me when someone thanks me for an edit I made.', @@ -30,7 +30,7 @@ $messages['en'] = array( 'notification-link-text-respond-to-user' => 'Respond to user', 'log-name-thanks' => 'Thanks log', 'log-description-thanks' => 'Below is a list of users thanked by other users.', - 'logentry-thanks-thank' => '$1 {{GENDER:$2|thanked}} $3', + 'logentry-thanks-thank' => '$1 {{GENDER:$2|thanked}} {{GENDER:$4|$3}}', ); /** Message documentation (Message documentation) @@ -51,7 +51,9 @@ Parameters: {{Identical|Please try again}}', 'thanks-error-invalidrevision' => 'Error message that is displayed when the revision ID is not valid', 'thanks-error-ratelimited' => 'Error message that is displayed when user exceeds rate limit', - 'thanks-thank-tooltip' => 'Tooltip that appears when a user hovers over the "thank" link', + 'thanks-thank-tooltip' => 'Tooltip that appears when a user hovers over the "thank" link. Parameters +* $1 - The user sending the thanks. Can be used for GENDER support. +* $2 - The user receiving the thanks. Can be used for GENDER support', 'thanks-confirmation' => 'A confirmation message to make sure the user actually wants to send thanks to another user. Parameters: @@ -85,7 +87,8 @@ Used for $2 in {{msg-mw|Notification-thanks}}. Should have capitali 'logentry-thanks-thank' => 'Log entry that is created when a user thanks another user for an edit. Parameters: * $1 is a user link, for example "Jane Doe (Talk | contribs)" * $2 is a username. Can be used for GENDER. -* $3 is a user link, for example "John Doe (Talk | contribs)', +* $3 is a user link, for example "John Doe (Talk | contribs) +* $4 is the username of the recipient. Can be used for GENDER.', ); /** Arabic (العربية) diff --git a/ThanksLogFormatter.php b/ThanksLogFormatter.php index b55c2b2d..17d6b129 100644 --- a/ThanksLogFormatter.php +++ b/ThanksLogFormatter.php @@ -9,6 +9,7 @@ class ThanksLogFormatter extends LogFormatter { // actually a user, not a page. $recipient = User::newFromName( $this->entry->getTarget()->getText(), false ); $params[2] = Message::rawParam( $this->makeUserLink( $recipient ) ); + $params[3] = $recipient->getName(); return $params; }