Index: trunk/phase3/includes/SpecialNewpages.php |
— | — | @@ -20,13 +20,12 @@ |
21 | 21 | } |
22 | 22 | |
23 | 23 | function formatResult( $skin, $result ) { |
24 | | - |
25 | 24 | global $wgLang; |
26 | 25 | |
27 | 26 | $u = $result->cur_user; |
28 | 27 | $ut = $result->cur_user_text; |
29 | 28 | |
30 | | - $length = wfmsg( "nbytes", $result->cur_length ); |
| 29 | + $length = wfmsg( "nbytes", $wgLang->formatNum( $result->cur_length ) ); |
31 | 30 | $c = wfEscapeHTML( $result->cur_comment ); |
32 | 31 | |
33 | 32 | if ( 0 == $u ) { # not by a logged-in user |
Index: trunk/phase3/includes/SpecialImagelist.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | if ( 0 == $limit ) { |
38 | 38 | $lt = wfMsg( "all" ); |
39 | 39 | } else { |
40 | | - $lt = "${limit}"; |
| 40 | + $lt = $wgLang->formatNum( "${limit}" ); |
41 | 41 | $sql .= " LIMIT {$limit}"; |
42 | 42 | } |
43 | 43 | $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "\n" ); |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | if ( ! $first ) { $fill .= " | "; } |
67 | 67 | $first = false; |
68 | 68 | |
69 | | - $fill .= $sk->makeKnownLink( $here, "{$num}", |
| 69 | + $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ), |
70 | 70 | "sort=bysize&limit={$num}" ); |
71 | 71 | } |
72 | 72 | $text = wfMsg( "showlast", $fill, $bysize ); |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | if ( ! $first ) { $fill .= " | "; } |
79 | 79 | $first = false; |
80 | 80 | |
81 | | - $fill .= $sk->makeKnownLink( $here, $num, |
| 81 | + $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ), |
82 | 82 | "sort=bydate&limit={$num}" ); |
83 | 83 | } |
84 | 84 | $text = wfMsg( "showlast", $fill, $bydate ); |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | $ilink = "<a href=\"" . wfImageUrl( $name ) . |
96 | 96 | "\">{$name}</a>"; |
97 | 97 | |
98 | | - $nb = wfMsg( "nbytes", $s->img_size ); |
| 98 | + $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) ); |
99 | 99 | $l = "(" . |
100 | 100 | $sk->makeKnownLink( $wgLang->getNsText( |
101 | 101 | Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) . |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -596,19 +596,22 @@ |
597 | 597 | |
598 | 598 | function wfShowingResults( $offset, $limit ) |
599 | 599 | { |
600 | | - return wfMsg( "showingresults", $limit, $offset+1 ); |
| 600 | + global $wgLang; |
| 601 | + return wfMsg( "showingresults", $wgLang->formatNum( $limit ), $wgLang->formatNum( $offset+1 ) ); |
601 | 602 | } |
602 | 603 | |
603 | 604 | function wfShowingResultsNum( $offset, $limit, $num ) |
604 | 605 | { |
605 | | - return wfMsg( "showingresultsnum", $limit, $offset+1, $num ); |
| 606 | + global $wgLang; |
| 607 | + return wfMsg( "showingresultsnum", $wgLang->formatNum( $limit ), $wgLang->formatNum( $offset+1 ), $wgLang->formatNum( $num ) ); |
606 | 608 | } |
607 | 609 | |
608 | 610 | function wfViewPrevNext( $offset, $limit, $link, $query = "", $atend = false ) |
609 | 611 | { |
610 | | - global $wgUser; |
611 | | - $prev = wfMsg( "prevn", $limit ); |
612 | | - $next = wfMsg( "nextn", $limit ); |
| 612 | + global $wgUser, $wgLang; |
| 613 | + $fmtLimit = $wgLang->formatNum( $limit ); |
| 614 | + $prev = wfMsg( "prevn", $fmtLimit ); |
| 615 | + $next = wfMsg( "nextn", $fmtLimit ); |
613 | 616 | $link = wfUrlencode( $link ); |
614 | 617 | |
615 | 618 | $sk = $wgUser->getSkin(); |
— | — | @@ -640,12 +643,13 @@ |
641 | 644 | |
642 | 645 | function wfNumLink( $offset, $limit, $link, $query = "" ) |
643 | 646 | { |
644 | | - global $wgUser; |
| 647 | + global $wgUser, $wgLang; |
645 | 648 | if ( "" == $query ) { $q = ""; } |
646 | 649 | else { $q = "{$query}&"; } |
647 | 650 | $q .= "limit={$limit}&offset={$offset}"; |
648 | 651 | |
649 | | - $s = "<a href=\"" . wfLocalUrlE( $link, $q ) . "\">{$limit}</a>"; |
| 652 | + $fmtLimit = $wgLang->formatNum( $limit ); |
| 653 | + $s = "<a href=\"" . wfLocalUrlE( $link, $q ) . "\">{$fmtLimit}</a>"; |
650 | 654 | return $s; |
651 | 655 | } |
652 | 656 | |
Index: trunk/phase3/includes/SpecialStatistics.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | function wfSpecialStatistics() |
5 | 5 | { |
6 | | - global $wgUser, $wgOut; |
| 6 | + global $wgUser, $wgOut, $wgLang; |
7 | 7 | $fname = "wfSpecialStatistics"; |
8 | 8 | |
9 | 9 | $wgOut->addHTML( "<h2>" . wfMsg( "sitestats" ) . "</h2>\n" ); |
— | — | @@ -21,9 +21,12 @@ |
22 | 22 | $good = $row->ss_good_articles; |
23 | 23 | |
24 | 24 | $text = wfMsg( "sitestatstext", |
25 | | - $total, $good, $views, $edits, |
26 | | - sprintf( "%.2f", $total ? $edits / $total : 0 ), |
27 | | - sprintf( "%.2f", $edits ? $views / $edits : 0 ) ); |
| 25 | + $wgLang->formatNum( $total ), |
| 26 | + $wgLang->formatNum( $good ), |
| 27 | + $wgLang->formatNum( $views ), |
| 28 | + $wgLang->formatNum( $edits ), |
| 29 | + $wgLang->formatNum( sprintf( "%.2f", $total ? $edits / $total : 0 ) ), |
| 30 | + $wgLang->formatNum( sprintf( "%.2f", $edits ? $views / $edits : 0 ) ) ); |
28 | 31 | |
29 | 32 | $wgOut->addHTML( $text ); |
30 | 33 | $wgOut->addHTML( "<h2>" . wfMsg( "userstats" ) . "</h2>\n" ); |
— | — | @@ -42,7 +45,9 @@ |
43 | 46 | $sk = $wgUser->getSkin(); |
44 | 47 | $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" ); |
45 | 48 | |
46 | | - $text = wfMsg( "userstatstext", $total, $admins, $ap ); |
| 49 | + $text = wfMsg( "userstatstext", |
| 50 | + $wgLang->formatNum( $total ), |
| 51 | + $wgLang->formatNum( $admins ), $ap ); |
47 | 52 | $wgOut->addHTML( $text ); |
48 | 53 | } |
49 | 54 | |
Index: trunk/phase3/includes/SpecialPopularpages.php |
— | — | @@ -19,8 +19,9 @@ |
20 | 20 | } |
21 | 21 | |
22 | 22 | function formatResult( $skin, $result ) { |
| 23 | + global $wgLang; |
23 | 24 | $link = $skin->makeKnownLink( $result->cur_title, "" ); |
24 | | - $nv = wfMsg( "nviews", $result->cur_counter ); |
| 25 | + $nv = wfMsg( "nviews", $wgLang->formatNum( $result->cur_counter ) ); |
25 | 26 | return "{$link} ({$nv})"; |
26 | 27 | } |
27 | 28 | } |
Index: trunk/phase3/includes/SpecialRecentchanges.php |
— | — | @@ -104,10 +104,10 @@ |
105 | 105 | } |
106 | 106 | |
107 | 107 | if(isset($from)) { |
108 | | - $note = wfMsg( "rcnotefrom", $limit, |
| 108 | + $note = wfMsg( "rcnotefrom", $wgLang->formatNum( $limit ), |
109 | 109 | $wgLang->timeanddate( $from, true ) ); |
110 | 110 | } else { |
111 | | - $note = wfMsg( "rcnote", $limit, $days ); |
| 111 | + $note = wfMsg( "rcnote", $wgLang->formatNum( $limit ), $wgLang->formatNum( $days ) ); |
112 | 112 | } |
113 | 113 | $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" ); |
114 | 114 | |
— | — | @@ -142,7 +142,7 @@ |
143 | 143 | global $wgUser, $wgLang; |
144 | 144 | $sk = $wgUser->getSkin(); |
145 | 145 | $s = $sk->makeKnownLink( $wgLang->specialPage( $page ), |
146 | | - ($lim ? "{$lim}" : wfMsg( "all" ) ), "{$more}" . |
| 146 | + ($lim ? $wgLang->formatNum( "{$lim}" ) : wfMsg( "all" ) ), "{$more}" . |
147 | 147 | ($d ? "days={$d}&" : "") . "limit={$lim}" ); |
148 | 148 | return $s; |
149 | 149 | } |
— | — | @@ -152,7 +152,7 @@ |
153 | 153 | global $wgUser, $wgLang; |
154 | 154 | $sk = $wgUser->getSkin(); |
155 | 155 | $s = $sk->makeKnownLink( $wgLang->specialPage( $page ), |
156 | | - ($d ? "{$d}" : wfMsg( "all" ) ), "{$more}days={$d}" . |
| 156 | + ($d ? $wgLang->formatNum( "{$d}" ) : wfMsg( "all" ) ), "{$more}days={$d}" . |
157 | 157 | ($lim ? "&limit={$lim}" : "") ); |
158 | 158 | return $s; |
159 | 159 | } |
Index: trunk/phase3/includes/SpecialLongpages.php |
— | — | @@ -19,7 +19,8 @@ |
20 | 20 | } |
21 | 21 | |
22 | 22 | function formatResult( $skin, $result ) { |
23 | | - $nb = wfMsg( "nbytes", $result->len ); |
| 23 | + global $wgLang; |
| 24 | + $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->len ) ); |
24 | 25 | $link = $skin->makeKnownLink( $result->cur_title, "" ); |
25 | 26 | return "{$link} ({$nb})"; |
26 | 27 | } |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -668,7 +668,7 @@ |
669 | 669 | if ( $wgDisableCounters ) { |
670 | 670 | $s = ""; |
671 | 671 | } else { |
672 | | - $count = $wgArticle->getCount(); |
| 672 | + $count = $wgLang->formatNum( $wgArticle->getCount() ); |
673 | 673 | $s = wfMsg( "viewcount", $count ); |
674 | 674 | } |
675 | 675 | $s .= $this->lastModified(); |
Index: trunk/phase3/includes/SpecialShortpages.php |
— | — | @@ -19,7 +19,8 @@ |
20 | 20 | } |
21 | 21 | |
22 | 22 | function formatResult( $skin, $result ) { |
23 | | - $nb = wfMsg( "nbytes", $result->len ); |
| 23 | + global $wgLang; |
| 24 | + $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->len ) ); |
24 | 25 | $link = $skin->makeKnownLink( $result->cur_title, "" ); |
25 | 26 | return "{$link} ({$nb})"; |
26 | 27 | } |
Index: trunk/phase3/includes/SpecialWatchlist.php |
— | — | @@ -89,7 +89,7 @@ |
90 | 90 | } |
91 | 91 | |
92 | 92 | if(isset($_REQUEST['magic'])) { |
93 | | - $wgOut->addHTML( wfMsg( "watchlistcontains", $nitems ) . |
| 93 | + $wgOut->addHTML( wfMsg( "watchlistcontains", $wgLang->formatNum( $nitems ) ) . |
94 | 94 | "<p>" . wfMsg( "watcheditlist" ) . "</p>\n" ); |
95 | 95 | |
96 | 96 | $wgOut->addHTML( "<form action='" . |
— | — | @@ -133,7 +133,8 @@ |
134 | 134 | } |
135 | 135 | |
136 | 136 | |
137 | | - $wgOut->addHTML( "<i>" . wfMsg( "watchdetails", $nitems, $npages, $y, |
| 137 | + $wgOut->addHTML( "<i>" . wfMsg( "watchdetails", |
| 138 | + $wgLang->formatNum( $nitems ), $wgLang->formatNum( $npages ), $y, |
138 | 139 | $specialTitle->getURL( "magic=yes", true ) ) . "</i><br>\n" ); |
139 | 140 | |
140 | 141 | |
— | — | @@ -151,9 +152,9 @@ |
152 | 153 | $res = wfQuery( $sql, DB_READ, $fname ); |
153 | 154 | |
154 | 155 | if($days >= 1) |
155 | | - $note = wfMsg( "rcnote", $limit, $days ); |
| 156 | + $note = wfMsg( "rcnote", $wgLang->formatNum( $limit ), $wgLang->formatNum( $days ) ); |
156 | 157 | elseif($days > 0) |
157 | | - $note = wfMsg( "wlnote", $limit, round($days*24) ); |
| 158 | + $note = wfMsg( "wlnote", $wgLang->formatNum( $limit ), $wgLang->formatNum( round($days*24) ) ); |
158 | 159 | else |
159 | 160 | $note = ""; |
160 | 161 | $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" ); |
— | — | @@ -189,7 +190,8 @@ |
190 | 191 | $sk = $wgUser->getSkin(); |
191 | 192 | $s = $sk->makeKnownLink( |
192 | 193 | $wgLang->specialPage( $page ), |
193 | | - $h, "days=" . ($h / 24.0) ); |
| 194 | + $wgLang->formatNum( $h ), |
| 195 | + "days=" . ($h / 24.0) ); |
194 | 196 | return $s; |
195 | 197 | } |
196 | 198 | |
— | — | @@ -199,7 +201,7 @@ |
200 | 202 | $sk = $wgUser->getSkin(); |
201 | 203 | $s = $sk->makeKnownLink( |
202 | 204 | $wgLang->specialPage( $page ), |
203 | | - ($d ? $d : wfMsg( "all" ) ), "days=$d" ); |
| 205 | + ($d ? $wgLang->formatNum( $d ) : wfMsg( "all" ) ), "days=$d" ); |
204 | 206 | return $s; |
205 | 207 | } |
206 | 208 | |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -1560,23 +1560,15 @@ |
1561 | 1561 | $datePreference = $wgAmericanDates ? 1 : 2; |
1562 | 1562 | } |
1563 | 1563 | |
1564 | | - if ( $datePreference == 1 ) { |
1565 | | - # MDY |
1566 | | - $d = $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) . |
1567 | | - " " . (0 + substr( $ts, 6, 2 )) . ", " . |
1568 | | - substr( $ts, 0, 4 ); |
1569 | | - } else if ( $datePreference == 2 ) { |
1570 | | - #DMY |
1571 | | - $d = (0 + substr( $ts, 6, 2 )) . " " . |
1572 | | - $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) . " " . |
1573 | | - substr( $ts, 0, 4 ); |
1574 | | - } else { |
1575 | | - #YMD |
1576 | | - $d = substr( $ts, 0, 4 ) . " " . $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) . |
1577 | | - " " . (0 + substr( $ts, 6, 2 )); |
| 1564 | + $month = $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ); |
| 1565 | + $day = $this->formatNum( 0 + substr( $ts, 6, 2 ) ); |
| 1566 | + $year = $this->formatNum( substr( $ts, 0, 4 ) ); |
| 1567 | + |
| 1568 | + switch( $datePreference ) { |
| 1569 | + case 1: return "$month $day, $year"; |
| 1570 | + case 2: return "$day $month $year"; |
| 1571 | + default: return "$year $month $day"; |
1578 | 1572 | } |
1579 | | - |
1580 | | - return $d; |
1581 | 1573 | } |
1582 | 1574 | |
1583 | 1575 | function time( $ts, $adj = false ) |
— | — | @@ -1584,7 +1576,7 @@ |
1585 | 1577 | if ( $adj ) { $ts = $this->userAdjust( $ts ); } |
1586 | 1578 | |
1587 | 1579 | $t = substr( $ts, 8, 2 ) . ":" . substr( $ts, 10, 2 ); |
1588 | | - return $t; |
| 1580 | + return $this->formatNum( $t ); |
1589 | 1581 | } |
1590 | 1582 | |
1591 | 1583 | function timeanddate( $ts, $adj = false ) |
— | — | @@ -1748,6 +1740,13 @@ |
1749 | 1741 | { |
1750 | 1742 | return NULL; |
1751 | 1743 | } |
| 1744 | + |
| 1745 | + # Normally we use the plain ASCII digits. Some languages such as Arabic will |
| 1746 | + # want to output numbers using script-appropriate characters: override this |
| 1747 | + # function with a translator. See LanguageAr.php for an example. |
| 1748 | + function formatNum( $number ) { |
| 1749 | + return $number; |
| 1750 | + } |
1752 | 1751 | |
1753 | 1752 | } |
1754 | 1753 | |
Index: trunk/phase3/languages/LanguageAr.php |
— | — | @@ -3,18 +3,18 @@ |
4 | 4 | include_once("LanguageUtf8.php"); |
5 | 5 | |
6 | 6 | /* private */ $wgNamespaceNamesAr = array( |
7 | | - "-2" => "ملف", |
8 | | - "-1" => "خاص", |
9 | | - "0" => "", |
10 | | - "1" => "نقاش", |
11 | | - "2" => "مستخدم", |
12 | | - "3" => "نقاش_المستخدم", |
13 | | - "4" => "ويكيبيديا", |
14 | | - "5" => "ويكيبيديا_نقاش", |
15 | | - "6" => "صورة", |
16 | | - "7" => "نقاش_الصورة", |
17 | | - "8" => "MediaWiki", |
18 | | - "9" => "MediaWiki_talk", |
| 7 | + -2 => "ملف", |
| 8 | + -1 => "خاص", |
| 9 | + 0 => "", |
| 10 | + 1 => "نقاش", |
| 11 | + 2 => "مستخدم", |
| 12 | + 3 => "نقاش_المستخدم", |
| 13 | + 4 => "ويكيبيديا", |
| 14 | + 5 => "ويكيبيديا_نقاش", |
| 15 | + 6 => "صورة", |
| 16 | + 7 => "نقاش_الصورة", |
| 17 | + 8 => "MediaWiki", |
| 18 | + 9 => "MediaWiki_talk", |
19 | 19 | ); |
20 | 20 | |
21 | 21 | /* private */ $wgWeekdayNamesAr = array( |
— | — | @@ -29,6 +29,22 @@ |
30 | 30 | ); |
31 | 31 | |
32 | 32 | class LanguageAr extends LanguageUtf8 { |
| 33 | + var $digitTransTable = array( |
| 34 | + "0" => "٠", |
| 35 | + "1" => "١", |
| 36 | + "2" => "٢", |
| 37 | + "3" => "٣", |
| 38 | + "4" => "٤", |
| 39 | + "5" => "٥", |
| 40 | + "6" => "٦", |
| 41 | + "7" => "٧", |
| 42 | + "8" => "٨", |
| 43 | + "9" => "٩", |
| 44 | + "%" => "٪", |
| 45 | + "." => "٫", |
| 46 | + "," => "٬" |
| 47 | + ); |
| 48 | + |
33 | 49 | # TODO: TRANSLATION! |
34 | 50 | |
35 | 51 | # Inherit everything except... |
— | — | @@ -101,7 +117,10 @@ |
102 | 118 | |
103 | 119 | return $s; |
104 | 120 | } |
105 | | - |
| 121 | + |
| 122 | + function formatNum( $number ) { |
| 123 | + return strtr( $number, $this->digitTransTable ); |
| 124 | + } |
106 | 125 | } |
107 | 126 | |
108 | 127 | ?> |