finesse.utilities.text.ngettext

finesse.utilities.text.ngettext(n, fsingle, fplural, sub=True)[source]

Get the singular or plural form of the specified messages based on n.

Simplified version of the Python standard library function gettext.ngettext().

Parameters:
nint

The number to use to decide which form to return.

fsingle, fpluralstr

Single and plural templates.

subbool, optional

Substitute n into the templates. Defaults to True.

Examples

>>> ngettext(1, "{n} item", "{n} items")
'1 item'
>>> ngettext(5, "{n} item", "{n} items")
'5 items'

The template doesn’t have to contain {n}: >>> ngettext(5, “item”, “items”) ‘items’

Setting sub=False turns off substitution: >>> ngettext(5, “{n} item”, “{n} items”, sub=False) ‘{n} items’