On 2013-02-12 15:21, Steven Schveighoffer wrote:
string pluralize(string x, int count)
{
    return count > 1 ? x ~ "s" : x;
}

You mean: return count != 1 ? x ~ "s" : x;
For special cases there could be a third optional argument:

    string pluralize(int count, string sng, string pl="") {
        return count == 1 ? sng : pl.length ? pl : sng ~ "s";
    }
    writeln(pluralize(2, "cat"));
    writeln(pluralize(2, "radius", "radii"));


That's for simple English-only pluralization, before we jump into translations.

Reply via email to