开发者

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜