Which way is the best to show message in Controller? Is must showing count articles.
$c = count($articles);
if($c == 0) {
return "On site are 0 articles";
} elseif ($c == 1){
return "On site is 1 article";
} else {
return "On site are" . $c . "articles";
}
or:
if($c == 1) {
$text1 = 'is';
$text2 = 'article'
} else {
$text1 = 'are';
$text2 = 'articles'
}
return "On site" . $text1 . $c . $text2;
Maybe others ways?
You might use an external pluralization class.
A short Google research returned this: http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/
Use it like:
Pretty sure there are other libraries which also pluralize/singularize the verb (is/are).