Saturday, September 27, 2008

1 potato, 2 potato...oh, potatoes

No, not a Dan Quayle post.

English has this irksome rule for pluralization that says that "zero" items are treated as plural, leaving "one" item as the only singular. Anyone who has worked in programming for any length of time has dealt with this rule; if you have used a substantial number of programs, you have likely seen one (or more) violate this rule.

Yet, it's pretty simple to implement correctly in every computer language I know. I won't bore you with too much code, but it is often as simple as:
(num == 1 ? sstr = "" : sstr = "s");
itemstr = num + " item" + sstr;
which simply means you put the 's' on the end of "item" in all situations except that for which the number of items is 1.

It is one of those things which is simple enough that, when I see a program that has failed to do it correctly, I grow concerned about the overall quality of the program. At the very least, it suggests to me that the company has little concern for the polish, those finishing touches that make a program a pleasurable experience.

So it's pretty irritating when a program that I use every day hasn't been able to get it right. And that program is...Blogger. That's right, the basis for all the blogspot.com blogs has, at least on some goodly number of their templates, managed not to get this right.

But if you look right now, you'll see that, on humble Androcass, it is correct. And that's because it is quite easy to fix. I finally got bothered enough to open up the code, and I didn't even need the kind of code I listed above. I was so surprised that I went out to the Web to verify that it really was that simple, and it was. Since I like to give credit to those who did the work first, I'll point you to this post, which describes the two modifications very succinctly.

(The odd part is that Blogger does have a provision for treating the two cases differently, so somebody thought of it, but they then failed to execute it and make it right. Strange.)

To augment the instructions, you hit Customize from your blog, then Edit HTML. Under Edit Template, you check Expand Widget Templates. Then follow the instructions, and your blog will look far more professional (unless you really don't care, in which case you're probably already not reading).

I use the Rounders 3 built-in template, but I have seen other Blogger blogs and believe that it's a larger problem than just that template.

No comments:

Clicky Web Analytics