Backlog Request: Liquid "Pluralize" string filter

Request to get the pluralize filter implimented into Treepl.

{% assign itemCount = "3" %}
{{ itemCount | pluralize: 'item', 'items' }}

Output:
3 items

Example from: String filters

Also with the option to use variables ie:

{% assign term = "minute" %}
{% assign terms = "minutes" %}
{% assign time = 50 %}

{% assign prettyTimePlural = time | pluralize: term, terms %}
{% assign prettyTime = time | append: " " | append: prettyTimePlural %}

Output: {{ prettyTime }}
50 Minutes
1 Like

Just out of curiosity, why does the Shopify docs have a note about ā€œEnglish pluralization rulesā€ when you set the singular and plural words in the filter yourself? you could have any 2 terms you like regardless of language.

Or can you use it on a word/string as well? ie:
{{ "day" | pluralize }}
Giving you:
days

Yeah that one struck me as odd as well. maybe there is some hidden functionality in the docs, that we donā€™t see?
If your example was a thing then i guess language would come into it.

I did find this reference which sheds a little more light on it:
Liquid Filters Ā· DocSpring Docs
The plural string isnā€™t required, so it defaults to adding an ā€˜sā€™ā€¦ I guess thatā€™s all.
Anyhooā€¦ I think I look into things too much :rofl:

This filter would be handy to have either way.

Oh that makes senseā€¦ and then you can specify for cases like this when the spelling is different.

"city", "cities"

makes total senseā€¦ ha :slight_smile:

1 Like

Cool - Added here: https://treepl.co/public-backlog-state/request/liquid-pluralize-string-filter