r9839 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r9838‎ | r9839 | r9840 >
Date:20:26, 2 July 2005
Author:nikerabbit
Status:old
Tags:
Comment:

(bugs 2633, 2672) Fix Estonian, Portuguese and Finnish numeric formatting
Little code cleanup
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/languages/LanguageEt.php (modified) (history)
  • /trunk/phase3/languages/LanguageFi.php (modified) (history)
  • /trunk/phase3/languages/LanguagePt.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES
@@ -443,8 +443,8 @@
444444 * (bug 2629) Automatically capitalize usernames again instead of
445445 rejecting lowercase with a useless error message
446446 * (bug 2661) Fix link generation in contribs
 447+* (bugs 2633, 2672) Fix Estonian, Portuguese and Finnish numeric formatting
447448
448 -
449449 === Caveats ===
450450
451451 Some output, particularly involving user-supplied inline HTML, may not
Index: trunk/phase3/languages/LanguagePt.php
@@ -954,38 +954,41 @@
955955 return $wgDateFormatsPt;
956956 }
957957
958 - function timeanddate( $ts, $adj = false )
959 - {
 958+ function timeanddate( $ts, $adj = false ) {
960959 return $this->time( $ts, $adj ) . ", " . $this->date( $ts, $adj );
961960 }
962961
963 - function getValidSpecialPages()
964 - {
 962+ function getValidSpecialPages() {
965963 global $wgValidSpecialPagesPt;
966964 return $wgValidSpecialPagesPt;
967965 }
968966
969 - function getSysopSpecialPages()
970 - {
 967+ function getSysopSpecialPages() {
971968 global $wgSysopSpecialPagesPt;
972969 return $wgSysopSpecialPagesPt;
973970 }
974971
975 - function getDeveloperSpecialPages()
976 - {
 972+ function getDeveloperSpecialPages() {
977973 global $wgDeveloperSpecialPagesPt;
978974 return $wgDeveloperSpecialPagesPt;
979975 }
980976
981 - function getMessage( $key )
982 - {
983 - global $wgAllMessagesPt;
984 - if( isset( $wgAllMessagesPt[$key] ) ) {
985 - return $wgAllMessagesPt[$key];
986 - } else {
987 - return parent::getMessage( $key );
988 - }
 977+ function getMessage( $key ) {
 978+ global $wgAllMessagesPt;
 979+ if( isset( $wgAllMessagesPt[$key] ) ) {
 980+ return $wgAllMessagesPt[$key];
 981+ } else {
 982+ return parent::getMessage( $key );
 983+ }
989984 }
 985+
 986+ /**
 987+ * Portuguese numeric format is 123.456,78
 988+ */
 989+ function formatNum( $number, $year = false ) {
 990+ return $year ? $number : strtr($this->commafy($number), '.,', ',.' );
 991+ }
 992+
990993 }
991994
992995 ?>
Index: trunk/phase3/languages/LanguageEt.php
@@ -1083,20 +1083,17 @@
10841084 return $wgSkinNamesEt;
10851085 }
10861086
1087 - function getValidSpecialPages()
1088 - {
 1087+ function getValidSpecialPages() {
10891088 global $wgValidSpecialPagesEt;
10901089 return $wgValidSpecialPagesEt;
10911090 }
10921091
1093 - function getSysopSpecialPages()
1094 - {
 1092+ function getSysopSpecialPages() {
10951093 global $wgSysopSpecialPagesEt;
10961094 return $wgSysopSpecialPagesEt;
10971095 }
10981096
1099 - function getDeveloperSpecialPages()
1100 - {
 1097+ function getDeveloperSpecialPages() {
11011098 global $wgDeveloperSpecialPagesEt;
11021099 return $wgDeveloperSpecialPagesEt;
11031100 }
@@ -1110,5 +1107,24 @@
11111108 }
11121109 }
11131110
 1111+ /**
 1112+ * Estonian numeric formatting is 123 456,78.
 1113+ * Notice that the space is non-breaking.
 1114+ */
 1115+ function formatNum( $number, $year = false ) {
 1116+ return $year ? $number : strtr($this->commafy($number), '.,', ", " );
 1117+ }
 1118+
 1119+ /**
 1120+ * Avoid grouping whole numbers between 0 to 9999
 1121+ */
 1122+ function commafy($_) {
 1123+ if (!preg_match('/^\d{1,4}$/',$_)) {
 1124+ return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
 1125+ } else {
 1126+ return $_;
 1127+ }
 1128+ }
 1129+
11141130 }
11151131 ?>
Index: trunk/phase3/languages/LanguageFi.php
@@ -1324,8 +1324,7 @@
13251325 return $wgSkinNamesFi;
13261326 }
13271327
1328 - function date( $ts, $adj = false )
1329 - {
 1328+ function date( $ts, $adj = false ) {
13301329 if ( $adj ) { $ts = $this->userAdjust( $ts ); }
13311330
13321331 $d = (0 + substr( $ts, 6, 2 )) . '. ' .
@@ -1333,8 +1332,7 @@
13341333 return $d;
13351334 }
13361335
1337 - function time( $ts, $adj = false, $seconds = true )
1338 - {
 1336+ function time( $ts, $adj = false, $seconds = true ) {
13391337 if ( $adj ) { $ts = $this->userAdjust( $ts ); }
13401338
13411339 $t = substr( $ts, 8, 2 ) . ':' . substr( $ts, 10, 2 );
@@ -1344,13 +1342,11 @@
13451343 return $t;
13461344 }
13471345
1348 - function timeanddate( $ts, $adj = false )
1349 - {
 1346+ function timeanddate( $ts, $adj = false ) {
13501347 return $this->date( $ts, $adj ) . ' kello ' . $this->time( $ts, $adj );
13511348 }
13521349
1353 - function getMessage( $key )
1354 - {
 1350+ function getMessage( $key ) {
13551351 global $wgAllMessagesFi;
13561352 if( isset( $wgAllMessagesFi[$key] ) ) {
13571353 return $wgAllMessagesFi[$key];
@@ -1359,13 +1355,23 @@
13601356 }
13611357 }
13621358
1363 - var $digitTransTable = array(
1364 - ',' => ' ',
1365 - '.' => ','
1366 - );
 1359+ /**
 1360+ * Finnish numeric formatting is 123 456,78.
 1361+ * Notice that the space is non-breaking.
 1362+ */
 1363+ function formatNum( $number, $year = false ) {
 1364+ return $year ? $number : strtr($this->commafy($number), '.,', ", " );
 1365+ }
13671366
1368 - function formatNum( $number ) {
1369 - return strtr($number, $this->digitTransTable );
 1367+ /**
 1368+ * Avoid grouping whole numbers between 0 to 9999
 1369+ */
 1370+ function commafy($_) {
 1371+ if (!preg_match('/^\d{1,4}$/',$_)) {
 1372+ return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
 1373+ } else {
 1374+ return $_;
 1375+ }
13701376 }
13711377
13721378 # Convert from the nominative form of a noun to some other case

Status & tagging log