Package detail

ember-inflector

emberjs494.8kMIT6.0.0

The default blueprint for Embroider v2 addons.

ember-addon

readme

Ember Inflector CI

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.

Compatibility

  • Ember.js v3.16 or above
  • Embroider or ember-auto-import v2

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

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

changelog

Changelog

Release (2025-03-12)

ember-inflector 6.0.0 (major)

:boom: Breaking Change

  • ember-inflector
    • #513 Added meta to the uncountable array because "metum" is not a word. (@ErvinSabic)

Committers: 1

Release (2024-10-24)

ember-inflector 5.0.2 (patch)

:house: Internal

  • ember-inflector

Committers: 1

Release (2024-08-05)

ember-inflector 5.0.1 (patch)

:bug: Bug Fix

  • ember-inflector

Committers: 1

Release (2024-07-24)

ember-inflector 5.0.0 (major)

:boom: Breaking Change

  • ember-inflector, test-app

Committers: 1

Release (2024-07-12)

ember-inflector 4.0.3 (patch)

:bug: Bug Fix

  • ember-inflector
    • #505 chore: Drop hidden ember/string dependency (@Techn1x)

:house: Internal

  • ember-inflector
    • #503 start using release-plan (@mansona)
    • #502 Remove yarn and upgrade ember blueprint with ember-cli-update (@mansona)

Committers: 2

v4.0.2 (2021-06-11)

:bug: Bug Fix

  • #372 Remove non-existing defaultRules re-export (@mydea)

Committers: 2

4.0.0 (Dec 3, 2020)

  • switch to GH actions
  • fix and expand TypeScript types
  • Embroider compatibility test scenarios via ember-try
  • upgrade all dependencies (As of dec 3, 2020)
  • update package.json#engines to reflect actually supported node versions (as of Dec 3, 2020)
  • Drop string extension support #154

    The deprecated global access has been removed. If you used to access Emeber.inflector, Ember.String.singularize or Ember.String.pluralize via the window.Ember global, you must now import the module like this instead:

    import { singularize } from 'ember-inflector'
    singularize('cats');
    

    See PR for more details.

  • Document custom rules #149

3.0.0 (May 1, 2018)

2.3.0 (April 20, 2018)

  • Fix deprecation regarding Ember.EXTEND_PROTOTYPES.
  • Add ability to specify count to Inflector.pluralize and {{pluralize.

2.2.0 (March 27, 2018)

  • Fix documentation snippets in README.
  • Fix issue with local CI runs.

2.1.0 (November 11, 2017)

  • Deprecate Ember.Inflector, Ember.String.singularize, Ember.String.pluralize.

2.0.0 (April 22, 2017)

  • Update to use Babel 6
  • Drop support for Node 0.10 and Node 0.12.

1.10.1 (January 9, 2017)

  • [BUGFIX] Return the same output format for defined.amd environments.

1.10.0 (January 3, 2017)

  • Expose the same API (singularize, pluralize) for all UMD consumers

1.9.6 (August 3, 2016)

  • Fix "bonus" inflection. - #108