Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/bdesham/pluralize

A Liquid filter to make it easy to form correct plurals.
https://github.com/bdesham/pluralize

Last synced: 18 days ago
JSON representation

A Liquid filter to make it easy to form correct plurals.

Lists

README

        

# pluralize

A [Liquid](http://www.liquidmarkup.org/) filter to make it easy to form correct plurals.

At some point, every programmer has had to display a count of objects, like “36 pages” or “1 message”. This Liquid filter makes it easier to form these plurals correctly—no more taking the lazy way out and writing `{{ number }} message(s)`! (Or worse, assuming that the number will be greater than one.)

## Installation

The easiest way to install this plugin is with RubyGems: `gem install liquid_pluralize`.

If you’re using Jekyll, see the Jekyll [documentation on installing plugins](http://jekyllrb.com/docs/plugins/#installing-a-plugin) for more-detailed installation instructions.

## Usage

The sole provided function is `pluralize`. It can be used in one of two ways:

* for regular plurals (where the plural is formed by appending an _s_):

{{ remaining_time | pluralize: "minute" }}

will output “0 minutes”, “1 minute”, “17 minutes”, etc.

* for irregular plurals:

{{ cul_de_sac_list.length | pluralize: "cul-de-sac", "culs-de-sac" }}

will output “0 culs-de-sac”, “1 cul-de-sac”, “17 culs-de-sac”, etc.

## Author

This script was written by [Benjamin Esham](https://esham.io).

This project is [hosted on GitHub](https://github.com/bdesham/pluralize). Please feel free to submit pull requests.

## Version history

The version numbers of this project conform to [Semantic Versioning 2.0](http://semver.org/).

* 1.0.3 (2017-07-19): This Gem works with Liquid 4.x too.
* 1.0.2 (2015-03-06): This Gem works with Liquid 3.x too and the dependencies should reflect that. Thanks to [Aidan Feldman](https://github.com/afeld) for verifying 3.x support and submitting the pull request.
* 1.0.1 (2015-03-04): Correctly handle the number 1 when it is given in string form. Don’t refer to Jekyll in the code itself.
* 1.0.0 (2013-08-20): Initial release.

## License

This project is released into the public domain via the Unlicense, which you can find in the file LICENSE.md.