Index: trunk/phase3/includes/Title.php |
— | — | @@ -554,7 +554,7 @@ |
555 | 555 | * @return \type{\string} Namespace text |
556 | 556 | */ |
557 | 557 | public function getNsText() { |
558 | | - global $wgContLang, $wgCanonicalNamespaceNames; |
| 558 | + global $wgCanonicalNamespaceNames; |
559 | 559 | |
560 | 560 | if ( '' != $this->mInterwiki ) { |
561 | 561 | // This probably shouldn't even happen. ohh man, oh yuck. |
— | — | @@ -567,6 +567,35 @@ |
568 | 568 | return $wgCanonicalNamespaceNames[$this->mNamespace]; |
569 | 569 | } |
570 | 570 | } |
| 571 | + |
| 572 | + return $this->getNsTextInternal( $this->mNamespace ); |
| 573 | + } |
| 574 | + |
| 575 | + function getNsTextInternal( $namespace) { |
| 576 | + global $wgContLang, $wgSlowGenderAliases, $wgTitle, $title; |
| 577 | + if( $namespace === NS_USER || $namespace === NS_USER_TALK ) { |
| 578 | + static $gender = null; |
| 579 | + |
| 580 | + $name = $this->getBaseText(); |
| 581 | + if( !isset($gender[$name] ) ) { |
| 582 | + $gender[$name] = User::getDefaultOption( 'gender' ); |
| 583 | + |
| 584 | + // wgTitle may not be defined |
| 585 | + $mytitle = isset($wgTitle) ? $wgTitle: Title::newFromText($title); |
| 586 | + |
| 587 | + // Check stuff |
| 588 | + if ( $wgSlowGenderAliases || |
| 589 | + // Needs to be checked always to produce desired |
| 590 | + // effect when viewing user pages |
| 591 | + ($mytitle && $name === $mytitle->getBaseText()) ) { |
| 592 | + |
| 593 | + $user = User::newFromName( $name ); |
| 594 | + if ( $user ) $gender[$name] = $user->getOption( 'gender' ); |
| 595 | + } |
| 596 | + } |
| 597 | + |
| 598 | + return $wgContLang->getGenderNsText( $this->mNamespace, $gender[$name] ); |
| 599 | + } |
571 | 600 | return $wgContLang->getNsText( $this->mNamespace ); |
572 | 601 | } |
573 | 602 | /** |
— | — | @@ -581,16 +610,14 @@ |
582 | 611 | * @return \type{\string} Namespace text |
583 | 612 | */ |
584 | 613 | public function getSubjectNsText() { |
585 | | - global $wgContLang; |
586 | | - return $wgContLang->getNsText( MWNamespace::getSubject( $this->mNamespace ) ); |
| 614 | + return $this->getNsTextInternal( MWNamespace::getSubject( $this->mNamespace ) ); |
587 | 615 | } |
588 | 616 | /** |
589 | 617 | * Get the namespace text of the talk page |
590 | 618 | * @return \type{\string} Namespace text |
591 | 619 | */ |
592 | 620 | public function getTalkNsText() { |
593 | | - global $wgContLang; |
594 | | - return( $wgContLang->getNsText( MWNamespace::getTalk( $this->mNamespace ) ) ); |
| 621 | + return $this->getNsTextInternal( MWNamespace::getTalk( $this->mNamespace ) ); |
595 | 622 | } |
596 | 623 | /** |
597 | 624 | * Could this title have a corresponding talk page? |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2645,6 +2645,12 @@ |
2646 | 2646 | $wgNamespaceAliases = array(); |
2647 | 2647 | |
2648 | 2648 | /** |
| 2649 | + * Whether to check correct gender for all titles. If false, correct gender |
| 2650 | + * alias is only fetched for wgTitle. |
| 2651 | + */ |
| 2652 | +$wgSlowGenderAliases = true; |
| 2653 | + |
| 2654 | +/** |
2649 | 2655 | * Limit images on image description pages to a user-selectable limit. In order |
2650 | 2656 | * to reduce disk usage, limits can only be selected from a list. |
2651 | 2657 | * The user preference is saved as an array offset in the database, by default |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -99,6 +99,18 @@ |
100 | 100 | ); |
101 | 101 | |
102 | 102 | /** |
| 103 | + * Array of gender-based namespace aliases per namespace. Only NS_USER and |
| 104 | + * NS_USER_TALK works. |
| 105 | + * |
| 106 | + * Example: |
| 107 | + NS_USER => array( |
| 108 | + 'male' => 'Male_user', |
| 109 | + 'female' => 'Female_user', |
| 110 | + ), |
| 111 | + */ |
| 112 | +$genderAliases = array(); |
| 113 | + |
| 114 | +/** |
103 | 115 | * Array of namespace aliases, mapping from name to NS_xxx index |
104 | 116 | */ |
105 | 117 | $namespaceAliases = array(); |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | 'defaultUserOptionOverrides', 'linkTrail', 'namespaceAliases', |
65 | 65 | 'dateFormats', 'datePreferences', 'datePreferenceMigrationMap', |
66 | 66 | 'defaultDateFormat', 'extraUserToggles', 'specialPageAliases', |
67 | | - 'imageFiles' |
| 67 | + 'imageFiles', 'genderAliases' |
68 | 68 | ); |
69 | 69 | |
70 | 70 | static public $mMergeableMapKeys = array( 'messages', 'namespaceNames', 'mathNames', |
— | — | @@ -266,6 +266,18 @@ |
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
| 270 | + * Like getNsText, but looks first if there is custom alias for given gender |
| 271 | + */ |
| 272 | + function getGenderNsText( $index, $gender ) { |
| 273 | + $this->load(); |
| 274 | + if ( isset( $this->genderAliases[$index][$gender] ) ) { |
| 275 | + return $this->genderAliases[$index][$gender]; |
| 276 | + } else { |
| 277 | + return $this->getNsText( $index ); |
| 278 | + } |
| 279 | + } |
| 280 | + |
| 281 | + /** |
270 | 282 | * A convenience function that returns the same thing as |
271 | 283 | * getNsText() except with '_' changed to ' ', useful for |
272 | 284 | * producing output. |
— | — | @@ -2324,7 +2336,7 @@ |
2325 | 2337 | * |
2326 | 2338 | * @return array Dependencies, map of filenames to mtimes |
2327 | 2339 | */ |
2328 | | - static function loadLocalisation( $code, $disableCache = false ) { |
| 2340 | + static function loadLocalisation( $code, $disableCache = true ) { |
2329 | 2341 | static $recursionGuard = array(); |
2330 | 2342 | global $wgMemc, $wgEnableSerializedMessages, $wgCheckSerialized; |
2331 | 2343 | |
— | — | @@ -2592,6 +2604,12 @@ |
2593 | 2605 | foreach ( $this->namespaceNames as $index => $name ) { |
2594 | 2606 | $this->mNamespaceIds[$this->lc($name)] = $index; |
2595 | 2607 | } |
| 2608 | + # Add gender aliases to the normal aliases table automatically |
| 2609 | + foreach ( $this->genderAliases as $index => $aliases ) { |
| 2610 | + foreach ( $aliases as $alias ) { |
| 2611 | + $this->namespaceAliases[$alias] = $index; |
| 2612 | + } |
| 2613 | + } |
2596 | 2614 | if ( $this->namespaceAliases ) { |
2597 | 2615 | foreach ( $this->namespaceAliases as $name => $index ) { |
2598 | 2616 | if ( $index === NS_PROJECT_TALK ) { |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -96,6 +96,7 @@ |
97 | 97 | * Localize time zone regions in Special:Preferences |
98 | 98 | * Add NUMBEROFACTIVEUSERS magic word, which is like NUMBEROFUSERS, but uses |
99 | 99 | the active users data from site_stats. |
| 100 | +* (bug 13040) Gender-aware user namespace aliases |
100 | 101 | |
101 | 102 | === Bug fixes in 1.15 === |
102 | 103 | * (bug 16968) Special:Upload no longer throws useless warnings. |