How to convert a word to its plural form based on quantity in the Anqi CMS template?
pluralize
A filter can convert a word into a plural form based on the quantity.
How to use
pluralize
How to use filters:
{{ obj|pluralize:"复数附加词" }}
pluralize
Specify the current quantity and add the plural form of the word. Supports 0 to 2 words, use both words when there are 2.,
Separate.
for examplecustomer
, you can write it like this:
customer{{ 1|pluralize }}
# 显示结果
customer
Sample Demo
customer{{ 0|pluralize }}
customer{{ 1|pluralize }}
customer{{ 2|pluralize }}
cherr{{ 0|pluralize:"y,ies" }}
cherr{{ 1|pluralize:"y,ies" }}
cherr{{ 2|pluralize:"y,ies" }}
walrus{{ 0|pluralize:"es" }}
walrus{{ 1|pluralize:"es" }}
walrus{{ simple.number|pluralize:"es" }}
# 显示结果
customers
customer
customers
cherries
cherry
cherries
walruses
walrus
walruses