which is supposed to produce "category" if there is exactly one category and "categories" if there are multiple categories.
- There is a better way to handle this, which is to use the ngettext function. Like this::
- ${ngettext("%d category", "%d categories", numtags) % numtags}
By using ngettext it becomes possible to translate the blog into languages where counting is done differently than in English. Which is what I intend to do next.
After migrating this blog to Genshi templates, it seemed like a good idea to get rid of some spaghetti-code which was embedded in the templates. Most of the "logic" in the templates looked something like this:
${numtags} categor#if $numtags == 1#y#else#ies#end if#.
which is supposed to produce "category" if there is exactly one category and "categories" if there are multiple categories.
- There is a better way to handle this, which is to use the ngettext function. Like this::
- ${ngettext("%d category", "%d categories", numtags) % numtags}
By using ngettext it becomes possible to translate the blog into languages where counting is done differently than in English. Which is what I intend to do next.