Index: trunk/phase3/includes/parser/CoreParserFunctions.php |
— | — | @@ -27,6 +27,7 @@ |
28 | 28 | $parser->setFunctionHook( 'fullurle', array( __CLASS__, 'fullurle' ), SFH_NO_HASH ); |
29 | 29 | $parser->setFunctionHook( 'formatnum', array( __CLASS__, 'formatnum' ), SFH_NO_HASH ); |
30 | 30 | $parser->setFunctionHook( 'grammar', array( __CLASS__, 'grammar' ), SFH_NO_HASH ); |
| 31 | + $parser->setFunctionHook( 'gender', array( __CLASS__, 'gender' ), SFH_NO_HASH ); |
31 | 32 | $parser->setFunctionHook( 'plural', array( __CLASS__, 'plural' ), SFH_NO_HASH ); |
32 | 33 | $parser->setFunctionHook( 'numberofpages', array( __CLASS__, 'numberofpages' ), SFH_NO_HASH ); |
33 | 34 | $parser->setFunctionHook( 'numberofusers', array( __CLASS__, 'numberofusers' ), SFH_NO_HASH ); |
— | — | @@ -155,6 +156,22 @@ |
156 | 157 | return $parser->getFunctionLang()->convertGrammar( $word, $case ); |
157 | 158 | } |
158 | 159 | |
| 160 | + static function gender( $parser, $user ) { |
| 161 | + $forms = array_slice( func_get_args(), 2); |
| 162 | + |
| 163 | + // default |
| 164 | + $gender = User::getDefaultOption( 'gender' ); |
| 165 | + |
| 166 | + // check parameter, or use $wgUser if in interface message |
| 167 | + $user = User::newFromName( $user ); |
| 168 | + if ( $user ) { |
| 169 | + $gender = $user->getOption( 'gender' ); |
| 170 | + } elseif ( $parser->mOptions->getInterfaceMessage() ) { |
| 171 | + global $wgUser; |
| 172 | + $gender = $wgUser->getOption( 'gender' ); |
| 173 | + } |
| 174 | + return $parser->getFunctionLang()->gender( $gender, $forms ); |
| 175 | + } |
159 | 176 | static function plural( $parser, $text = '') { |
160 | 177 | $forms = array_slice( func_get_args(), 2); |
161 | 178 | $text = $parser->getFunctionLang()->parseFormattedNumber( $text ); |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2430,6 +2430,7 @@ |
2431 | 2431 | 'watchmoves' => 0, |
2432 | 2432 | 'watchdeletion' => 0, |
2433 | 2433 | 'noconvertlink' => 0, |
| 2434 | + 'gender' => 'unknown', |
2434 | 2435 | ); |
2435 | 2436 | |
2436 | 2437 | /** Whether or not to allow and use real name fields. Defaults to true. */ |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -2065,6 +2065,21 @@ |
2066 | 2066 | } |
2067 | 2067 | |
2068 | 2068 | /** |
| 2069 | + * Provides an alternative text depending on specified gender. |
| 2070 | + * Usage {{gender:username|masculine|feminine|neutral}}. |
| 2071 | + * username is optional, in which case the gender of current user is used, |
| 2072 | + * but only in (some) interface messages; otherwise default gender is used. |
| 2073 | + * If second or third parameter are not specified, masculine is used. |
| 2074 | + * These details may be overriden per language. |
| 2075 | + */ |
| 2076 | + function gender( $gender, $forms ) { |
| 2077 | + $forms = $this->preConvertPlural( $forms, 2 ); |
| 2078 | + if ( $gender === 'male' ) return $forms[0]; |
| 2079 | + if ( $gender === 'female' ) return $forms[1]; |
| 2080 | + return isset($forms[2]) ? $forms[2] : $forms[0]; |
| 2081 | + } |
| 2082 | + |
| 2083 | + /** |
2069 | 2084 | * Plural form transformations, needed for some languages. |
2070 | 2085 | * For example, there are 3 form of plural in Russian and Polish, |
2071 | 2086 | * depending on "count mod 10". See [[w:Plural]] |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -63,6 +63,7 @@ |
64 | 64 | * (bug 17145) Specific categories can be excluded from Special:UnusedCategories |
65 | 65 | with __IGNOREUNUSED__ |
66 | 66 | * (bug 13040) Gender switch in user preferences |
| 67 | +* (bug 13040) {{GENDER:}} magic word for interface messages |
67 | 68 | |
68 | 69 | === Bug fixes in 1.15 === |
69 | 70 | * (bug 16968) Special:Upload no longer throws useless warnings. |