Sunday, February 28, 2010

1 comments?

For a bit of software with as much development muscle behind it as blogger has, you would think it could distinguish between the number 1 and all the other numbers, then make "comment" singular or not. In fact, here you go blogger folks, the fix in one line:

<?php
$commentLabel = ($numComments == 1) ? "comment" : "comments";
?>

And if you don't use PHP, I know that Java has an equivilant. ASP and C++ ought to, but I don't know. If doing it server-side is a big deal, here's a client-side, Javascript implementation, using my native jQuery:

$('span.comment-link').each(function() {
var numComments = $(this).html().split(" ")[0];
if(parseInt(numComments) == 1) {
$(this).html(numComments + " comment");
}
else {
$(this).html(numComments + " comments");
}
}

That oughtta do it. It's not tested though, so use it at your own risk.

Anyway, I'll be moving development of my book over to my personal blog. My intent was to generate some sort of traffic over here, make something interested that would help people want to come around every so often, but I don't think it quite fits.

All the best to you all,
-Benjamin