r13936 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13935‎ | r13936 | r13937 >
Date:20:07, 29 April 2006
Author:nikerabbit
Status:old
Tags:
Comment:
* Cleaned up formatNum usage in langfiles
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/LanguageAf.php (modified) (history)
  • /trunk/phase3/languages/LanguageAr.php (modified) (history)
  • /trunk/phase3/languages/LanguageAs.php (modified) (history)
  • /trunk/phase3/languages/LanguageAz.php (modified) (history)
  • /trunk/phase3/languages/LanguageBe.php (modified) (history)
  • /trunk/phase3/languages/LanguageBg.php (modified) (history)
  • /trunk/phase3/languages/LanguageBn.php (modified) (history)
  • /trunk/phase3/languages/LanguageBo.php (modified) (history)
  • /trunk/phase3/languages/LanguageBr.php (modified) (history)
  • /trunk/phase3/languages/LanguageBs.php (modified) (history)
  • /trunk/phase3/languages/LanguageCa.php (modified) (history)
  • /trunk/phase3/languages/LanguageCs.php (modified) (history)
  • /trunk/phase3/languages/LanguageDa.php (modified) (history)
  • /trunk/phase3/languages/LanguageDe.php (modified) (history)
  • /trunk/phase3/languages/LanguageDz.php (modified) (history)
  • /trunk/phase3/languages/LanguageEl.php (modified) (history)
  • /trunk/phase3/languages/LanguageEo.php (modified) (history)
  • /trunk/phase3/languages/LanguageEs.php (modified) (history)
  • /trunk/phase3/languages/LanguageEt.php (modified) (history)
  • /trunk/phase3/languages/LanguageFa.php (modified) (history)
  • /trunk/phase3/languages/LanguageFi.php (modified) (history)
  • /trunk/phase3/languages/LanguageFr.php (modified) (history)
  • /trunk/phase3/languages/LanguageFur.php (modified) (history)
  • /trunk/phase3/languages/LanguageFy.php (modified) (history)
  • /trunk/phase3/languages/LanguageGu.php (modified) (history)
  • /trunk/phase3/languages/LanguageHi.php (modified) (history)
  • /trunk/phase3/languages/LanguageHr.php (modified) (history)
  • /trunk/phase3/languages/LanguageHu.php (modified) (history)
  • /trunk/phase3/languages/LanguageId.php (modified) (history)
  • /trunk/phase3/languages/LanguageIs.php (modified) (history)
  • /trunk/phase3/languages/LanguageIt.php (modified) (history)
  • /trunk/phase3/languages/LanguageKm.php (modified) (history)
  • /trunk/phase3/languages/LanguageKn.php (modified) (history)
  • /trunk/phase3/languages/LanguageLo.php (modified) (history)
  • /trunk/phase3/languages/LanguageLt.php (modified) (history)
  • /trunk/phase3/languages/LanguageMl.php (modified) (history)
  • /trunk/phase3/languages/LanguageNds.php (modified) (history)
  • /trunk/phase3/languages/LanguageNl.php (modified) (history)
  • /trunk/phase3/languages/LanguageNn.php (modified) (history)
  • /trunk/phase3/languages/LanguageNo.php (modified) (history)
  • /trunk/phase3/languages/LanguageOr.php (modified) (history)
  • /trunk/phase3/languages/LanguageOs.php (modified) (history)
  • /trunk/phase3/languages/LanguagePa.php (modified) (history)
  • /trunk/phase3/languages/LanguagePl.php (modified) (history)
  • /trunk/phase3/languages/LanguagePt.php (modified) (history)
  • /trunk/phase3/languages/LanguageRu.php (modified) (history)
  • /trunk/phase3/languages/LanguageSk.php (modified) (history)
  • /trunk/phase3/languages/LanguageSl.php (modified) (history)
  • /trunk/phase3/languages/LanguageSq.php (modified) (history)
  • /trunk/phase3/languages/LanguageSr_ec.php (modified) (history)
  • /trunk/phase3/languages/LanguageSr_el.php (modified) (history)
  • /trunk/phase3/languages/LanguageSv.php (modified) (history)
  • /trunk/phase3/languages/LanguageTe.php (modified) (history)
  • /trunk/phase3/languages/LanguageTr.php (modified) (history)
  • /trunk/phase3/languages/LanguageUdm.php (modified) (history)
  • /trunk/phase3/languages/LanguageUk.php (modified) (history)
  • /trunk/phase3/languages/LanguageVi.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES
@@ -144,6 +144,7 @@
145145 * (bug 5761) Project talk namespace broken in Xal, Os, Udm and Cv
146146 * Rewrite reassignEdits script to be more efficient; support optional updates to
147147 recent changes table; add reporting and silent modes
 148+* Cleaned up formatNum usage in langfiles
148149
149150 == Compatibility ==
150151
Index: trunk/phase3/languages/LanguageEl.php
@@ -73,9 +73,10 @@
7474 return 'iso-8859-7';
7575 }
7676
77 - function formatNum( $number, $year = false ) {
78 - return $year ? $number : strtr($this->commafy( $number ), '.,', ',.' );
 77+ function separatorTransformTable() {
 78+ return array(',' => '.', '.' => ',' );
7979 }
 80+
8081 }
8182
8283 ?>
Index: trunk/phase3/languages/LanguageAs.php
@@ -8,27 +8,20 @@
99 require_once( 'LanguageUtf8.php' );
1010
1111 class LanguageAs extends LanguageUtf8 {
12 - var $digitTransTable = array(
13 - '0' => '০',
14 - '1' => '১',
15 - '2' => '২',
16 - '3' => '৩',
17 - '4' => '৪',
18 - '5' => '৫',
19 - '6' => '৬',
20 - '7' => '৭',
21 - '8' => '৮',
22 - '9' => '৯'
23 - );
24 -
25 - function formatNum( $number ) {
26 - global $wgTranslateNumerals;
27 - if( $wgTranslateNumerals ) {
28 - return strtr( $number, $this->digitTransTable );
29 - } else {
30 - return $number;
31 - }
 12+ function digitTransformTable() {
 13+ return array(
 14+ '0' => '০',
 15+ '1' => '১',
 16+ '2' => '২',
 17+ '3' => '৩',
 18+ '4' => '৪',
 19+ '5' => '৫',
 20+ '6' => '৬',
 21+ '7' => '৭',
 22+ '8' => '৮',
 23+ '9' => '৯'
 24+ );
3225 }
33 -}
3426
 27+}
3528 ?>
Index: trunk/phase3/languages/LanguageSr_el.php
@@ -162,8 +162,8 @@
163163 return $wgMagicWordsSr_el;
164164 }
165165
166 - function formatNum( $number, $year = false ) {
167 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 166+ function separatorTransformTable() {
 167+ return array(',' => '.', '.' => ',' );
168168 }
169169
170170 /**
@@ -278,5 +278,4 @@
279279 }
280280
281281 }
282 -
283282 ?>
Index: trunk/phase3/languages/LanguageEt.php
@@ -151,8 +151,8 @@
152152 * Estonian numeric formatting is 123 456,78.
153153 * Notice that the space is non-breaking.
154154 */
155 - function formatNum( $number, $year = false ) {
156 - return $year ? $number : strtr($this->commafy($number), '.,', ", " );
 155+ function separatorTransformTable() {
 156+ return array(',' => "\xc2\xa0", '.' => ',' );
157157 }
158158
159159 /**
Index: trunk/phase3/languages/LanguageMl.php
@@ -10,27 +10,21 @@
1111 require_once( 'LanguageUtf8.php' );
1212
1313 class LanguageMl extends LanguageUtf8 {
14 - var $digitTransTable = array(
15 - '0' => '൦',
16 - '1' => '൧',
17 - '2' => '൨',
18 - '3' => '൩',
19 - '4' => '൪',
20 - '5' => '൫',
21 - '6' => '൬',
22 - '7' => '൭',
23 - '8' => '൮',
24 - '9' => '൯'
25 - );
26 -
27 - function formatNum( $number ) {
28 - global $wgTranslateNumerals;
29 - if( $wgTranslateNumerals ) {
30 - return strtr( $number, $this->digitTransTable );
31 - } else {
32 - return $number;
33 - }
 14+ function digitTransformTable() {
 15+ return array(
 16+ '0' => '൦',
 17+ '1' => '൧',
 18+ '2' => '൨',
 19+ '3' => '൩',
 20+ '4' => '൪',
 21+ '5' => '൫',
 22+ '6' => '൬',
 23+ '7' => '൭',
 24+ '8' => '൮',
 25+ '9' => '൯'
 26+ );
3427 }
 28+
3529 }
3630
3731 ?>
Index: trunk/phase3/languages/LanguageIs.php
@@ -158,8 +158,8 @@
159159 * The Icelandic number style uses dots where English would use commas
160160 * and commas where English would use dots, e.g. 201.511,17 not 201,511.17
161161 */
162 - function formatNum( $number, $year = false ) {
163 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 162+ function separatorTransformTable() {
 163+ return array(',' => '.', '.' => ',' );
164164 }
165165
166166 function linkPrefixExtension() {
Index: trunk/phase3/languages/LanguageNds.php
@@ -134,9 +134,9 @@
135135 }
136136 }
137137
138 - function formatNum( $number, $year = false ) {
139 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 138+ function separatorTransformTable() {
 139+ return array(',' => '.', '.' => ',' );
140140 }
 141+
141142 }
142 -
143143 ?>
Index: trunk/phase3/languages/LanguageFa.php
@@ -55,21 +55,23 @@
5656 #--------------------------------------------------------------------------
5757
5858 class LanguageFa extends LanguageUtf8 {
59 - var $digitTransTable = array(
60 - "0" => "۰",
61 - "1" => "۱",
62 - "2" => "۲",
63 - "3" => "۳",
64 - "4" => "۴",
65 - "5" => "۵",
66 - "6" => "۶",
67 - "7" => "۷",
68 - "8" => "۸",
69 - "9" => "۹",
70 - "%" => "٪",
71 - "." => "٫",
72 - "," => "٬"
73 - );
 59+ function digitTransformTable() {
 60+ return array(
 61+ "0" => "۰",
 62+ "1" => "۱",
 63+ "2" => "۲",
 64+ "3" => "۳",
 65+ "4" => "۴",
 66+ "5" => "۵",
 67+ "6" => "۶",
 68+ "7" => "۷",
 69+ "8" => "۸",
 70+ "9" => "۹",
 71+ "%" => "٪",
 72+ "." => "٫", // wrong table?
 73+ "," => "٬"
 74+ );
 75+ }
7476
7577 function getDefaultUserOptions() {
7678 $opt = Language::getDefaultUserOptions();
@@ -104,15 +106,6 @@
105107 # For right-to-left language support
106108 function isRTL() { return true; }
107109
108 - function formatNum( $number ) {
109 - global $wgTranslateNumerals;
110 - if( $wgTranslateNumerals ) {
111 - return strtr( $number, $this->digitTransTable );
112 - } else {
113 - return $number;
114 - }
115 - }
116 -
117110 function timeanddate( $ts, $adj = false ) {
118111 return $this->formatNum( Language::timeanddate( $ts, $adj ) );
119112 }
Index: trunk/phase3/languages/LanguageFi.php
@@ -175,10 +175,9 @@
176176
177177 /**
178178 * Finnish numeric formatting is 123 456,78.
179 - * Notice that the space is non-breaking.
180179 */
181 - function formatNum( $number, $year = false ) {
182 - return $year ? $number : strtr($this->commafy($number), '.,', ", " );
 180+ function separatorTransformTable() {
 181+ return array(',' => "\xc2\xa0", '.' => ',' );
183182 }
184183
185184 /**
Index: trunk/phase3/languages/LanguageBn.php
@@ -47,31 +47,25 @@
4848 return $wgDateFormatsBn;
4949 }
5050
51 - var $digitTransTable = array(
52 - '0' => '০',
53 - '1' => '১',
54 - '2' => '২',
55 - '3' => '৩',
56 - '4' => '৪',
57 - '5' => '৫',
58 - '6' => '৬',
59 - '7' => '৭',
60 - '8' => '৮',
61 - '9' => '৯'
62 - );
63 -
64 - function formatNum( $number ) {
65 - global $wgTranslateNumerals;
66 - if( $wgTranslateNumerals ) {
67 - return strtr( $number, $this->digitTransTable );
68 - } else {
69 - return $number;
70 - }
 51+ function digitTransformTable() {
 52+ return array(
 53+ '0' => '০',
 54+ '1' => '১',
 55+ '2' => '২',
 56+ '3' => '৩',
 57+ '4' => '৪',
 58+ '5' => '৫',
 59+ '6' => '৬',
 60+ '7' => '৭',
 61+ '8' => '৮',
 62+ '9' => '৯'
 63+ );
7164 }
7265
7366 function timeanddate( $ts, $adj = false ) {
7467 return $this->formatNum( Language::timeanddate( $ts, $adj ) );
7568 }
 69+
7670 }
7771
7872 ?>
Index: trunk/phase3/languages/LanguageBr.php
@@ -108,13 +108,8 @@
109109 return $this->date( $ts, $adj ) . " da " . $this->time( $ts, $adj );
110110 }
111111
112 - var $digitTransTable = array(
113 - ',' => "\xc2\xa0", // @bug 2749
114 - '.' => ','
115 - );
116 -
117 - function formatNum( $number, $year = false ) {
118 - return $year ? $number : strtr($this->commafy($number), $this->digitTransTable );
 112+ function separatorTransformTable() {
 113+ return array(',' => "\xc2\xa0", '.' => ',' );
119114 }
120115
121116 function getMessage( $key ) {
Index: trunk/phase3/languages/LanguageNo.php
@@ -92,8 +92,8 @@
9393 }
9494 }
9595
96 - function formatNum( $number, $year = false ) {
97 - return !$year ? strtr($number, '.,', ',.' ) : $number;
 96+ function separatorTransformTable() {
 97+ return array(',' => '.', '.' => ',' );
9898 }
9999
100100 function getMessage( $key ) {
Index: trunk/phase3/languages/LanguageFy.php
@@ -87,14 +87,8 @@
8888 return $wgSkinNamesFy;
8989 }
9090
91 -
92 - var $digitTransTable = array(
93 - ',' => '.',
94 - '.' => ','
95 - );
96 -
97 - function formatNum( $number, $year = false ) {
98 - return !$year ? strtr($this->commafy($number), $this->digitTransTable ) : $number;
 91+ function separatorTransformTable() {
 92+ return array(',' => '.', '.' => ',' );
9993 }
10094
10195 function getDateFormats() {
Index: trunk/phase3/languages/LanguageVi.php
@@ -178,16 +178,10 @@
179179 }
180180 }
181181
182 - var $digitTransTable = array(
183 - ',' => '.',
184 - '.' => ','
185 - );
186 -
187 - function formatNum( $number, $year = false ) {
188 - return !$year ? strtr($this->commafy($number), $this->digitTransTable ) : $number;
 182+ function separatorTransformTable() {
 183+ return array(',' => '.', '.' => ',' );
189184 }
190185
191 -
192186 function getDateFormats() {
193187 global $wgDateFormatsVi;
194188 return $wgDateFormatsVi;
Index: trunk/phase3/languages/LanguageCa.php
@@ -77,8 +77,8 @@
7878 }
7979 }
8080
81 - function formatNum( $number, $year = false ) {
82 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 81+ function separatorTransformTable() {
 82+ return array(',' => '.', '.' => ',' );
8383 }
8484
8585 }
Index: trunk/phase3/languages/LanguageFur.php
@@ -77,16 +77,10 @@
7878 return $this->date( $ts, $adj ) . " a lis " . $this->time( $ts, $adj );
7979 }
8080
81 - var $digitTransTable = array(
82 - ',' => "\xc2\xa0", // @bug 2749
83 - '.' => ','
84 - );
85 -
86 - function formatNum( $number, $year = false ) {
87 - return $year? $number : strtr($this->commafy($number), $this->digitTransTable);
 81+ function separatorTransformTable() {
 82+ return array(',' => "\xc2\xa0", '.' => ',' );
8883 }
8984
90 -
9185 function getMessage( $key ) {
9286 global $wgAllMessagesFur;
9387 if( isset( $wgAllMessagesFur[$key] ) ) {
Index: trunk/phase3/languages/LanguageCs.php
@@ -186,13 +186,8 @@
187187 return $s;
188188 }
189189
190 - var $digitTransTable = array(
191 - ',' => "\xc2\xa0", // @bug 2749
192 - '.' => ','
193 - );
194 -
195 - function formatNum( $number, $year = false ) {
196 - return $year ? $number : strtr($this->commafy($number), $this->digitTransTable);
 190+ function separatorTransformTable() {
 191+ return array(',' => "\xc2\xa0", '.' => ',' );
197192 }
198193
199194 # Grammatical transformations, needed for inflected languages
Index: trunk/phase3/languages/LanguageKm.php
@@ -10,27 +10,21 @@
1111 require_once( 'LanguageUtf8.php' );
1212
1313 class LanguageKm extends LanguageUtf8 {
14 - var $digitTransTable = array(
15 - '0' => '០',
16 - '1' => '១',
17 - '2' => '២',
18 - '3' => '៣',
19 - '4' => '៤',
20 - '5' => '៥',
21 - '6' => '៦',
22 - '7' => '៧',
23 - '8' => '៨',
24 - '9' => '៩'
25 - );
26 -
27 - function formatNum( $number ) {
28 - global $wgTranslateNumerals;
29 - if( $wgTranslateNumerals ) {
30 - return strtr( $number, $this->digitTransTable );
31 - } else {
32 - return $number;
33 - }
 14+ function digitTransformTable() {
 15+ return array(
 16+ '0' => '០',
 17+ '1' => '១',
 18+ '2' => '២',
 19+ '3' => '៣',
 20+ '4' => '៤',
 21+ '5' => '៥',
 22+ '6' => '៦',
 23+ '7' => '៧',
 24+ '8' => '៨',
 25+ '9' => '៩'
 26+ );
3427 }
 28+
3529 }
3630
3731 ?>
Index: trunk/phase3/languages/LanguageSk.php
@@ -167,13 +167,11 @@
168168 return parent::getMessage( $key );
169169 }
170170
171 - var $digitTransTable = array(
172 - ',' => "\xc2\xa0",
173 - '.' => ','
174 - );
175 -
176 - function formatNum( $number, $year = false ) {
177 - return $year ? $number : strtr($this->commafy($number), $this->digitTransTable );
 171+ function separatorTransformTable() {
 172+ return array(
 173+ ',' => "\xc2\xa0",
 174+ '.' => ','
 175+ );
178176 }
179177
180178 # Convert from the nominative form of a noun to some other case
Index: trunk/phase3/languages/LanguageOr.php
@@ -10,27 +10,21 @@
1111 require_once( 'LanguageUtf8.php' );
1212
1313 class LanguageOr extends LanguageUtf8 {
14 - var $digitTransTable = array(
15 - '0' => '୦',
16 - '1' => '୧',
17 - '2' => '୨',
18 - '3' => '୩',
19 - '4' => '୪',
20 - '5' => '୫',
21 - '6' => '୬',
22 - '7' => '୭',
23 - '8' => '୮',
24 - '9' => '୯',
25 - );
2614
27 - function formatNum( $number ) {
28 - global $wgTranslateNumerals;
29 - if( $wgTranslateNumerals ) {
30 - return strtr( $number, $this->digitTransTable );
31 - } else {
32 - return $number;
33 - }
 15+ function digitTransformTable() {
 16+ return array(
 17+ '0' => '୦',
 18+ '1' => '୧',
 19+ '2' => '୨',
 20+ '3' => '୩',
 21+ '4' => '୪',
 22+ '5' => '୫',
 23+ '6' => '୬',
 24+ '7' => '୭',
 25+ '8' => '୮',
 26+ '9' => '୯',
 27+ );
3428 }
35 -}
3629
 30+}
3731 ?>
Index: trunk/phase3/languages/LanguageSq.php
@@ -106,11 +106,9 @@
107107 return parent::getMessage($key);
108108 }
109109
110 - function formatNum( $number ) {
111 - global $wgTranslateNumerals;
112 - return $wgTranslateNumerals ? strtr($number, '.,', ',.' ) : $number;
 110+ function separatorTransformTable() {
 111+ return array(',' => '.', '.' => ',' );
113112 }
114113
115114 }
116 -
117115 ?>
Index: trunk/phase3/languages/LanguageUdm.php
@@ -69,8 +69,8 @@
7070 return "windows-1251";
7171 }
7272
73 - function formatNum( $number, $year = false ) {
74 - return !$year ? strtr($number, '.,', ', ' ) : $number;
 73+ function separatorTransformTable() {
 74+ return array(',' => ' ', '.' => ',' );
7575 }
7676
7777 }
Index: trunk/phase3/languages/LanguageHi.php
@@ -31,18 +31,20 @@
3232
3333
3434 class LanguageHi extends LanguageUtf8 {
35 - var $digitTransTable = array(
36 - "0" => "०",
37 - "1" => "१",
38 - "2" => "२",
39 - "3" => "३",
40 - "4" => "४",
41 - "5" => "५",
42 - "6" => "६",
43 - "7" => "७",
44 - "8" => "८",
45 - "9" => "९"
46 - );
 35+ function digitTransformTable() {
 36+ return array(
 37+ "0" => "०",
 38+ "1" => "१",
 39+ "2" => "२",
 40+ "3" => "३",
 41+ "4" => "४",
 42+ "5" => "५",
 43+ "6" => "६",
 44+ "7" => "७",
 45+ "8" => "८",
 46+ "9" => "९"
 47+ );
 48+ }
4749
4850 function getNamespaces() {
4951 global $wgNamespaceNamesHi;
@@ -57,14 +59,6 @@
5860 return parent::getMessage($key);
5961 }
6062
61 - function formatNum( $number ) {
62 - global $wgTranslateNumerals;
63 - if( $wgTranslateNumerals ) {
64 - return strtr( $number, $this->digitTransTable );
65 - } else {
66 - return $number;
67 - }
68 - }
6963 function timeanddate( $ts, $adj = false ) {
7064 return $this->formatNum( Language::timeanddate( $ts, $adj ) );
7165 }
Index: trunk/phase3/languages/LanguagePa.php
@@ -73,26 +73,20 @@
7474 }
7575 }
7676
77 - var $digitTransTable = array(
78 - '0' => '੦',
79 - '1' => '੧',
80 - '2' => '੨',
81 - '3' => '੩',
82 - '4' => '੪',
83 - '5' => '੫',
84 - '6' => '੬',
85 - '7' => '੭',
86 - '8' => '੮',
87 - '9' => '੯'
88 - );
89 -
90 - function formatNum( $number ) {
91 - global $wgTranslateNumerals;
92 - if( $wgTranslateNumerals ) {
93 - return strtr( $number, $this->digitTransTable );
94 - } else {
95 - return $number;
96 - }
 77+ function digitTransformTable() {
 78+ return array(
 79+ '0' => '੦',
 80+ '1' => '੧',
 81+ '2' => '੨',
 82+ '3' => '੩',
 83+ '4' => '੪',
 84+ '5' => '੫',
 85+ '6' => '੬',
 86+ '7' => '੭',
 87+ '8' => '੮',
 88+ '9' => '੯'
 89+ );
9790 }
 91+
9892 }
9993 ?>
Index: trunk/phase3/languages/LanguageHu.php
@@ -123,8 +123,8 @@
124124 return $this->date( $ts, $adj ) . ", " . $this->time( $ts, $adj );
125125 }
126126
127 - function formatNum( $number, $year = false ) {
128 - return !$year ? strtr($this->commafy($number), array( '.' => ',', ',' => "\xc2\xa0" )) : $number;
 127+ function separatorTransformTable() {
 128+ return array(',' => "\xc2\xa0", '.' => ',' );
129129 }
130130
131131 }
Index: trunk/phase3/languages/LanguageDz.php
@@ -10,27 +10,21 @@
1111 require_once( 'LanguageUtf8.php' );
1212
1313 class LanguageDz extends LanguageUtf8 {
14 - var $digitTransTable = array(
15 - '0' => '༠',
16 - '1' => '༡',
17 - '2' => '༢',
18 - '3' => '༣',
19 - '4' => '༤',
20 - '5' => '༥',
21 - '6' => '༦',
22 - '7' => '༧',
23 - '8' => '༨',
24 - '9' => '༩'
25 - );
26 -
27 - function formatNum( $number ) {
28 - global $wgTranslateNumerals;
29 - if( $wgTranslateNumerals ) {
30 - return strtr( $number, $this->digitTransTable );
31 - } else {
32 - return $number;
33 - }
 14+ function digitTransformTable() {
 15+ return array(
 16+ '0' => '༠',
 17+ '1' => '༡',
 18+ '2' => '༢',
 19+ '3' => '༣',
 20+ '4' => '༤',
 21+ '5' => '༥',
 22+ '6' => '༦',
 23+ '7' => '༧',
 24+ '8' => '༨',
 25+ '9' => '༩'
 26+ );
3427 }
 28+
3529 }
3630
3731 ?>
Index: trunk/phase3/languages/LanguageLt.php
@@ -81,8 +81,8 @@
8282 return $wgAllMessagesLt;
8383 }
8484
85 - function formatNum( $number, $year = false ) {
86 - return $year ? $number : strtr($this->commafy($number), '.,', ', ' );
 85+ function separatorTransformTable() {
 86+ return array(',' => ' ', '.' => ',' );
8787 }
8888
8989 }
Index: trunk/phase3/languages/LanguageTr.php
@@ -44,10 +44,6 @@
4545 return $wgNamespaceNamesTr;
4646 }
4747
48 - function formatNum( $number, $year = false ) {
49 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
50 - }
51 -
5248 function ucfirst ( $string ) {
5349 if ( $string[0] == 'i' ) {
5450 return 'İ' . substr( $string, 1 );
@@ -70,7 +66,9 @@
7167 return $wgDateFormatsTr;
7268 }
7369
74 -}
 70+ function separatorTransformTable() {
 71+ return array(',' => '.', '.' => ',' );
 72+ }
7573
76 -
77 -?>
 74+}
 75+?>
\ No newline at end of file
Index: trunk/phase3/languages/LanguageAf.php
@@ -69,18 +69,11 @@
7070 }
7171 }
7272
73 - function formatNum( $number, $year = false ) {
74 - # South Africa uses space for thousands and comma for decimal
75 - # Reference: AWS Reël 7.4 p. 52, 2002 edition
76 - # glibc is wrong in this respect in some versions
77 - if ( $year ) {
78 - return $number;
79 - } else {
80 - return strtr($this->commafy($number), array(
81 - '.' => ',',
82 - ',' => "\xc2\xa0" // non-breaking space
83 - ));
84 - }
 73+ # South Africa uses space for thousands and comma for decimal
 74+ # Reference: AWS Reël 7.4 p. 52, 2002 edition
 75+ # glibc is wrong in this respect in some versions
 76+ function separatorTransformTable() {
 77+ return array(',' => "\xc2\xa0", '.' => ',' );
8578 }
8679
8780 }
Index: trunk/phase3/languages/LanguageSr_ec.php
@@ -162,8 +162,8 @@
163163 return $wgMagicWordsSr_ec;
164164 }
165165
166 - function formatNum( $number, $year = false ) {
167 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 166+ function separatorTransformTable() {
 167+ return array(',' => '.', '.' => ',' );
168168 }
169169
170170 /**
@@ -278,5 +278,4 @@
279279 }
280280
281281 }
282 -
283282 ?>
Index: trunk/phase3/languages/LanguageId.php
@@ -113,8 +113,8 @@
114114 }
115115 }
116116
117 - function formatNum( $number, $year = false ) {
118 - return !$year ? strtr($this->commafy($number), '.,', ',.' ) : $number;
 117+ function separatorTransformTable() {
 118+ return array(',' => '.', '.' => ',' );
119119 }
120120
121121 }
Index: trunk/phase3/languages/LanguageAr.php
@@ -97,20 +97,22 @@
9898 }
9999
100100 class LanguageAr extends LanguageUtf8 {
101 - var $digitTransTable = array(
102 - '0' => '٠',
103 - '1' => '١',
104 - '2' => '٢',
105 - '3' => '٣',
106 - '4' => '٤',
107 - '5' => '٥',
108 - '6' => '٦',
109 - '7' => '٧',
110 - '8' => '٨',
111 - '9' => '٩',
112 - '.' => '٫',
113 - ',' => '٬'
114 - );
 101+ function digitTransformTable() {
 102+ return array(
 103+ '0' => '٠',
 104+ '1' => '١',
 105+ '2' => '٢',
 106+ '3' => '٣',
 107+ '4' => '٤',
 108+ '5' => '٥',
 109+ '6' => '٦',
 110+ '7' => '٧',
 111+ '8' => '٨',
 112+ '9' => '٩',
 113+ '.' => '٫', // wrong table?
 114+ ',' => '٬'
 115+ );
 116+ }
115117
116118 function getNamespaces() {
117119 global $wgNamespaceNamesAr;
@@ -159,14 +161,5 @@
160162 }
161163 }
162164
163 - function formatNum( $number ) {
164 - global $wgTranslateNumerals;
165 - if( $wgTranslateNumerals ) {
166 - return strtr( $number, $this->digitTransTable );
167 - } else {
168 - return $number;
169 - }
170 - }
171165 }
172 -
173166 ?>
Index: trunk/phase3/languages/LanguageEo.php
@@ -178,9 +178,10 @@
179179 $wgEditEncoding = '';
180180 }
181181
182 - function formatNum( $number, $year = false ) {
183 - return $year ? $number : strtr($this->commafy($number), '.,', ', ' );
 182+ function separatorTransformTable() {
 183+ return array(',' => ' ', '.' => ',' );
184184 }
 185+
185186 }
186187
187188 ?>
Index: trunk/phase3/languages/LanguageEs.php
@@ -80,9 +80,10 @@
8181 }
8282 }
8383
84 - function formatNum( $number, $year = false ) {
85 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 84+ function separatorTransformTable() {
 85+ return array(',' => '.', '.' => ',' );
8686 }
 87+
8788 }
8889
8990 ?>
Index: trunk/phase3/languages/LanguageAz.php
@@ -43,15 +43,14 @@
4444 }
4545
4646
47 -
4847 class LanguageAz extends LanguageUtf8 {
4948 function getNamespaces() {
5049 global $wgNamespaceNamesAz;
5150 return $wgNamespaceNamesAz;
5251 }
5352
54 - function formatNum( $number, $year = false ) {
55 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 53+ function separatorTransformTable() {
 54+ return array(',' => '.', '.' => ',' );
5655 }
5756
5857 function ucfirst ( $string ) {
@@ -77,6 +76,4 @@
7877 }
7978
8079 }
81 -
82 -
8380 ?>
\ No newline at end of file
Index: trunk/phase3/languages/LanguageIt.php
@@ -63,8 +63,8 @@
6464 /**
6565 * Italian numeric format is 201.511,17
6666 */
67 - function formatNum( $number, $year = false ) {
68 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 67+ function separatorTransformTable() {
 68+ return array(',' => '.', '.' => ',' );
6969 }
7070
7171 }
Index: trunk/phase3/languages/LanguageUk.php
@@ -90,10 +90,9 @@
9191 return "windows-1251";
9292 }
9393
94 - function formatNum( $number, $year = false ) {
95 - return !$year ? strtr($number, '.,', ',.' ) : $number;
 94+ function separatorTransformTable() {
 95+ return array(',' => '.', '.' => ',' );
9696 }
9797
9898 }
99 -
100 -?>
 99+?>
\ No newline at end of file
Index: trunk/phase3/languages/LanguageBe.php
@@ -169,8 +169,8 @@
170170 }
171171 }
172172
173 - function formatNum( $number, $year = false ) {
174 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 173+ function separatorTransformTable() {
 174+ return array(',' => '.', '.' => ',' );
175175 }
176176
177177 function convertPlural( $count, $wordform1, $wordform2, $wordform3) {
@@ -188,4 +188,5 @@
189189 }
190190 }
191191 }
 192+
192193 ?>
Index: trunk/phase3/languages/LanguageBg.php
@@ -173,26 +173,21 @@
174174 }
175175
176176
177 - /**
178 - * Translation table for numbers
179 - * @var array
180 - */
181 - var $digitTransTable = array(
182 - ',' => "\xC2\xA0", // @bug 2749
183 - '.' => ','
184 - );
 177+ function separatorTransformTable() {
 178+ return array(',' => "\xc2\xa0", '.' => ',' );
 179+ }
185180
186181 /**
187182 * ISO number formatting: 123 456 789,99.
188183 * Avoid tripple grouping by numbers with whole part up to 4 digits.
189 - * @param string $number
190 - * @return string
191184 */
192 - function formatNum( $number, $year = false ) {
193 - if ( preg_match('/^\d{5}/', $number) ) {
194 - $number = $this->commafy($number);
 185+ function commafy($_) {
 186+ if (!preg_match('/^\d{1,4}$/',$_)) {
 187+ return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
 188+ } else {
 189+ return $_;
195190 }
196 - return strtr($number, $this->digitTransTable);
197191 }
 192+
198193 }
199194 ?>
Index: trunk/phase3/languages/LanguageBo.php
@@ -10,27 +10,21 @@
1111 require_once( 'LanguageUtf8.php' );
1212
1313 class LanguageBo extends LanguageUtf8 {
14 - var $digitTransTable = array(
15 - '0' => '༠',
16 - '1' => '༡',
17 - '2' => '༢',
18 - '3' => '༣',
19 - '4' => '༤',
20 - '5' => '༥',
21 - '6' => '༦',
22 - '7' => '༧',
23 - '8' => '༨',
24 - '9' => '༩'
25 - );
26 -
27 - function formatNum( $number ) {
28 - global $wgTranslateNumerals;
29 - if( $wgTranslateNumerals ) {
30 - return strtr( $number, $this->digitTransTable );
31 - } else {
32 - return $number;
33 - }
 14+ function digitTransformTable() {
 15+ return array(
 16+ '0' => '༠',
 17+ '1' => '༡',
 18+ '2' => '༢',
 19+ '3' => '༣',
 20+ '4' => '༤',
 21+ '5' => '༥',
 22+ '6' => '༦',
 23+ '7' => '༧',
 24+ '8' => '༨',
 25+ '9' => '༩'
 26+ );
3427 }
 28+
3529 }
3630
3731 ?>
Index: trunk/phase3/languages/LanguageBs.php
@@ -160,8 +160,8 @@
161161 return "iso-8859-2";
162162 }
163163
164 - function formatNum( $number, $year = false ) {
165 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 164+ function separatorTransformTable() {
 165+ return array(',' => '.', '.' => ',' );
166166 }
167167
168168 # Convert from the nominative form of a noun to some other case
Index: trunk/phase3/languages/LanguageFr.php
@@ -92,13 +92,8 @@
9393 return " à ";
9494 }
9595
96 - var $digitTransTable = array(
97 - ',' => "\xc2\xa0", // @bug 2749
98 - '.' => ','
99 - );
100 -
101 - function formatNum( $number, $year = false ) {
102 - return !$year ? strtr($number, $this->digitTransTable ) : $number;
 96+ function separatorTransformTable() {
 97+ return array(',' => "\xc2\xa0", '.' => ',' );
10398 }
10499
105100 function getMessage( $key ) {
Index: trunk/phase3/languages/LanguageNl.php
@@ -83,9 +83,9 @@
8484 }
8585 }
8686
87 - function formatNum( $number, $year = false ) {
88 - return $year ? $number : strtr( $this->commafy( $number ), '.,', ',.' );
 87+ function separatorTransformTable() {
 88+ return array(',' => '.', '.' => ',' );
8989 }
 90+
9091 }
91 -
9292 ?>
Index: trunk/phase3/languages/LanguageNn.php
@@ -204,13 +204,11 @@
205205
206206 }
207207
208 - var $digitTransTable = array(
209 - ',' => "\xc2\xa0",
210 - '.' => ','
211 - );
212 -
213 - function formatNum( $number, $year = false ) {
214 - return $year ? $number : strtr($this->commafy($number), $this->digitTransTable);
 208+ function separatorTransformTable() {
 209+ return array(
 210+ ',' => "\xc2\xa0",
 211+ '.' => ','
 212+ );
215213 }
216214
217215 function getMessage( $key ) {
Index: trunk/phase3/languages/Language.php
@@ -892,10 +892,7 @@
893893 return "<em>$text</em>";
894894 }
895895
896 - /**
897 - * This function enables formatting of numbers, it should only come
898 - * into effect when the $wgTranslateNumerals variable is TRUE.
899 - *
 896+ /**
900897 * Normally we output all numbers in plain en_US style, that is
901898 * 293,291.235 for twohundredninetythreethousand-twohundredninetyone
902899 * point twohundredthirtyfive. However this is not sutable for all
@@ -916,11 +913,23 @@
917914 * @public
918915 * @param mixed $number the string to be formatted, should be an integer or
919916 * a floating point number.
920 - * @param bool $year are we being passed a year? (turns off commafication)
921 - * @return mixed whatever we're fed if it's a year, a string otherwise.
 917+ * @param bool $commafy Set to false for special numbers like dates
 918+ * @return string
922919 */
923 - function formatNum( $number, $year = false ) {
924 - return $year ? $number : $this->commafy($number);
 920+ function formatNum( $number, $commafy = false ) {
 921+ global $wgTranslateNumerals;
 922+ if (!$commafy) {
 923+ $number = $this->commafy($number);
 924+ $s = $this->separatorTransformTable();
 925+ if (!is_null($s)) { $number = strtr($number, $s); }
 926+ }
 927+
 928+ if ($wgTranslateNumerals) {
 929+ $s = $this->digitTransformTable();
 930+ if (!is_null($s)) { $number = strtr($number, $s); }
 931+ }
 932+
 933+ return $number;
925934 }
926935
927936 /**
@@ -933,6 +942,15 @@
934943 return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
935944 }
936945
 946+ function digitTransformTable() {
 947+ return null;
 948+ }
 949+
 950+ function separatorTransformTable() {
 951+ return null;
 952+ }
 953+
 954+
937955 /**
938956 * For the credit list in includes/Credits.php (action=credits)
939957 *
Index: trunk/phase3/languages/LanguageRu.php
@@ -217,22 +217,24 @@
218218 }
219219 }
220220
221 - /**
 221+ /*
222222 * Russian numeric format is "12 345,67" but "1234,56"
223223 */
224 - function formatNum( $number, $year = false ) {
225 - if ($year) {
226 - return $number;
 224+
 225+ function commafy($_) {
 226+ if (!preg_match('/^\d{1,4}$/',$_)) {
 227+ return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
 228+ } else {
 229+ return $_;
227230 }
228 - else {
229 - //not strtr because of 2-byte unicode nbsp char
230 - $commafied_number = str_replace('.', ',', str_replace(',', ' ', $this->commafy($number)));
231 - return ($number<10000) ? str_replace(' ', '', $commafied_number) : $commafied_number;
232 - }
 231+ }
233232
234 -
 233+ function separatorTransformTable() {
 234+ return array(
 235+ ',' => "\xc2\xa0",
 236+ '.' => ','
 237+ );
235238 }
236239
237240 }
238 -
239241 ?>
Index: trunk/phase3/languages/LanguageKn.php
@@ -21,18 +21,20 @@
2222 }
2323
2424 class LanguageKn extends LanguageUtf8 {
25 - var $digitTransTable = array(
26 - '0' => '೦',
27 - '1' => '೧',
28 - '2' => '೨',
29 - '3' => '೩',
30 - '4' => '೪',
31 - '5' => '೫',
32 - '6' => '೬',
33 - '7' => '೭',
34 - '8' => '೮',
35 - '9' => '೯'
36 - );
 25+ function digitTransformTable() {
 26+ return array(
 27+ '0' => '೦',
 28+ '1' => '೧',
 29+ '2' => '೨',
 30+ '3' => '೩',
 31+ '4' => '೪',
 32+ '5' => '೫',
 33+ '6' => '೬',
 34+ '7' => '೭',
 35+ '8' => '೮',
 36+ '9' => '೯'
 37+ );
 38+ }
3739
3840 function getMessage( $key ) {
3941 global $wgAllMessagesKn;
@@ -42,14 +44,6 @@
4345 return parent::getMessage($key);
4446 }
4547
46 - function formatNum( $number ) {
47 - global $wgTranslateNumerals;
48 - if( $wgTranslateNumerals ) {
49 - return strtr( $number, $this->digitTransTable );
50 - } else {
51 - return $number;
52 - }
53 - }
5448 }
5549
5650 ?>
Index: trunk/phase3/languages/LanguageGu.php
@@ -7,27 +7,21 @@
88 require_once( 'LanguageUtf8.php' );
99
1010 class LanguageGu extends LanguageUtf8 {
11 - var $digitTransTable = array(
12 - '0' => '૦',
13 - '1' => '૧',
14 - '2' => '૨',
15 - '3' => '૩',
16 - '4' => '૪',
17 - '5' => '૫',
18 - '6' => '૬',
19 - '7' => '૭',
20 - '8' => '૮',
21 - '9' => '૯'
22 - );
23 -
24 - function formatNum( $number ) {
25 - global $wgTranslateNumerals;
26 - if( $wgTranslateNumerals ) {
27 - return strtr( $number, $this->digitTransTable );
28 - } else {
29 - return $number;
30 - }
 11+ function digitTransformTable() {
 12+ return array(
 13+ '0' => '૦',
 14+ '1' => '૧',
 15+ '2' => '૨',
 16+ '3' => '૩',
 17+ '4' => '૪',
 18+ '5' => '૫',
 19+ '6' => '૬',
 20+ '7' => '૭',
 21+ '8' => '૮',
 22+ '9' => '૯'
 23+ );
3124 }
 25+
3226 }
3327
3428 ?>
Index: trunk/phase3/languages/LanguageSl.php
@@ -93,8 +93,8 @@
9494 return "iso-8859-2";
9595 }
9696
97 - function formatNum( $number, $year = false ) {
98 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 97+ function separatorTransformTable() {
 98+ return array(',' => '.', '.' => ',' );
9999 }
100100
101101 # Convert from the nominative form of a noun to some other case
Index: trunk/phase3/languages/LanguageOs.php
@@ -83,9 +83,5 @@
8484 return "windows-1251";
8585 }
8686
87 - function formatNum( $number, $year = false ) {
88 - return !$year ? strtr($number, '.,', ', ' ) : $number;
89 - }
90 -
9187 }
9288 ?>
Index: trunk/phase3/languages/LanguageDa.php
@@ -102,8 +102,8 @@
103103 }
104104 }
105105
106 - function formatNum( $number, $year = false ) {
107 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 106+ function separatorTransformTable() {
 107+ return array(',' => '.', '.' => ',' );
108108 }
109109
110110 }
Index: trunk/phase3/languages/LanguageDe.php
@@ -100,8 +100,8 @@
101101 }
102102 }
103103
104 - function formatNum( $number, $year = false ) {
105 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 104+ function separatorTransformTable() {
 105+ return array(',' => '.', '.' => ',' );
106106 }
107107
108108 }
Index: trunk/phase3/languages/LanguageSv.php
@@ -93,14 +93,12 @@
9494 }
9595 }
9696
97 - var $digitTransTable = array(
98 - ',' => "\xc2\xa0", // @bug 2749
99 - '.' => ','
100 - );
101 -
102 - function formatNum( $number, $year = false ) {
103 - return $year ? $number : strtr($this->commafy($number), $this->digitTransTable);
 97+ function separatorTransformTable() {
 98+ return array(
 99+ ',' => "\xc2\xa0", // @bug 2749
 100+ '.' => ','
 101+ );
104102 }
105 -}
106103
 104+}
107105 ?>
Index: trunk/phase3/languages/LanguageTe.php
@@ -10,27 +10,21 @@
1111 require_once( 'LanguageUtf8.php' );
1212
1313 class LanguageTe extends LanguageUtf8 {
14 - var $digitTransTable = array(
15 - '0' => '౦',
16 - '1' => '౧',
17 - '2' => '౨',
18 - '3' => '౩',
19 - '4' => '౪',
20 - '5' => '౫',
21 - '6' => '౬',
22 - '7' => '౭',
23 - '8' => '౮',
24 - '9' => '౯'
25 - );
2614
27 - function formatNum( $number ) {
28 - global $wgTranslateNumerals;
29 - if( $wgTranslateNumerals ) {
30 - return strtr( $number, $this->digitTransTable );
31 - } else {
32 - return $number;
33 - }
 15+ function digitTransformTable() {
 16+ return array(
 17+ '0' => '౦',
 18+ '1' => '౧',
 19+ '2' => '౨',
 20+ '3' => '౩',
 21+ '4' => '౪',
 22+ '5' => '౫',
 23+ '6' => '౬',
 24+ '7' => '౭',
 25+ '8' => '౮',
 26+ '9' => '౯'
 27+ );
3428 }
35 -}
3629
 30+}
3731 ?>
Index: trunk/phase3/languages/LanguageHr.php
@@ -94,9 +94,9 @@
9595 }
9696 }
9797
98 - function formatNum( $number, $year = false ) {
99 - return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
100 - }
 98+ function separatorTransformTable() {
 99+ return array(',' => '.', '.' => ',' );
 100+ }
101101
102102 function fallback8bitEncoding() {
103103 return "iso-8859-2";
Index: trunk/phase3/languages/LanguageLo.php
@@ -10,27 +10,21 @@
1111 require_once( 'LanguageUtf8.php' );
1212
1313 class LanguageLo extends LanguageUtf8 {
14 - var $digitTransTable = array(
15 - '0' => '໐',
16 - '1' => '໑',
17 - '2' => '໒',
18 - '3' => '໓',
19 - '4' => '໔',
20 - '5' => '໕',
21 - '6' => '໖',
22 - '7' => '໗',
23 - '8' => '໘',
24 - '9' => '໙'
25 - );
26 -
27 - function formatNum( $number ) {
28 - global $wgTranslateNumerals;
29 - if( $wgTranslateNumerals ) {
30 - return strtr( $number, $this->digitTransTable );
31 - } else {
32 - return $number;
33 - }
 14+ function digitTransformTable() {
 15+ return array(
 16+ '0' => '໐',
 17+ '1' => '໑',
 18+ '2' => '໒',
 19+ '3' => '໓',
 20+ '4' => '໔',
 21+ '5' => '໕',
 22+ '6' => '໖',
 23+ '7' => '໗',
 24+ '8' => '໘',
 25+ '9' => '໙'
 26+ );
3427 }
 28+
3529 }
3630
3731 ?>
Index: trunk/phase3/languages/LanguagePl.php
@@ -104,14 +104,12 @@
105105 return "iso-8859-2";
106106 }
107107
108 - var $digitTransTable = array(
109 - ',' => "\xc2\xa0", // @bug 2749
110 - '.' => ','
111 - );
112 -
113 - function formatNum( $number, $year = false ) {
114 - return !$year ? strtr($number, $this->digitTransTable ) : $number;
 108+ function separatorTransformTable() {
 109+ return array(
 110+ ',' => "\xc2\xa0", // @bug 2749
 111+ '.' => ','
 112+ );
115113 }
116 -}
117114
 115+}
118116 ?>
Index: trunk/phase3/languages/LanguagePt.php
@@ -141,8 +141,8 @@
142142 /**
143143 * Portuguese numeric format is 123 456,78
144144 */
145 - function formatNum( $number, $year = false ) {
146 - return $year ? $number : strtr($this->commafy($number), '.,', ', ' );
 145+ function separatorTransformTable() {
 146+ return array(',' => ' ', '.' => ',' );
147147 }
148148
149149 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r14467Revert to r13936; r14440 version was completely broken.brion21:56, 29 May 2006

Status & tagging log