Ember Inflector is a library for inflecting words between plural and singular forms. Ember Inflector aims to be compatible with ActiveSupport::Inflector from Ruby on Rails, including the ability to add your own inflections in your app.
- Ember.js v3.16 or above
- Embroider or ember-auto-import v2
ember install ember-inflector
All methods are always available from the ember-inflector
module:
import Inflector from 'ember-inflector';
import { singularize, pluralize } from 'ember-inflector';
Inflector.inflector.singularize("tacos"); // taco
Inflector.inflector.pluralize("taco"); // tacos
singularize("tacos"); // taco
pluralize("taco"); // tacos
pluralize(2, "taco"); // 2 tacos
pluralize(2, "tacos", { withoutCount: true }); // tacos
If necessary you can setup special inflection rules for your application:
import Inflector from 'ember-inflector';
Inflector.inflector.irregular('person', 'people');
Inflector.inflector.uncountable('sheep');
Pluralize a word
Specify a count with the word, with the pluralization being based on the number of items.
Specify a count with the word, with the pluralization being based on the number of items. Specify without-count=true
to return on the word without the number.
See the Contributing guide for details.
This project is licensed under the MIT License.