Show
Ignore:
Timestamp:
04/17/08 21:48:11 (20 months ago)
Author:
bchoate
Message:

Added support for phrases on count tags. BugId:79359

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-35/php/lib/MTViewer.php

    r1876 r1956  
    456456            return null; 
    457457    } 
     458 
     459    function count_format($count, $args) { 
     460        $phrase = ''; 
     461        if ($count == 0) { 
     462            $phrase = array_key_exists('none', $args) ? $args['none'] : 
     463                (array_key_exists('plural', $args) ? $args['plural'] : ''); 
     464        } elseif ($count == 1) { 
     465            $phrase = array_key_exists('singular', $args) ? $args['singular'] : ''; 
     466        } elseif ($count > 1) { 
     467            $phrase = array_key_exists('plural', $args) ? $args['plural'] : ''; 
     468        } 
     469        if ($phrase == '') 
     470            return $count; 
     471 
     472        // \# of entries: #  --> # of entries: 10 
     473        $phrase = preg_replace('/(?<!\\\\)#/', $count, $phrase); 
     474        $phrase = preg_replace('/\\\\#/', '#', $phrase); 
     475 
     476        return $phrase; 
     477    } 
    458478} 
    459 ?>