Index: branches/release-35/php/lib/function.mtentryscorecount.php
===================================================================
--- branches/release-35/php/lib/function.mtentryscorecount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtentryscorecount.php (revision 1956)
@@ -9,5 +9,5 @@
 
 function smarty_function_mtentryscorecount($args, &$ctx) {
-    return hdlr_score_count($ctx, 'entry', $args['namespace']);
+    $count = hdlr_score_count($ctx, 'entry', $args['namespace']);
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtblogentrycount.php
===================================================================
--- branches/release-35/php/lib/function.mtblogentrycount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtblogentrycount.php (revision 1956)
@@ -11,5 +11,4 @@
     $args['blog_id'] = $ctx->stash('blog_id');
     $count = $ctx->mt->db->blog_entry_count($args);
-    return $count;
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtblogcategorycount.php
===================================================================
--- branches/release-35/php/lib/function.mtblogcategorycount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtblogcategorycount.php (revision 1956)
@@ -11,5 +11,4 @@
     $args['blog_id'] = $ctx->stash('blog_id');
     $count = $ctx->mt->db->blog_category_count($args);
-    return $count;
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtauthorscorecount.php
===================================================================
--- branches/release-35/php/lib/function.mtauthorscorecount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtauthorscorecount.php (revision 1956)
@@ -9,6 +9,5 @@
 
 function smarty_function_mtauthorscorecount($args, &$ctx) {
-    return hdlr_score_count($ctx, 'author', $args['namespace']);
+    $count = hdlr_score_count($ctx, 'author', $args['namespace']);
+    return $ctx->count_format($count, $args);
 }
-?>
-
Index: branches/release-35/php/lib/function.mtassetscorecount.php
===================================================================
--- branches/release-35/php/lib/function.mtassetscorecount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtassetscorecount.php (revision 1956)
@@ -9,6 +9,5 @@
 
 function smarty_function_mtassetscorecount($args, &$ctx) {
-    return hdlr_score_count($ctx, 'asset', $args['namespace']);
+    $count = hdlr_score_count($ctx, 'asset', $args['namespace']);
+    return $ctx->count_format($count, $args);
 }
-?>
-
Index: branches/release-35/php/lib/function.mttagcount.php
===================================================================
--- branches/release-35/php/lib/function.mttagcount.php (revision 1174)
+++ branches/release-35/php/lib/function.mttagcount.php (revision 1956)
@@ -8,10 +8,7 @@
 function smarty_function_mttagcount($args, &$ctx) {
     $tag = $ctx->stash('Tag');
-    if (!$tag) return '';
-    if (is_array($tag)) {
-        return $tag['tag_count'];
-    } else {
-        return 0;
-    }
+    $count = 0;
+    if ($tag && is_array($tag))
+        $count = $tag['tag_count'];
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtcommentscorecount.php
===================================================================
--- branches/release-35/php/lib/function.mtcommentscorecount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtcommentscorecount.php (revision 1956)
@@ -9,5 +9,5 @@
 
 function smarty_function_mtcommentscorecount($args, &$ctx) {
-    return hdlr_score_count($ctx, 'comment', $args['namespace']);
+    $count = hdlr_score_count($ctx, 'comment', $args['namespace']);
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtpingscorecount.php
===================================================================
--- branches/release-35/php/lib/function.mtpingscorecount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtpingscorecount.php (revision 1956)
@@ -9,5 +9,5 @@
 
 function smarty_function_mtpingscorecount($args, &$ctx) {
-    return hdlr_score_count($ctx, 'tbping', $args['namespace']);
+    $count = hdlr_score_count($ctx, 'tbping', $args['namespace']);
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtcategorycommentcount.php
===================================================================
--- branches/release-35/php/lib/function.mtcategorycommentcount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtcategorycommentcount.php (revision 1956)
@@ -11,6 +11,8 @@
     $category = $ctx->stash('category');
     $cat_id = (int)$category['category_id'];
-    if (!$cat_id) return 0;
-    return $db->category_comment_count(array( 'category_id' => $cat_id ));
+    $count = 0;
+    if ($cat_id) {
+        $count = $db->category_comment_count(array( 'category_id' => $cat_id ));
+    }
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtentrytrackbackcount.php
===================================================================
--- branches/release-35/php/lib/function.mtentrytrackbackcount.php (revision 1583)
+++ branches/release-35/php/lib/function.mtentrytrackbackcount.php (revision 1956)
@@ -8,5 +8,5 @@
 function smarty_function_mtentrytrackbackcount($args, &$ctx) {
     $entry = $ctx->stash('entry');
-    return $entry['entry_ping_count'];
+    $count = $entry['entry_ping_count'];
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtblogpagecount.php
===================================================================
--- branches/release-35/php/lib/function.mtblogpagecount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtblogpagecount.php (revision 1956)
@@ -13,3 +13,2 @@
     return smarty_function_mtblogentrycount($args, $ctx);
 }
-?>
Index: branches/release-35/php/lib/function.mtcategorytrackbackcount.php
===================================================================
--- branches/release-35/php/lib/function.mtcategorytrackbackcount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtcategorytrackbackcount.php (revision 1956)
@@ -9,5 +9,5 @@
     $cat = $ctx->stash('category');
     $cat_id = $cat['category_id'];
-    return $ctx->mt->db->category_ping_count($cat_id);
+    $count = $ctx->mt->db->category_ping_count($cat_id);
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtblogpingcount.php
===================================================================
--- branches/release-35/php/lib/function.mtblogpingcount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtblogpingcount.php (revision 1956)
@@ -8,5 +8,5 @@
 function smarty_function_mtblogpingcount($args, &$ctx) {
     $args['blog_id'] = $ctx->stash('blog_id');
-    return $ctx->mt->db->blog_ping_count($args);
+    $count = $ctx->mt->db->blog_ping_count($args);
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtassetcount.php
===================================================================
--- branches/release-35/php/lib/function.mtassetcount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtassetcount.php (revision 1956)
@@ -9,4 +9,4 @@
     $args['blog_id'] = $ctx->stash('blog_id');
     $count = $ctx->mt->db->asset_count($args);
-    return $count;
+    return $ctx->count_format($count, $args);
 }
Index: branches/release-35/php/lib/MTViewer.php
===================================================================
--- branches/release-35/php/lib/MTViewer.php (revision 1876)
+++ branches/release-35/php/lib/MTViewer.php (revision 1956)
@@ -456,4 +456,23 @@
             return null;
     }
+
+    function count_format($count, $args) {
+        $phrase = '';
+        if ($count == 0) {
+            $phrase = array_key_exists('none', $args) ? $args['none'] :
+                (array_key_exists('plural', $args) ? $args['plural'] : '');
+        } elseif ($count == 1) {
+            $phrase = array_key_exists('singular', $args) ? $args['singular'] : '';
+        } elseif ($count > 1) {
+            $phrase = array_key_exists('plural', $args) ? $args['plural'] : '';
+        }
+        if ($phrase == '')
+            return $count;
+
+        // \# of entries: #  --> # of entries: 10
+        $phrase = preg_replace('/(?<!\\\\)#/', $count, $phrase);
+        $phrase = preg_replace('/\\\\#/', '#', $phrase);
+
+        return $phrase;
+    }
 }
-?>
Index: branches/release-35/php/lib/function.mtblogcommentcount.php
===================================================================
--- branches/release-35/php/lib/function.mtblogcommentcount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtblogcommentcount.php (revision 1956)
@@ -8,5 +8,5 @@
 function smarty_function_mtblogcommentcount($args, &$ctx) {
     $args['blog_id'] = $ctx->stash('blog_id');
-    return $ctx->mt->db->blog_comment_count($args);
+    $count = $ctx->mt->db->blog_comment_count($args);
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtentriescount.php
===================================================================
--- branches/release-35/php/lib/function.mtentriescount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtentriescount.php (revision 1956)
@@ -10,5 +10,5 @@
         return $ctx->tag('MTCategoryCount', $args);
     } elseif ($count = $ctx->stash('archive_count')) {
-        return $count;
+        # $count is set
     } else {
         $entries = $ctx->stash('entries');
@@ -21,8 +21,8 @@
         $lastn = $ctx->stash('_entries_lastn');
         if ($lastn && $lastn <= count($entries))
-            return $lastn;
+            $count = $lastn;
         else
-            return count($entries);
+            $count = count($entries);
     }
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtarchivecount.php
===================================================================
--- branches/release-35/php/lib/function.mtarchivecount.php (revision 1766)
+++ branches/release-35/php/lib/function.mtarchivecount.php (revision 1956)
@@ -14,11 +14,12 @@
         $archiver = $_archivers[$at];
     }
+    $count = 0;
     if ((!isset($archiver) && $ctx->stash('inside_mt_categories')) ||
         ($ctx->stash('inside_mt_categories') && !$archiver->is_date_based())) {
         return $ctx->tag('MTCategoryCount', $args);
     } elseif ($count = $ctx->stash('archive_count')) {
-        return $count;
+        # $count is set
     } elseif ($entries = $ctx->stash('entries')) {
-        return count($entries);
+        $count = count($entries);
     } else {
         $eargs = array();
@@ -38,8 +39,7 @@
             $eargs['lastn'] = -1;
             $entries =& $ctx->mt->db->fetch_entries($eargs);
-            return count($entries);
+            $count = count($entries);
         }
     }
-    return 0;
+    $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtentrycommentcount.php
===================================================================
--- branches/release-35/php/lib/function.mtentrycommentcount.php (revision 1583)
+++ branches/release-35/php/lib/function.mtentrycommentcount.php (revision 1956)
@@ -8,5 +8,5 @@
 function smarty_function_mtentrycommentcount($args, &$ctx) {
     $entry = $ctx->stash('entry');
-    return $entry['entry_comment_count'];
+    $count = $entry['entry_comment_count'];
+    return $ctx->count_format($count, $args);
 }
-?>
Index: branches/release-35/php/lib/function.mtfoldercount.php
===================================================================
--- branches/release-35/php/lib/function.mtfoldercount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtfoldercount.php (revision 1956)
@@ -10,3 +10,2 @@
     return smarty_function_mtcategorycount($args, $ctx);
 }
-?>
Index: branches/release-35/php/lib/function.mtcategorycount.php
===================================================================
--- branches/release-35/php/lib/function.mtcategorycount.php (revision 1174)
+++ branches/release-35/php/lib/function.mtcategorycount.php (revision 1956)
@@ -8,5 +8,5 @@
 function smarty_function_mtcategorycount($args, &$ctx) {
     $category = $ctx->stash('category');
-    return $category['category_count'];
+    $count = $category['category_count'];
+    return $ctx->count_format($count, $args);
 }
-?>
