From bef26fbb405bb617f52fdbe1b3dc5b6791e2fbda Mon Sep 17 00:00:00 2001
From: Pavel Selitskas
Date: Mon, 3 Dec 2012 00:31:30 +0300
Subject: [PATCH] Genderize Special:Preferences
GENDER support added for messages:
* username
* uid
* prefs-memberingroups
These messages require GENDER for grammatically correct sentences
at least in some Slavic languages. Perhaps, other languages may
require its support in other messages as well (e.g. yourrealname).
+ Some refactoring per review request.
Change-Id: I51cc8ea9128dda90d87de656ea3a4605a5dc04e0
---
includes/Preferences.php | 40 +++++++++++++-----------------
languages/messages/MessagesEn.php | 6 ++---
languages/messages/MessagesQqq.php | 10 +++++---
3 files changed, 27 insertions(+), 29 deletions(-)
diff --git a/includes/Preferences.php b/includes/Preferences.php
index a3c684b560..67258489e4 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -158,18 +158,21 @@ class Preferences {
$wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication,
$wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress;
+ // retrieving user name for GENDER and misc.
+ $userName = $user->getName();
+
## User info #####################################
// Information panel
$defaultPreferences['username'] = array(
'type' => 'info',
- 'label-message' => 'username',
- 'default' => $user->getName(),
+ 'label-message' => array( 'username', $userName ),
+ 'default' => $userName,
'section' => 'personal/info',
);
$defaultPreferences['userid'] = array(
'type' => 'info',
- 'label-message' => 'uid',
+ 'label-message' => array( 'uid', $userName ),
'default' => $user->getId(),
'section' => 'personal/info',
);
@@ -185,7 +188,7 @@ class Preferences {
$groupName = User::getGroupName( $ueg );
$userGroups[] = User::makeGroupLinkHTML( $ueg, $groupName );
- $memberName = User::getGroupMember( $ueg, $user->getName() );
+ $memberName = User::getGroupMember( $ueg, $userName );
$userMembers[] = User::makeGroupLinkHTML( $ueg, $memberName );
}
asort( $userGroups );
@@ -196,7 +199,7 @@ class Preferences {
$defaultPreferences['usergroups'] = array(
'type' => 'info',
'label' => $context->msg( 'prefs-memberingroups' )->numParams(
- count( $userGroups ) )->parse(),
+ count( $userGroups ) )->params( $userName )->parse(),
'default' => $context->msg( 'prefs-memberingroups-type',
$lang->commaList( $userGroups ),
$lang->commaList( $userMembers )
@@ -507,14 +510,15 @@ class Preferences {
# be nice to somehow merge this back in there to avoid redundancy.
if ( $wgAllowUserCss || $wgAllowUserJs ) {
$linkTools = array();
+ $userName = $user->getName();
if ( $wgAllowUserCss ) {
- $cssPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.css' );
+ $cssPage = Title::makeTitleSafe( NS_USER, $userName . '/common.css' );
$linkTools[] = Linker::link( $cssPage, $context->msg( 'prefs-custom-css' )->escaped() );
}
if ( $wgAllowUserJs ) {
- $jsPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.js' );
+ $jsPage = Title::makeTitleSafe( NS_USER, $userName . '/common.js' );
$linkTools[] = Linker::link( $jsPage, $context->msg( 'prefs-custom-js' )->escaped() );
}
@@ -1009,27 +1013,17 @@ class Preferences {
'section' => 'searchoptions/advancedsearchoptions',
);
- $nsOptions = array();
-
- foreach ( $wgContLang->getNamespaces() as $ns => $name ) {
- if ( $ns < 0 ) {
- continue;
- }
-
- $displayNs = str_replace( '_', ' ', $name );
-
- if ( !$displayNs ) {
- $displayNs = $context->msg( 'blanknamespace' )->text();
- }
-
- $displayNs = htmlspecialchars( $displayNs );
- $nsOptions[$displayNs] = $ns;
+ $nsOptions = $wgContLang->getFormattedNamespaces();
+ $nsOptions[0] = $context->msg( 'blanknamespace' )->text();
+ foreach ( $nsOptions as $ns => $name ) {
+ if ( $ns < 0 )
+ unset( $nsOptions[$ns] );
}
$defaultPreferences['searchnamespaces'] = array(
'type' => 'multiselect',
'label-message' => 'defaultns',
- 'options' => $nsOptions,
+ 'options' => array_flip( $nsOptions ),
'section' => 'searchoptions/advancedsearchoptions',
'prefix' => 'searchNs',
);
diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php
index 09e0ad0887..cd3ef1abea 100644
--- a/languages/messages/MessagesEn.php
+++ b/languages/messages/MessagesEn.php
@@ -1890,9 +1890,9 @@ This cannot be undone.',
'prefs-emailconfirm-label' => 'E-mail confirmation:',
'prefs-textboxsize' => 'Size of editing window',
'youremail' => 'E-mail:',
-'username' => 'Username:',
-'uid' => 'User ID:',
-'prefs-memberingroups' => 'Member of {{PLURAL:$1|group|groups}}:',
+'username' => '{{GENDER:$1|Username}}:',
+'uid' => '{{GENDER:$1|User}} ID:',
+'prefs-memberingroups' => '{{GENDER:$2|Member}} of {{PLURAL:$1|group|groups}}:',
'prefs-memberingroups-type' => '$1', # only translate this message to other languages if you have to change it
'prefs-registration' => 'Registration time:',
'prefs-registration-date-time' => '$1', # only translate this message to other languages if you have to change it
diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php
index 9dfe974250..97e365c218 100644
--- a/languages/messages/MessagesQqq.php
+++ b/languages/messages/MessagesQqq.php
@@ -1576,9 +1576,13 @@ Shown as legend of the second fieldset of the tab 'Search' in [[Special:Preferen
'youremail' => 'Label of the e-mail text box of the "E-mail options" section of "Special:Preferences".
{{Identical|E-mail}}',
-'username' => '{{Identical|Username}}',
-'uid' => '{{Identical|User ID}}',
-'prefs-memberingroups' => 'This message is shown on [[Special:Preferences]], first tab. See also {{msg-mw|prefs-memberingroups-type}}.',
+'username' => 'Username field in [[Special:Preferences]]. $1 is the current user name for GENDER distinction (depends on sex setting).
+
+{{Identical|Username}}',
+'uid' => 'User ID field in [[Special:Preferences]]. $1 is the current user name for GENDER distinction (depends on sex setting).
+
+{{Identical|User ID}}',
+'prefs-memberingroups' => 'This message is shown on [[Special:Preferences]], first tab. See also {{msg-mw|prefs-memberingroups-type}}. $2 is the user name for GENDER.',
'prefs-memberingroups-type' => '{{optional}}
Parameters:
* $1 is list of group names
--
2.20.1