How to Pluralize and Singularize a Word in Drupal 8

Parent Feed: 

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.

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web