How to Pluralize and Singularize a Word in Drupal 8


Pluralizing and singularizing words got very easy with the inclusion of the Doctrine Inflector class in Drupal 8 core.

use Doctrine\Common\Inflector\Inflector;
$pluralized = Inflector::pluralize($bundle_singular);
$singularized = Inflector::singularize($bundle_singular);

You can read more about the Doctrine Inflector class here.

About the Author

Hi. My name is Jeremiah John. I'm a sf/f writer and activist.

I just completed a dystopian science fiction novel. I run a website which I created that connects farms with churches, mosques, and synagogues to buy fresh vegetables directly and distribute them on a sliding scale to those in need.

In 2003, I spent six months in prison for civil disobedience while working to close the School of the Americas, converting to Christianity, as one does, while I was in the clink.