2017 © Pedro Peláez
 

library twig-pluralize-extension

Twig extension to output correctly pluralized strings

image

vanpattenmedia/twig-pluralize-extension

Twig extension to output correctly pluralized strings

  • Monday, September 12, 2016
  • by vanpattenmedia
  • Repository
  • 2 Watchers
  • 3 Stars
  • 911 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 30 % Grown

The README.md

Twig Pluralize

A simple extension for Twig that allows you to pluralize a given string., (*1)

Usage

Register the function, then reference it in your template:, (*2)

This section has {{pluralize(categories|length, 'one category', '%d categories', 'no categories')}}.

Given the values 0, 1, and 5, the above would output:, (*3)

0: This section has no categories.
1: This section has one category.
5: This section has 5 categories.

The last parameter (the "zero items" string) is optional. If omitted, the 3rd parameter (the "many items" string) will be used, as in the following:, (*4)

This section has {{pluralize(categories|length, 'one category', '%d categories')}}.
0: This section has 0 categories.
1: This section has one category.
5: This section has 5 categories.

The strings are passed through sprintf. You can use the %d token to insert the count into your string, if desired., (*5)

About Tomodomo

Tomodomo is a creative agency for magazine publishers. We use custom design and technology to speed up your editorial workflow, engage your readers, and build sustainable subscription revenue for your business., (*6)

Learn more at tomodomo.co or email us: hello@tomodomo.co, (*7)

License & Conduct

This project is licensed under the terms of the MIT License, included in LICENSE.md., (*8)

All open source Tomodomo projects follow a strict code of conduct, included in CODEOFCONDUCT.md. We ask that all contributors adhere to the standards and guidelines in that document., (*9)

Thank you!, (*10)

The Versions

12/09 2016

dev-master

9999999-dev https://www.vanpattenmedia.com/

Twig extension to output correctly pluralized strings

  Sources   Download

BSD-3-Clause

The Requires

 

twig twig extension plural

12/09 2016

v1.0.2

1.0.2.0 https://www.vanpattenmedia.com/

Twig extension to output correctly pluralized strings

  Sources   Download

BSD-3-Clause

The Requires

 

twig twig extension plural

10/08 2016

v1.0.1

1.0.1.0 https://www.vanpattenmedia.com/

Twig extension to output correctly pluralized strings

  Sources   Download

BSD-3-Clause

The Requires

 

twig twig extension plural

03/08 2016

v1.0.0

1.0.0.0 https://www.vanpattenmedia.com/

Twig extension to output correctly pluralized strings

  Sources   Download

BSD-3-Clause

The Requires

 

twig twig extension plural