* (bug 17145) Specific categories can be excluded from Special:UnusedCategories
with __IGNOREUNUSED__
* (bug 13040) Gender switch in user preferences
+* (bug 13040) {{GENDER:}} magic word for interface messages
=== Bug fixes in 1.15 ===
* (bug 16968) Special:Upload no longer throws useless warnings.
$parser->setFunctionHook( 'fullurle', array( __CLASS__, 'fullurle' ), SFH_NO_HASH );
$parser->setFunctionHook( 'formatnum', array( __CLASS__, 'formatnum' ), SFH_NO_HASH );
$parser->setFunctionHook( 'grammar', array( __CLASS__, 'grammar' ), SFH_NO_HASH );
+ $parser->setFunctionHook( 'gender', array( __CLASS__, 'gender' ), SFH_NO_HASH );
$parser->setFunctionHook( 'plural', array( __CLASS__, 'plural' ), SFH_NO_HASH );
$parser->setFunctionHook( 'numberofpages', array( __CLASS__, 'numberofpages' ), SFH_NO_HASH );
$parser->setFunctionHook( 'numberofusers', array( __CLASS__, 'numberofusers' ), SFH_NO_HASH );
return $parser->getFunctionLang()->convertGrammar( $word, $case );
}
+ static function gender( $parser, $user ) {
+ $forms = array_slice( func_get_args(), 2);
+
+ // default
+ $gender = User::getDefaultOption( 'gender' );
+
+ // check parameter, or use $wgUser if in interface message
+ $user = User::newFromName( $user );
+ if ( $user ) {
+ $gender = $user->getOption( 'gender' );
+ } elseif ( $parser->mOptions->getInterfaceMessage() ) {
+ global $wgUser;
+ $gender = $wgUser->getOption( 'gender' );
+ }
+ return $parser->getFunctionLang()->gender( $gender, $forms );
+ }
static function plural( $parser, $text = '') {
$forms = array_slice( func_get_args(), 2);
$text = $parser->getFunctionLang()->parseFormattedNumber( $text );
return $word;
}
+ /**
+ * Provides an alternative text depending on specified gender.
+ * Usage {{gender:username|masculine|feminine|neutral}}.
+ * username is optional, in which case the gender of current user is used,
+ * but only in (some) interface messages; otherwise default gender is used.
+ * If second or third parameter are not specified, masculine is used.
+ * These details may be overriden per language.
+ */
+ function gender( $gender, $forms ) {
+ $forms = $this->preConvertPlural( $forms, 2 );
+ if ( $gender === 'male' ) return $forms[0];
+ if ( $gender === 'female' ) return $forms[1];
+ return isset($forms[2]) ? $forms[2] : $forms[0];
+ }
+
/**
* Plural form transformations, needed for some languages.
* For example, there are 3 form of plural in Russian and Polish,