r47052 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47051‎ | r47052 | r47053 >
Date:21:36, 9 February 2009
Author:minuteelectron
Status:deferred
Tags:
Comment:
* Babel: Remove internal gender support, replaced with regular MediaWiki gender support.
Modified paths:
  • /trunk/extensions/Babel/Babel.class.php (modified) (history)
  • /trunk/extensions/Babel/Babel.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Babel/Babel.class.php
@@ -9,24 +9,12 @@
1010 class Babel {
1111
1212 /**
13 - * Define the three posisble genders as constants.
14 - */
15 - const GENDER_FEMALE = 1;
16 - const GENDER_MALE = 2;
17 - const GENDER_NEUTER = 0;
18 -
19 - /**
2013 * Various values from the message cache.
2114 */
2215 private $_prefixes, $_suffixes, $_cellspacing, $_directionality, $_url,
2316 $_title, $_footer;
2417
2518 /**
26 - * Whether or not male, female or neuter messages should be prefered.
27 - */
28 - private $_gender = self::GENDER_NEUTER;
29 -
30 - /**
3119 * Array: Language codes.
3220 */
3321 private $_codes;
@@ -82,9 +70,6 @@
8371 // Parse the options and provide an array.
8472 $options = $this->_parseOptions( $parameters );
8573
86 - // Process gender stuff.
87 - $this->_setGender( $options );
88 -
8974 // Do a link batch on all the parameters so that their information is
9075 // cached for use later on.
9176 $this->_doTemplateLinkBatch( $parameters );
@@ -267,31 +252,6 @@
268253 }
269254
270255 /**
271 - * Identify what gender has been specified within the function.
272 - *
273 - * @param $options Array: Options.
274 - */
275 - private function _setGender( array $options ) {
276 -
277 - // Identify whether #female or #male have been specified as options and
278 - // set gender as appropriate.
279 - if( array_key_exists( 'female', $options ) ) {
280 -
281 - $this->_gender = self::GENDER_FEMALE;
282 -
283 - } elseif( array_key_exists( 'male', $options ) ) {
284 -
285 - $this->_gender = self::GENDER_MALE;
286 -
287 - } else {
288 -
289 - $this->_gender = self::GENDER_NEUTER;
290 -
291 - }
292 -
293 - }
294 -
295 - /**
296256 * Identify whether or not the template exists or not.
297257 *
298258 * @param $title String: Name of the template to check.
@@ -477,104 +437,36 @@
478438 */
479439 private function _getText( $name, $language, $level ) {
480440
481 - // If gender not neuter then try getting the gender specific message.
482 - if( $this->_gender === self::GENDER_FEMALE ) {
 441+ global $wgTitle;
483442
484 - // Try the language of the box in female.
485 - $text = wfMsgExt( "babel-$level-n-female",
486 - array( 'language' => $language ),
487 - ":Category:{$this->_addFixes( "$language-$level",'category' )}",
488 - ":Category:{$this->_addFixes( $language,'category' )}"
489 - );
490 -
491 - // Get the fallback message for comparison in female.
492 - $fallback = wfMsgExt( "babel-$level-n-female",
493 - array( 'language' => Language::getFallbackfor( $language ) ),
494 - ":Category:{$this->_addFixes( "$language-$level",'category' )}",
495 - ":Category:{$this->_addFixes( $language,'category' )}"
496 - );
497 -
498 - // Translation not found, use the generic translation of the
499 - // highest level fallback possible in female.
500 - if( $text == $fallback ) {
501 -
502 - $text = wfMsgExt( "babel-$level-female",
503 - array( 'language' => $language ),
504 - ":Category:{$this->_addFixes( "$language-$level",'category')}",
505 - ":Category:{$this->_addFixes( $language,'category' )}",
506 - $name
507 - );
508 -
509 - }
510 -
511 - // Not empty, return.
512 - if( $text != '' ) {
513 -
514 - return $text;
515 -
516 - }
517 -
518 - } elseif( $this->_gender === self::GENDER_MALE ) {
519 -
520 - // Try the language of the box in male.
521 - $text = wfMsgExt( "babel-$level-n-male",
522 - array( 'language' => $language ),
523 - ":Category:{$this->_addFixes( "$language-$level",'category' )}",
524 - ":Category:{$this->_addFixes( $language,'category' )}"
525 - );
526 -
527 - // Get the fallback message for comparison in male.
528 - $fallback = wfMsgExt( "babel-$level-n-male",
529 - array( 'language' => Language::getFallbackfor( $language ) ),
530 - ":Category:{$this->_addFixes( "$language-$level",'category' )}",
531 - ":Category:{$this->_addFixes( $language,'category' )}"
532 - );
533 -
534 - // Translation not found, use the generic translation of the
535 - // highest level fallback possible in male.
536 - if( $text == $fallback ) {
537 -
538 - $text = wfMsgExt( "babel-$level-male",
539 - array( 'language' => $language ),
540 - ":Category:{$this->_addFixes( "$language-$level",'category')}",
541 - ":Category:{$this->_addFixes( $language,'category' )}",
542 - $name
543 - );
544 -
545 - }
546 -
547 - // Not empty, return.
548 - if( $text != '' ) {
549 -
550 - return $text;
551 -
552 - }
553 -
554 - }
555 -
556 - // Try the language of the box.
 443+ // Try the language of the box in female.
557444 $text = wfMsgExt( "babel-$level-n",
558 - array( 'language' => $language ),
 445+ array( 'language' => $language, 'parsemag' ),
559446 ":Category:{$this->_addFixes( "$language-$level",'category' )}",
560 - ":Category:{$this->_addFixes( $language,'category' )}"
 447+ ":Category:{$this->_addFixes( $language,'category' )}",
 448+ '',
 449+ $wgTitle->getDBkey()
561450 );
562451
563 - // Get the fallback message for comparison.
 452+ // Get the fallback message for comparison in female.
564453 $fallback = wfMsgExt( "babel-$level-n",
565 - array( 'language' => Language::getFallbackfor( $language ) ),
 454+ array( 'language' => Language::getFallbackfor( $language ), 'parsemag' ),
566455 ":Category:{$this->_addFixes( "$language-$level",'category' )}",
567 - ":Category:{$this->_addFixes( $language,'category' )}"
 456+ ":Category:{$this->_addFixes( $language,'category' )}",
 457+ '',
 458+ $wgTitle->getDBkey()
568459 );
569460
570461 // Translation not found, use the generic translation of the
571 - // highest level fallback possible.
 462+ // highest level fallback possible in female.
572463 if( $text == $fallback ) {
573464
574465 $text = wfMsgExt( "babel-$level",
575 - array( 'language' => $language ),
 466+ array( 'language' => $language, 'parsemag' ),
576467 ":Category:{$this->_addFixes( "$language-$level",'category')}",
577468 ":Category:{$this->_addFixes( $language,'category' )}",
578 - $name
 469+ $name,
 470+ $wgTitle->getDBkey()
579471 );
580472
581473 }
Index: trunk/extensions/Babel/Babel.i18n.php
@@ -40,38 +40,6 @@
4141 'babel-5-n' => 'This user has [[$1|professional]] knowledge of [[$2|English]].',
4242 'babel-N-n' => 'This user has a [[$1|native]] understanding of [[$2|English]].',
4343
44 - 'babel-0-female' => '', # Optional.
45 - 'babel-1-female' => '', # Optional.
46 - 'babel-2-female' => '', # Optional.
47 - 'babel-3-female' => '', # Optional.
48 - 'babel-4-female' => '', # Optional.
49 - 'babel-5-female' => '', # Optional.
50 - 'babel-N-female' => '', # Optional.
51 -
52 - 'babel-0-n-female' => '', # Optional.
53 - 'babel-1-n-female' => '', # Optional.
54 - 'babel-2-n-female' => '', # Optional.
55 - 'babel-3-n-female' => '', # Optional.
56 - 'babel-4-n-female' => '', # Optional.
57 - 'babel-5-n-female' => '', # Optional.
58 - 'babel-N-n-female' => '', # Optional.
59 -
60 - 'babel-0-male' => '', # Optional.
61 - 'babel-1-male' => '', # Optional.
62 - 'babel-2-male' => '', # Optional.
63 - 'babel-3-male' => '', # Optional.
64 - 'babel-4-male' => '', # Optional.
65 - 'babel-5-male' => '', # Optional.
66 - 'babel-N-male' => '', # Optional.
67 -
68 - 'babel-0-n-male' => '', # Optional.
69 - 'babel-1-n-male' => '', # Optional.
70 - 'babel-2-n-male' => '', # Optional.
71 - 'babel-3-n-male' => '', # Optional.
72 - 'babel-4-n-male' => '', # Optional.
73 - 'babel-5-n-male' => '', # Optional.
74 - 'babel-N-n-male' => '', # Optional.
75 -
7644 'babel-box-cellspacing' => '0', # Do not translate or duplicate this message to other languages.
7745
7846 'babel-category-prefix' => '', # Do not translate or duplicate this message to other languages.

Status & tagging log