Index: trunk/phase3/includes/DateFormatter.php |
— | — | @@ -47,14 +47,14 @@ |
48 | 48 | * @todo document |
49 | 49 | */ |
50 | 50 | function DateFormatter() { |
51 | | - global $wgMonthNamesEn, $wgMonthAbbreviationsEn, $wgInputEncoding; |
| 51 | + global $wgContLang, $wgInputEncoding; |
52 | 52 | |
53 | 53 | $this->monthNames = $this->getMonthRegex(); |
54 | 54 | for ( $i=1; $i<=12; $i++ ) { |
55 | | - $this->xMonths[strtolower( $wgMonthNamesEn[$i-1] )] = $i; |
| 55 | + $this->xMonths[strtolower( $wgContLang->getMonthName( $i ) )] = $i; |
56 | 56 | } |
57 | 57 | for ( $i=1; $i<=12; $i++ ) { |
58 | | - $this->xMonths[strtolower( $wgMonthAbbreviationsEn[$i-1] )] = $i; |
| 58 | + $this->xMonths[strtolower( $wgContLang->getMonthAbbreviation( $i ) )] = $i; |
59 | 59 | } |
60 | 60 | |
61 | 61 | # Attempt at UTF-8 support, untested at the moment |
— | — | @@ -140,7 +140,6 @@ |
141 | 141 | * @param $matches |
142 | 142 | */ |
143 | 143 | function replace( $matches ) { |
144 | | - global $wgMonthNamesEn; |
145 | 144 | # Extract information from $matches |
146 | 145 | $bits = array(); |
147 | 146 | $key = $this->keys[$this->mSource]; |
— | — | @@ -160,14 +159,14 @@ |
161 | 160 | $char = $format{$p}; |
162 | 161 | switch ( $char ) { |
163 | 162 | case 'd': # ISO day of month |
164 | | - if ( is_null($bits['d']) ) { |
| 163 | + if ( !isset($bits['d']) ) { |
165 | 164 | $text .= sprintf( '%02d', $bits['j'] ); |
166 | 165 | } else { |
167 | 166 | $text .= $bits['d']; |
168 | 167 | } |
169 | 168 | break; |
170 | 169 | case 'm': # ISO month |
171 | | - if ( is_null($bits['m']) ) { |
| 170 | + if ( !isset($bits['m']) ) { |
172 | 171 | $m = $this->makeIsoMonth( $bits['F'] ); |
173 | 172 | if ( !$m || $m == '00' ) { |
174 | 173 | $fail = true; |
— | — | @@ -179,33 +178,34 @@ |
180 | 179 | } |
181 | 180 | break; |
182 | 181 | case 'y': # ISO year |
183 | | - if ( is_null( $bits['y'] ) ) { |
| 182 | + if ( !isset( $bits['y'] ) ) { |
184 | 183 | $text .= $this->makeIsoYear( $bits['Y'] ); |
185 | 184 | } else { |
186 | 185 | $text .= $bits['y']; |
187 | 186 | } |
188 | 187 | break; |
189 | 188 | case 'j': # ordinary day of month |
190 | | - if ( is_null($bits['j']) ) { |
| 189 | + if ( !isset($bits['j']) ) { |
191 | 190 | $text .= IntVal( $bits['d'] ); |
192 | 191 | } else { |
193 | 192 | $text .= $bits['j']; |
194 | 193 | } |
195 | 194 | break; |
196 | 195 | case 'F': # long month |
197 | | - if ( is_null( $bits['F'] ) ) { |
| 196 | + if ( !isset( $bits['F'] ) ) { |
198 | 197 | $m = IntVal($bits['m']); |
199 | 198 | if ( $m > 12 || $m < 1 ) { |
200 | 199 | $fail = true; |
201 | 200 | } else { |
202 | | - $text .= $wgMonthNamesEn[$m-1]; |
| 201 | + global $wgContLang; |
| 202 | + $text .= $wgContLang->getMonthName( $m ); |
203 | 203 | } |
204 | 204 | } else { |
205 | 205 | $text .= ucfirst( $bits['F'] ); |
206 | 206 | } |
207 | 207 | break; |
208 | 208 | case 'Y': # ordinary (optional BC) year |
209 | | - if ( is_null( $bits['Y'] ) ) { |
| 209 | + if ( !isset( $bits['Y'] ) ) { |
210 | 210 | $text .= $this->makeNormalYear( $bits['y'] ); |
211 | 211 | } else { |
212 | 212 | $text .= $bits['Y']; |
— | — | @@ -225,8 +225,13 @@ |
226 | 226 | * @todo document |
227 | 227 | */ |
228 | 228 | function getMonthRegex() { |
229 | | - global $wgMonthNamesEn, $wgMonthAbbreviationsEn; |
230 | | - return implode( '|', array_merge($wgMonthNamesEn, $wgMonthAbbreviationsEn)); |
| 229 | + global $wgContLang; |
| 230 | + $names = array(); |
| 231 | + for( $i = 1; $i <= 12; $i++ ) { |
| 232 | + $names[] = $wgContLang->getMonthName( $i ); |
| 233 | + $names[] = $wgContLang->getMonthAbbreviation( $i ); |
| 234 | + } |
| 235 | + return implode( '|', $names ); |
231 | 236 | } |
232 | 237 | |
233 | 238 | /** |