The project is in a healthy, maintained state
Pluralize and singularize English words without ActiveSupport. Includes 200+ rules, irregular word handling, uncountable words, and string inflections (camelCase, snake_case, titleize).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

philiprehberger-pluralize

Tests Gem Version License Sponsor

Standalone English pluralization, singularization, and string inflection

Requirements

  • Ruby >= 3.1

Installation

Add to your Gemfile:

gem "philiprehberger-pluralize"

Or install directly:

gem install philiprehberger-pluralize

Usage

require "philiprehberger/pluralize"

Philiprehberger::Pluralize.plural('person')    # => "people"
Philiprehberger::Pluralize.singular('people')  # => "person"
Philiprehberger::Pluralize.count(5, 'item')    # => "5 items"

Custom Irregular Words

Philiprehberger::Pluralize.irregular('radius', 'radii')
Philiprehberger::Pluralize.plural('radius')    # => "radii"
Philiprehberger::Pluralize.singular('radii')   # => "radius"

Uncountable Words

Philiprehberger::Pluralize.uncountable('equipment')
Philiprehberger::Pluralize.plural('equipment')  # => "equipment"

String Inflections

Philiprehberger::Pluralize.camel_case('hello_world')  # => "HelloWorld"
Philiprehberger::Pluralize.snake_case('HelloWorld')    # => "hello_world"
Philiprehberger::Pluralize.titleize('hello_world')     # => "Hello World"
Philiprehberger::Pluralize.humanize('user_id')         # => "User"

API

Method Description
Pluralize.plural(word) Return the plural form of a word
Pluralize.singular(word) Return the singular form of a word
Pluralize.count(n, word) Format a count with the appropriate singular or plural word
Pluralize.irregular(singular, plural) Register a custom irregular singular/plural pair
Pluralize.uncountable(word) Register a word as uncountable
Pluralize.camel_case(str) Convert an underscored or hyphenated string to PascalCase
Pluralize.snake_case(str) Convert a PascalCase or camelCase string to snake_case
Pluralize.titleize(str) Convert an underscored or hyphenated string to Title Case
Pluralize.humanize(str) Convert an underscored string to a human-readable form
Pluralize.reset! Reset all custom irregular and uncountable rules

Development

bundle install
bundle exec rspec
bundle exec rubocop

License

MIT