Genshi pluralisation
Anyone know how I could show entry/entries
as appropriate, in the following fragment of Genshi syntax?
<span py:if="c.page.item_count">
${c.page.item_count} entries.
</span>
开发者_JAVA技巧Thanks!
Not pretty, but should work
<span py:if="c.page.item_count">
${c.page.item_count} ${['entries','entry'][c.page.item_count==1]}.
</span>
or
<span py:if="c.page.item_count">
${c.page.item_count} ${'entry' if c.page.item_count==1 else 'entries'}.
</span>
精彩评论