From: Brion Vibber Date: Sat, 6 Mar 2004 03:03:14 +0000 (+0000) Subject: Add digit transformation function Language::formatNum() for Arabic and other X-Git-Tag: 1.3.0beta1~862 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=4dac4d85c61f5163bfd703b6252e620f546e652f;p=lhc%2Fweb%2Fwiklou.git Add digit transformation function Language::formatNum() for Arabic and other languages which need to use localized (decimal) digits. Sample implementation for Arabic. --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index bf95d2a83e..8e69807324 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -596,19 +596,22 @@ function wfRecordUpload( $name, $oldver, $size, $desc ) function wfShowingResults( $offset, $limit ) { - return wfMsg( "showingresults", $limit, $offset+1 ); + global $wgLang; + return wfMsg( "showingresults", $wgLang->formatNum( $limit ), $wgLang->formatNum( $offset+1 ) ); } function wfShowingResultsNum( $offset, $limit, $num ) { - return wfMsg( "showingresultsnum", $limit, $offset+1, $num ); + global $wgLang; + return wfMsg( "showingresultsnum", $wgLang->formatNum( $limit ), $wgLang->formatNum( $offset+1 ), $wgLang->formatNum( $num ) ); } function wfViewPrevNext( $offset, $limit, $link, $query = "", $atend = false ) { - global $wgUser; - $prev = wfMsg( "prevn", $limit ); - $next = wfMsg( "nextn", $limit ); + global $wgUser, $wgLang; + $fmtLimit = $wgLang->formatNum( $limit ); + $prev = wfMsg( "prevn", $fmtLimit ); + $next = wfMsg( "nextn", $fmtLimit ); $link = wfUrlencode( $link ); $sk = $wgUser->getSkin(); @@ -640,12 +643,13 @@ function wfViewPrevNext( $offset, $limit, $link, $query = "", $atend = false ) function wfNumLink( $offset, $limit, $link, $query = "" ) { - global $wgUser; + global $wgUser, $wgLang; if ( "" == $query ) { $q = ""; } else { $q = "{$query}&"; } $q .= "limit={$limit}&offset={$offset}"; - $s = "{$limit}"; + $fmtLimit = $wgLang->formatNum( $limit ); + $s = "{$fmtLimit}"; return $s; } diff --git a/includes/Skin.php b/includes/Skin.php index 28d60a6932..bbdeaad9c6 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -668,7 +668,7 @@ class Skin { if ( $wgDisableCounters ) { $s = ""; } else { - $count = $wgArticle->getCount(); + $count = $wgLang->formatNum( $wgArticle->getCount() ); $s = wfMsg( "viewcount", $count ); } $s .= $this->lastModified(); diff --git a/includes/SpecialImagelist.php b/includes/SpecialImagelist.php index d1080362d3..a4e6bf5983 100644 --- a/includes/SpecialImagelist.php +++ b/includes/SpecialImagelist.php @@ -36,7 +36,7 @@ function wfSpecialImagelist() if ( 0 == $limit ) { $lt = wfMsg( "all" ); } else { - $lt = "${limit}"; + $lt = $wgLang->formatNum( "${limit}" ); $sql .= " LIMIT {$limit}"; } $wgOut->addHTML( "

" . wfMsg( "imglegend" ) . "\n" ); @@ -65,7 +65,7 @@ function wfSpecialImagelist() if ( ! $first ) { $fill .= " | "; } $first = false; - $fill .= $sk->makeKnownLink( $here, "{$num}", + $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ), "sort=bysize&limit={$num}" ); } $text = wfMsg( "showlast", $fill, $bysize ); @@ -77,7 +77,7 @@ function wfSpecialImagelist() if ( ! $first ) { $fill .= " | "; } $first = false; - $fill .= $sk->makeKnownLink( $here, $num, + $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ), "sort=bydate&limit={$num}" ); } $text = wfMsg( "showlast", $fill, $bydate ); @@ -94,7 +94,7 @@ function wfSpecialImagelist() $ilink = "{$name}"; - $nb = wfMsg( "nbytes", $s->img_size ); + $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) ); $l = "(" . $sk->makeKnownLink( $wgLang->getNsText( Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) . diff --git a/includes/SpecialLongpages.php b/includes/SpecialLongpages.php index 2a9a1f5fa7..403801d2b2 100644 --- a/includes/SpecialLongpages.php +++ b/includes/SpecialLongpages.php @@ -19,7 +19,8 @@ class LongPagesPage extends QueryPage { } function formatResult( $skin, $result ) { - $nb = wfMsg( "nbytes", $result->len ); + global $wgLang; + $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->len ) ); $link = $skin->makeKnownLink( $result->cur_title, "" ); return "{$link} ({$nb})"; } diff --git a/includes/SpecialNewpages.php b/includes/SpecialNewpages.php index ecd0e62eda..f0dfa2554a 100644 --- a/includes/SpecialNewpages.php +++ b/includes/SpecialNewpages.php @@ -20,13 +20,12 @@ class NewPagesPage extends QueryPage { } function formatResult( $skin, $result ) { - global $wgLang; $u = $result->cur_user; $ut = $result->cur_user_text; - $length = wfmsg( "nbytes", $result->cur_length ); + $length = wfmsg( "nbytes", $wgLang->formatNum( $result->cur_length ) ); $c = wfEscapeHTML( $result->cur_comment ); if ( 0 == $u ) { # not by a logged-in user diff --git a/includes/SpecialPopularpages.php b/includes/SpecialPopularpages.php index 8522b1223f..18dbb0d978 100644 --- a/includes/SpecialPopularpages.php +++ b/includes/SpecialPopularpages.php @@ -19,8 +19,9 @@ class PopularPagesPage extends QueryPage { } function formatResult( $skin, $result ) { + global $wgLang; $link = $skin->makeKnownLink( $result->cur_title, "" ); - $nv = wfMsg( "nviews", $result->cur_counter ); + $nv = wfMsg( "nviews", $wgLang->formatNum( $result->cur_counter ) ); return "{$link} ({$nv})"; } } diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index 0ffba3c734..c356d1ed73 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -104,10 +104,10 @@ function wfSpecialRecentchanges( $par ) } if(isset($from)) { - $note = wfMsg( "rcnotefrom", $limit, + $note = wfMsg( "rcnotefrom", $wgLang->formatNum( $limit ), $wgLang->timeanddate( $from, true ) ); } else { - $note = wfMsg( "rcnote", $limit, $days ); + $note = wfMsg( "rcnote", $wgLang->formatNum( $limit ), $wgLang->formatNum( $days ) ); } $wgOut->addHTML( "\n


\n{$note}\n
" ); @@ -142,7 +142,7 @@ function rcCountLink( $lim, $d, $page="Recentchanges", $more="" ) global $wgUser, $wgLang; $sk = $wgUser->getSkin(); $s = $sk->makeKnownLink( $wgLang->specialPage( $page ), - ($lim ? "{$lim}" : wfMsg( "all" ) ), "{$more}" . + ($lim ? $wgLang->formatNum( "{$lim}" ) : wfMsg( "all" ) ), "{$more}" . ($d ? "days={$d}&" : "") . "limit={$lim}" ); return $s; } @@ -152,7 +152,7 @@ function rcDaysLink( $lim, $d, $page="Recentchanges", $more="" ) global $wgUser, $wgLang; $sk = $wgUser->getSkin(); $s = $sk->makeKnownLink( $wgLang->specialPage( $page ), - ($d ? "{$d}" : wfMsg( "all" ) ), "{$more}days={$d}" . + ($d ? $wgLang->formatNum( "{$d}" ) : wfMsg( "all" ) ), "{$more}days={$d}" . ($lim ? "&limit={$lim}" : "") ); return $s; } diff --git a/includes/SpecialShortpages.php b/includes/SpecialShortpages.php index 2cb6c37890..b9892772e6 100644 --- a/includes/SpecialShortpages.php +++ b/includes/SpecialShortpages.php @@ -19,7 +19,8 @@ class ShortPagesPage extends QueryPage { } function formatResult( $skin, $result ) { - $nb = wfMsg( "nbytes", $result->len ); + global $wgLang; + $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->len ) ); $link = $skin->makeKnownLink( $result->cur_title, "" ); return "{$link} ({$nb})"; } diff --git a/includes/SpecialStatistics.php b/includes/SpecialStatistics.php index f28882a7b4..1a96dcf7f3 100644 --- a/includes/SpecialStatistics.php +++ b/includes/SpecialStatistics.php @@ -2,7 +2,7 @@ function wfSpecialStatistics() { - global $wgUser, $wgOut; + global $wgUser, $wgOut, $wgLang; $fname = "wfSpecialStatistics"; $wgOut->addHTML( "

" . wfMsg( "sitestats" ) . "

\n" ); @@ -21,9 +21,12 @@ function wfSpecialStatistics() $good = $row->ss_good_articles; $text = wfMsg( "sitestatstext", - $total, $good, $views, $edits, - sprintf( "%.2f", $total ? $edits / $total : 0 ), - sprintf( "%.2f", $edits ? $views / $edits : 0 ) ); + $wgLang->formatNum( $total ), + $wgLang->formatNum( $good ), + $wgLang->formatNum( $views ), + $wgLang->formatNum( $edits ), + $wgLang->formatNum( sprintf( "%.2f", $total ? $edits / $total : 0 ) ), + $wgLang->formatNum( sprintf( "%.2f", $edits ? $views / $edits : 0 ) ) ); $wgOut->addHTML( $text ); $wgOut->addHTML( "

" . wfMsg( "userstats" ) . "

\n" ); @@ -42,7 +45,9 @@ function wfSpecialStatistics() $sk = $wgUser->getSkin(); $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" ); - $text = wfMsg( "userstatstext", $total, $admins, $ap ); + $text = wfMsg( "userstatstext", + $wgLang->formatNum( $total ), + $wgLang->formatNum( $admins ), $ap ); $wgOut->addHTML( $text ); } diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index a763e8b477..3dd8806d92 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -89,7 +89,7 @@ function wfSpecialWatchlist() } if(isset($_REQUEST['magic'])) { - $wgOut->addHTML( wfMsg( "watchlistcontains", $nitems ) . + $wgOut->addHTML( wfMsg( "watchlistcontains", $wgLang->formatNum( $nitems ) ) . "

" . wfMsg( "watcheditlist" ) . "

\n" ); $wgOut->addHTML( "