r102998 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102997‎ | r102998 | r102999 >
Date:18:20, 14 November 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/Babel/Babel.class.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Babel/BabelAutoCreate.class.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CategoryTree/CategoryTree.i18n.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CategoryTree/CategoryTreeFunctions.php (modified) (history)
  • /branches/wmf/1.18wmf1/languages/Language.php (modified) (history)
  • /branches/wmf/1.18wmf1/languages/Names.php (modified) (history)
  • /branches/wmf/1.18wmf1/tests/phpunit/languages/LanguageMlTest.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/Babel/Babel.class.php
@@ -280,20 +280,20 @@
281281 * @return String: Wikitext to add categories.
282282 */
283283 protected static function mGenerateCategories( $code, $level ) {
284 - global $wgBabelMainCategory, $wgBabelCategoryNames, $wgLanguageCode;
 284+ global $wgBabelMainCategory, $wgBabelCategoryNames;
285285
286286 $r = '';
287287
288288 if ( $wgBabelMainCategory !== false && $wgBabelCategoryNames[$level] !== false ) {
289289 $category = self::mReplaceCategoryVariables( $wgBabelMainCategory, $code );
290290 $r .= "[[Category:$category|$level]]";
291 - BabelAutoCreate::create( $category, BabelLanguageCodes::getName( $code, $wgLanguageCode ) );
 291+ BabelAutoCreate::create( $category, $code );
292292 }
293293
294294 if ( $wgBabelCategoryNames[$level] !== false ) {
295295 $category = self::mReplaceCategoryVariables( $wgBabelCategoryNames[$level], $code );
296296 $r .= "[[Category:$category]]";
297 - BabelAutoCreate::create( $category, BabelLanguageCodes::getName( $code, $wgLanguageCode ), $level );
 297+ BabelAutoCreate::create( $category, $code, $level );
298298 }
299299
300300 return $r;
Index: branches/wmf/1.18wmf1/extensions/Babel/BabelAutoCreate.class.php
@@ -23,19 +23,21 @@
2424 * Create category.
2525 *
2626 * @param $category String: Name of category to create.
27 - * @param $language String: Name of language that the category is for.
 27+ * @param $code String: Code of language that the category is for.
2828 * @param $level String: Level that the category is for.
2929 */
30 - public static function create( $category, $language, $level = null ) {
 30+ public static function create( $category, $code, $level = null ) {
3131 $category = strip_tags( $category );
3232 $title = Title::makeTitleSafe( NS_CATEGORY, $category );
3333 if ( $title === null || $title->exists() ) {
3434 return;
3535 }
 36+ global $wgLanguageCode;
 37+ $language = BabelLanguageCodes::getName( $code, $wgLanguageCode );
3638 if ( $level === null ) {
37 - $text = wfMsgForContent( 'babel-autocreate-text-main', $language );
 39+ $text = wfMsgForContent( 'babel-autocreate-text-main', $language, $code );
3840 } else {
39 - $text = wfMsgForContent( 'babel-autocreate-text-levels', $level, $language );
 41+ $text = wfMsgForContent( 'babel-autocreate-text-levels', $level, $language, $code );
4042 }
4143 $article = new Article( $title, 0 );
4244
Index: branches/wmf/1.18wmf1/extensions/CategoryTree/CategoryTree.i18n.php
@@ -38,7 +38,11 @@
3939 'categorytree-page-bullet' => ' ', # do not translate or duplicate this message to other languages
4040
4141 'categorytree-member-counts' => 'contains {{PLURAL:$1|1 subcategory|$1 subcategories}}, {{PLURAL:$2|1 page|$2 pages}}, and {{PLURAL:$3|1 file|$3 files}}', # $1=subcategories, $2=subpages, $3=files, $4=total, $5=shown-in-tree
42 - 'categorytree-member-num' => '($5)', # do not translate or duplicate this message to other languages
 42+ 'categorytree-member-num' => '($5)', # do not translate or duplicate this message to other languages
 43+ 'categorytree-num-categories' => '$1 C',
 44+ 'categorytree-num-pages' => '$1 P',
 45+ 'categorytree-num-files' => '$1 F',
 46+ 'categorytree-num-empty' => 'empty',
4347
4448 'categorytree-load' => 'load',
4549 'categorytree-loading' => 'loading…',
@@ -62,6 +66,7 @@
6367 * @author The Evil IP address
6468 * @author Александр Сигачёв
6569 * @author פוילישער
 70+ * @author Amire80
6671 */
6772 $messages['qqq'] = array(
6873 'categorytree' => 'Title of [[Special:CategoryTree]]',
@@ -90,6 +95,11 @@
9196 * $4 = total number of members,
9297 * $5 = members to be shown in the tree, depending on mode.
9398 Use with { {PLURAL} }',
 99+ 'categorytree-member-num' => 'Do not translate or duplicate this message to other languages. It can be customized locally on a wiki.',
 100+ 'categorytree-num-categories' => 'Number of sub-categories in a category. The word "categories" should be abbreviated. Appears in brackets after a name of an empty category. This message supports PLURAL.',
 101+ 'categorytree-num-pages' => 'Number of pages in a category. The word "pages" should be abbreviated. Appears in brackets after a name of an empty category. This message supports PLURAL.',
 102+ 'categorytree-num-files' => 'Number of sub-categories in a category. The word "files" should be abbreviated. Appears in brackets after a name of an empty category. This message supports PLURAL.',
 103+ 'categorytree-num-empty' => 'The word "empty", as in "empty category". Appears in brackets after a name of an empty category.',
94104 'categorytree-load' => '{{Identical|Load}}
95105
96106 Tooltip for the "expend" button, if the content was not yet loaded',
@@ -1598,6 +1608,10 @@
15991609 'categorytree-collapse' => 'כיווץ',
16001610 'categorytree-expand' => 'הרחבה',
16011611 'categorytree-member-counts' => 'כוללת {{PLURAL:$1|קטגוריית משנה אחת|$1 קטגוריות משנה}}, {{PLURAL:$2|דף אחד|$2 דפים}}, ו{{PLURAL:$3|קובץ אחד|־$3 קבצים}}',
 1612+ 'categorytree-num-categories' => '{{PLURAL:$1|קט אחת|$1 קט}}',
 1613+ 'categorytree-num-pages' => '{{PLURAL:$1|דף אחד|$1 דפים}}',
 1614+ 'categorytree-num-files' => '{{PLURAL:$1|קובץ אחד|$1 קב}}',
 1615+ 'categorytree-num-empty' => 'ריקה',
16021616 'categorytree-load' => 'טעינה',
16031617 'categorytree-loading' => 'בטעינה',
16041618 'categorytree-nothing-found' => 'לא נמצאו תוצאות',
Index: branches/wmf/1.18wmf1/extensions/CategoryTree/CategoryTreeFunctions.php
@@ -698,12 +698,31 @@
699699 if ( $count !== false && $this->getOption( 'showcount' ) ) {
700700 $pages = $pageCount - $subcatCount - $fileCount;
701701
 702+ global $wgContLang, $wgLang;
702703 $attr = array(
703 - 'title' => wfMsgExt( 'categorytree-member-counts', 'parsemag', $subcatCount, $pages , $fileCount, $pageCount, $count )
 704+ 'title' => wfMsgExt( 'categorytree-member-counts', 'parsemag', $subcatCount, $pages , $fileCount, $pageCount, $count ),
 705+ 'dir' => $wgLang->getDir() # numbers and commas get messed up in a mixed dir env
704706 );
705707
706 - global $wgContLang, $wgLang;
707708 $s .= $wgContLang->getDirMark() . ' ';
 709+
 710+ # Create a list of category members with only non-zero member counts
 711+ $memberNums = array();
 712+ if ( $subcatCount ) {
 713+ $memberNums[] = wfMessage( 'categorytree-num-categories', $wgLang->formatNum( $subcatCount ) )->text();
 714+ }
 715+ if ( $pageCount ) {
 716+ $memberNums[] = wfMessage( 'categorytree-num-pages', $wgLang->formatNum( $pageCount ) )->text();
 717+ }
 718+ if ( $fileCount ) {
 719+ $memberNums[] = wfMessage( 'categorytree-num-files', $wgLang->formatNum( $fileCount ) )->text();
 720+ }
 721+ $memberNumsShort = $memberNums
 722+ ? $wgLang->commaList( $memberNums )
 723+ : wfMessage( 'categorytree-num-empty' )->text();
 724+
 725+ # Only $5 is actually used in the default message.
 726+ # Other arguments can be used in a customized message.
708727 $s .= Xml::tags( 'span', $attr,
709728 wfMsgExt( 'categorytree-member-num',
710729 array( 'parsemag', 'escapenoentities' ),
@@ -711,7 +730,7 @@
712731 $pages,
713732 $fileCount,
714733 $pageCount,
715 - $wgLang->formatNum( $count ) ) );
 734+ $memberNumsShort ) );
716735 }
717736
718737 $s .= Xml::closeElement( 'div' );
Property changes on: branches/wmf/1.18wmf1/extensions/CategoryTree/CategoryTreeFunctions.php
___________________________________________________________________
Modified: svn:mergeinfo
719738 Merged /trunk/extensions/CategoryTree/CategoryTreeFunctions.php:r98140,100023,102786
720739 Merged /trunk/phase3/extensions/CategoryTree/CategoryTreeFunctions.php:r102802,102893
Index: branches/wmf/1.18wmf1/tests/phpunit/languages/LanguageMlTest.php
@@ -26,5 +26,7 @@
2727 $this->assertEquals( '12,345.56', $this->lang->formatNum( '12345.56' ) );
2828 $this->assertEquals( '12,34,56,79,81,23,45,678', $this->lang->formatNum( '12345679812345678' ) );
2929 $this->assertEquals( '.12345', $this->lang->formatNum( '.12345' ) );
 30+ $this->assertEquals( '-12,00,000', $this->lang->formatNum( '-1200000' ) );
 31+ $this->assertEquals( '-98', $this->lang->formatNum( '-98' ) );
3032 }
3133 }
Index: branches/wmf/1.18wmf1/languages/Language.php
@@ -2573,15 +2573,21 @@
25742574 }
25752575 else {
25762576 // Ref: http://cldr.unicode.org/translation/number-patterns
 2577+ $sign = "";
 2578+ if ( intval( $_ ) < 0 ) {
 2579+ // For negative numbers apply the algorithm like positive number and add sign.
 2580+ $sign = $_[0];
 2581+ $_ = substr( $_,1 );
 2582+ }
25772583 $numberpart = array();
25782584 $decimalpart = array();
25792585 $numMatches = preg_match_all( "/(#+)/", $digitGroupingPattern, $matches );
25802586 preg_match( "/\d+/", $_, $numberpart );
25812587 preg_match( "/\.\d*/", $_, $decimalpart );
25822588 $groupedNumber = ( count( $decimalpart ) > 0 ) ? $decimalpart[0]:"";
2583 - if ( $groupedNumber === $_){
2584 - //the string does not have any number part. Eg: .12345
2585 - return $groupedNumber;
 2589+ if ( $groupedNumber === $_ ) {
 2590+ // the string does not have any number part. Eg: .12345
 2591+ return $sign . $groupedNumber;
25862592 }
25872593 $start = $end = strlen( $numberpart[0] );
25882594 while ( $start > 0 )
@@ -2602,7 +2608,7 @@
26032609 $groupedNumber = "," . $groupedNumber;
26042610 }
26052611 }
2606 - return $groupedNumber;
 2612+ return $sign . $groupedNumber;
26072613 }
26082614 }
26092615 /**
Property changes on: branches/wmf/1.18wmf1/languages/Language.php
___________________________________________________________________
Modified: svn:mergeinfo
26102616 Merged /trunk/phase3/languages/Language.php:r102802
Index: branches/wmf/1.18wmf1/languages/Names.php
@@ -289,7 +289,7 @@
290290 # 'ruq-grek' => 'Βλαεστε', # Megleno-Romanian (Greek script)
291291 'ruq-latn' => 'Vlăheşte', # Megleno-Romanian (Latin script)
292292 'rw' => 'Kinyarwanda', # Kinyarwanda, should possibly be Kinyarwandi
293 - 'sa' => 'संस्कृत', # Sanskrit
 293+ 'sa' => 'संस्कृतम्', # Sanskrit
294294 'sah' => 'Саха тыла', # Sakha
295295 'sc' => 'Sardu', # Sardinian
296296 'scn' => 'Sicilianu', # Sicilian

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98140Possibility to use the language code as parameter on categories.robin15:36, 26 September 2011
r100023Bug 29357: CategoryTree should have built-in localizable support for pretty C...amire8011:35, 17 October 2011
r102786Followup r98140 - fix docsnikerabbit14:40, 11 November 2011
r102802Make commafy support negative numbers too,...santhosh17:23, 11 November 2011
r102893Correct the name of Sanskrit. Follow-up 102889.santhosh12:50, 13 November 2011

Status & tagging log