Modular approach for pluralizing nouns
<p>I think we've all run into the issue before where an app says that there are "1 minutes remaining", or something along those lines. I think this observation is a testament to the fact that many programmers ignore this issue.</p>

<p>In my projects, I've typically done something along these lines to account for pluralizing nouns: </p>

<pre><code>$Count = count($Items);
$Noun = 'minute';
if ($Count != 1)
{
    $Noun .= 's';
}

echo sprintf('There are %u %s remaining.', $Count, $Noun);
</code></pre>

<p>I have a couple issues with this approach:</p>

<ol>
<li>It places the onus on the programmer to do this pluralization check every single time a string needs to be generated, so code can never be reused. </li>
<li>It needlessly bloats the application code and inhibits readability.</li>
<li>It is not generic. The example worked because "minutes" is the plural of "minute". What about "sheep", "ox", or "fungus"?</li>
</ol>

<p>Does anyone have any ideas for a generic, modular approach to solve this problem? I'm ok with there being more than just one answer. </p>

<p>Thanks in advance,<br />
Zach</p>
