Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -443,8 +443,8 @@ |
444 | 444 | * (bug 2629) Automatically capitalize usernames again instead of |
445 | 445 | rejecting lowercase with a useless error message |
446 | 446 | * (bug 2661) Fix link generation in contribs |
| 447 | +* (bugs 2633, 2672) Fix Estonian, Portuguese and Finnish numeric formatting |
447 | 448 | |
448 | | - |
449 | 449 | === Caveats === |
450 | 450 | |
451 | 451 | Some output, particularly involving user-supplied inline HTML, may not |
Index: trunk/phase3/languages/LanguagePt.php |
— | — | @@ -954,38 +954,41 @@ |
955 | 955 | return $wgDateFormatsPt; |
956 | 956 | } |
957 | 957 | |
958 | | - function timeanddate( $ts, $adj = false ) |
959 | | - { |
| 958 | + function timeanddate( $ts, $adj = false ) { |
960 | 959 | return $this->time( $ts, $adj ) . ", " . $this->date( $ts, $adj ); |
961 | 960 | } |
962 | 961 | |
963 | | - function getValidSpecialPages() |
964 | | - { |
| 962 | + function getValidSpecialPages() { |
965 | 963 | global $wgValidSpecialPagesPt; |
966 | 964 | return $wgValidSpecialPagesPt; |
967 | 965 | } |
968 | 966 | |
969 | | - function getSysopSpecialPages() |
970 | | - { |
| 967 | + function getSysopSpecialPages() { |
971 | 968 | global $wgSysopSpecialPagesPt; |
972 | 969 | return $wgSysopSpecialPagesPt; |
973 | 970 | } |
974 | 971 | |
975 | | - function getDeveloperSpecialPages() |
976 | | - { |
| 972 | + function getDeveloperSpecialPages() { |
977 | 973 | global $wgDeveloperSpecialPagesPt; |
978 | 974 | return $wgDeveloperSpecialPagesPt; |
979 | 975 | } |
980 | 976 | |
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 | + } |
989 | 984 | } |
| 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 | + |
990 | 993 | } |
991 | 994 | |
992 | 995 | ?> |
Index: trunk/phase3/languages/LanguageEt.php |
— | — | @@ -1083,20 +1083,17 @@ |
1084 | 1084 | return $wgSkinNamesEt; |
1085 | 1085 | } |
1086 | 1086 | |
1087 | | - function getValidSpecialPages() |
1088 | | - { |
| 1087 | + function getValidSpecialPages() { |
1089 | 1088 | global $wgValidSpecialPagesEt; |
1090 | 1089 | return $wgValidSpecialPagesEt; |
1091 | 1090 | } |
1092 | 1091 | |
1093 | | - function getSysopSpecialPages() |
1094 | | - { |
| 1092 | + function getSysopSpecialPages() { |
1095 | 1093 | global $wgSysopSpecialPagesEt; |
1096 | 1094 | return $wgSysopSpecialPagesEt; |
1097 | 1095 | } |
1098 | 1096 | |
1099 | | - function getDeveloperSpecialPages() |
1100 | | - { |
| 1097 | + function getDeveloperSpecialPages() { |
1101 | 1098 | global $wgDeveloperSpecialPagesEt; |
1102 | 1099 | return $wgDeveloperSpecialPagesEt; |
1103 | 1100 | } |
— | — | @@ -1110,5 +1107,24 @@ |
1111 | 1108 | } |
1112 | 1109 | } |
1113 | 1110 | |
| 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 | + |
1114 | 1130 | } |
1115 | 1131 | ?> |
Index: trunk/phase3/languages/LanguageFi.php |
— | — | @@ -1324,8 +1324,7 @@ |
1325 | 1325 | return $wgSkinNamesFi; |
1326 | 1326 | } |
1327 | 1327 | |
1328 | | - function date( $ts, $adj = false ) |
1329 | | - { |
| 1328 | + function date( $ts, $adj = false ) { |
1330 | 1329 | if ( $adj ) { $ts = $this->userAdjust( $ts ); } |
1331 | 1330 | |
1332 | 1331 | $d = (0 + substr( $ts, 6, 2 )) . '. ' . |
— | — | @@ -1333,8 +1332,7 @@ |
1334 | 1333 | return $d; |
1335 | 1334 | } |
1336 | 1335 | |
1337 | | - function time( $ts, $adj = false, $seconds = true ) |
1338 | | - { |
| 1336 | + function time( $ts, $adj = false, $seconds = true ) { |
1339 | 1337 | if ( $adj ) { $ts = $this->userAdjust( $ts ); } |
1340 | 1338 | |
1341 | 1339 | $t = substr( $ts, 8, 2 ) . ':' . substr( $ts, 10, 2 ); |
— | — | @@ -1344,13 +1342,11 @@ |
1345 | 1343 | return $t; |
1346 | 1344 | } |
1347 | 1345 | |
1348 | | - function timeanddate( $ts, $adj = false ) |
1349 | | - { |
| 1346 | + function timeanddate( $ts, $adj = false ) { |
1350 | 1347 | return $this->date( $ts, $adj ) . ' kello ' . $this->time( $ts, $adj ); |
1351 | 1348 | } |
1352 | 1349 | |
1353 | | - function getMessage( $key ) |
1354 | | - { |
| 1350 | + function getMessage( $key ) { |
1355 | 1351 | global $wgAllMessagesFi; |
1356 | 1352 | if( isset( $wgAllMessagesFi[$key] ) ) { |
1357 | 1353 | return $wgAllMessagesFi[$key]; |
— | — | @@ -1359,13 +1355,23 @@ |
1360 | 1356 | } |
1361 | 1357 | } |
1362 | 1358 | |
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 | + } |
1367 | 1366 | |
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 | + } |
1370 | 1376 | } |
1371 | 1377 | |
1372 | 1378 | # Convert from the nominative form of a noun to some other case |