r99312 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99311‎ | r99312 | r99313 >
Date:14:13, 8 October 2011
Author:nikerabbit
Status:resolved (Comments)
Tags:
Comment:
Part of bug 31503 - Allow gender distinction also for user groups
Modified paths:
  • /trunk/phase3/includes/Preferences.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialActiveusers.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialListusers.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserrights.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1908,12 +1908,12 @@
19091909 'group-suppress' => 'Oversights',
19101910 'group-all' => '(all)',
19111911
1912 -'group-user-member' => 'user',
1913 -'group-autoconfirmed-member' => 'autoconfirmed user',
1914 -'group-bot-member' => 'bot',
1915 -'group-sysop-member' => 'administrator',
1916 -'group-bureaucrat-member' => 'bureaucrat',
1917 -'group-suppress-member' => 'oversight',
 1912+'group-user-member' => '{{GENDER:$1|user}}',
 1913+'group-autoconfirmed-member' => '{{GENDER:$1|autoconfirmed user}}',
 1914+'group-bot-member' => '{{GENDER:$1|bot}}',
 1915+'group-sysop-member' => '{{GENDER:$1|administrator}}',
 1916+'group-bureaucrat-member' => '{{GENDER:$1|bureaucrat}}',
 1917+'group-suppress-member' => '{{GENDER:$1|oversight}}',
19181918
19191919 'grouppage-user' => '{{ns:project}}:Users',
19201920 'grouppage-autoconfirmed' => '{{ns:project}}:Autoconfirmed users',
Index: trunk/phase3/includes/specials/SpecialUserrights.php
@@ -450,7 +450,7 @@
451451 wfMessage( 'editinguser' )->params( wfEscapeWikiText( $user->getName() ) )->rawParams( $userToolLinks )->parse() .
452452 wfMsgExt( 'userrights-groups-help', array( 'parse' ) ) .
453453 $grouplist .
454 - Xml::tags( 'p', null, $this->groupCheckboxes( $groups ) ) .
 454+ Xml::tags( 'p', null, $this->groupCheckboxes( $groups, $user ) ) .
455455 Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-userrights-table-outer' ) ) .
456456 "<tr>
457457 <td class='mw-label'>" .
@@ -501,7 +501,7 @@
502502 * @param $usergroups Array: groups the user belongs to
503503 * @return string XHTML table element with checkboxes
504504 */
505 - private function groupCheckboxes( $usergroups ) {
 505+ private function groupCheckboxes( $usergroups, $user ) {
506506 $allgroups = $this->getAllGroups();
507507 $ret = '';
508508
@@ -549,11 +549,11 @@
550550 foreach( $column as $group => $checkbox ) {
551551 $attr = $checkbox['disabled'] ? array( 'disabled' => 'disabled' ) : array();
552552
 553+ $member = User::getGroupMember( $group, $user->getName() );
553554 if ( $checkbox['irreversible'] ) {
554 - $text = htmlspecialchars( wfMsg( 'userrights-irreversible-marker',
555 - User::getGroupMember( $group ) ) );
 555+ $text = wfMessage( 'userrights-irreversible-marker', $member )->escaped();
556556 } else {
557 - $text = htmlspecialchars( User::getGroupMember( $group ) );
 557+ $text = htmlspecialchars( $member );
558558 }
559559 $checkboxHtml = Xml::checkLabel( $text, "wpGroup-" . $group,
560560 "wpGroup-" . $group, $checkbox['set'], $attr );
Index: trunk/phase3/includes/specials/SpecialListusers.php
@@ -135,7 +135,7 @@
136136 if( count( $groups_list ) > 0 ) {
137137 $list = array();
138138 foreach( $groups_list as $group )
139 - $list[] = self::buildGroupLink( $group );
 139+ $list[] = self::buildGroupLink( $group, $userPage->getText() );
140140 $groups = $this->getLang()->commaList( $list );
141141 } else {
142142 $groups = '';
@@ -263,11 +263,8 @@
264264 * @param $group String: group name
265265 * @return string
266266 */
267 - protected static function buildGroupLink( $group ) {
268 - static $cache = array();
269 - if( !isset( $cache[$group] ) )
270 - $cache[$group] = User::makeGroupLinkHtml( $group, htmlspecialchars( User::getGroupMember( $group ) ) );
271 - return $cache[$group];
 267+ protected static function buildGroupLink( $group, $username ) {
 268+ return User::makeGroupLinkHtml( $group, htmlspecialchars( User::getGroupMember( $group, $username ) ) );
272269 }
273270 }
274271
Index: trunk/phase3/includes/specials/SpecialActiveusers.php
@@ -124,7 +124,7 @@
125125 if ( isset( $this->groups[$group] ) ) {
126126 return;
127127 }
128 - $list[] = self::buildGroupLink( $group );
 128+ $list[] = self::buildGroupLink( $group, $userName );
129129 }
130130 $groups = $this->getLang()->commaList( $list );
131131
Index: trunk/phase3/includes/User.php
@@ -3562,10 +3562,11 @@
35633563 * Get the localized descriptive name for a member of a group, if it exists
35643564 *
35653565 * @param $group String Internal group name
 3566+ * @param $username String Username for gender (since 1.19)
35663567 * @return String Localized name for group member
35673568 */
3568 - public static function getGroupMember( $group ) {
3569 - $msg = wfMessage( "group-$group-member" );
 3569+ public static function getGroupMember( $group, $username = '#' ) {
 3570+ $msg = wfMessage( "group-$group-member", $username );
35703571 return $msg->isBlank() ? $group : $msg->text();
35713572 }
35723573
Index: trunk/phase3/includes/Preferences.php
@@ -159,7 +159,7 @@
160160 $groupName = User::getGroupName( $ueg );
161161 $userGroups[] = User::makeGroupLinkHTML( $ueg, $groupName );
162162
163 - $memberName = User::getGroupMember( $ueg );
 163+ $memberName = User::getGroupMember( $ueg, $user->getName() );
164164 $userMembers[] = User::makeGroupLinkHTML( $ueg, $memberName );
165165 }
166166 asort( $userGroups );

Follow-up revisions

RevisionCommit summaryAuthorDate
r99343GENDER is optional. Blacklist these messages, changed in r99312, for the vari...raymond10:10, 9 October 2011
r99394Follow-up r99312: bug 31581: Allow gender distinction for user groups in exte...siebrand08:29, 10 October 2011
r107881remove useless gender for english group name...hashar11:57, 3 January 2012
r107882Fix gender on Special:Userrights...hashar12:48, 3 January 2012

Comments

#Comment by Siebrand (talk | contribs)   14:25, 8 October 2011

Gender for bot? :)

Should oversight be "oversighter" or something?

#Comment by Platonides (talk | contribs)   14:40, 8 October 2011

You pass a test to the bot, and it determines the gender of its algorithms :)

#Comment by Dantman (talk | contribs)   14:45, 8 October 2011
#Comment by Nikerabbit (talk | contribs)   15:57, 8 October 2011

Just changed them all for consistency.

#Comment by Raymond (talk | contribs)   10:03, 9 October 2011

Should this revision be tagged with "i18ndeploy"?

#Comment by Nikerabbit (talk | contribs)   11:08, 9 October 2011

Imho no, it's not that urgent.

#Comment by Jack Phoenix (talk | contribs)   17:39, 18 October 2011

This seems a bit awkward for English since English doesn't have any gender distinctions there. I mean, sure, French (fr) can use {{GENDER:$1|utilisateur|utilisatrice}} for 'group-user-member' message instead of whatever is currently used (I'd assume it'd be just utilisateur), but for English messages, this seems quite overkill to me.

#Comment by Nikerabbit (talk | contribs)   17:53, 18 October 2011

Like I said in r99394, it's very handy self-documenting way for everybody editing those messages. Even English can make distinction on some groups. If there is no other reason than "it looks weird" I'd rather save the effort and let it stay like it is currently.

#Comment by Hashar (talk | contribs)   11:58, 3 January 2012

With r107881 I have moved that documentation to QQQ and updated the tw.net template 'doc-group'.

#Comment by Hashar (talk | contribs)   12:50, 3 January 2012

Some messages in Special:Userrights were not being passed a user object. Done with r107882.


Marking, as resolved / ok.

Status & tagging log