Skip to content
ember-inflector goal is to be rails compatible.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
addon Drop String extension support Sep 5, 2018
app/helpers
config
tests Drop String extension support Sep 5, 2018
vendor
.bowerrc
.editorconfig
.ember-cli
.eslintignore upgrades Apr 30, 2018
.eslintrc.js upgrades Apr 30, 2018
.gitignore
.npmignore upgrades Apr 30, 2018
.travis.yml upgrades Apr 30, 2018
.watchmanconfig
CHANGELOG.md
LICENSE.md
README.md [DOC] Add examples for using uncountable and irregular May 1, 2018
ember-cli-build.js
index.d.ts Add typing definition file. Aug 10, 2017
index.js upgrades Apr 30, 2018
package.json
testem.js upgrades Apr 30, 2018
yarn.lock upgrades Apr 30, 2018

README.md

Ember Inflector Build Status

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.

Installation

ember install ember-inflector

Usage

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

Custom Rules

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');

Template Helpers

pluralize

Pluralize a word

{{pluralize "taco"}} -> tacos

Specify a count with the word, with the pluralization being based on the number of items.

{{pluralize 1 "taco"}} -> 1 taco
{{pluralize 2 "taco"}} -> 2 tacos

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.

{{pluralize 1 "taco" without-count=true}} -> taco
{{pluralize 2 "taco" without-count=true}} -> tacos

singularize

{{singularize 'octopi'}} -> octopus
You can’t perform that action at this time.