13 lines
399 B
Python
13 lines
399 B
Python
from app import app
|
|
|
|
|
|
@app.template_filter('pluralize')
|
|
def pluralize(count, singular="", plural="s"):
|
|
"""
|
|
Make a noun plural. Meant for templates; use it like this:
|
|
Il y a {{ n }} groupe{{ n | pluralize }}.
|
|
You can specify different suffixes if "s" is not relevant;
|
|
Il y a {{ n }} hibou{{ n | pluralize("", "x") }}.
|
|
"""
|
|
return singular if count <= 1 else plural
|