6.0.0 • Published 3 months ago

ember-inflector v6.0.0

Weekly downloads
172,193
License
MIT
Repository
github
Last release
3 months ago

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.

6.0.0

3 months ago

5.0.2

8 months ago

5.0.1

11 months ago

5.0.0

11 months ago

4.0.3

12 months ago

4.0.2

4 years ago

4.0.1

5 years ago

3.0.1

6 years ago

3.0.0

7 years ago

2.3.0

7 years ago

2.2.0

7 years ago

2.1.0

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.12.1

8 years ago

1.12.0

8 years ago

1.11.0

8 years ago

1.10.0

8 years ago

1.9.6

9 years ago

1.9.5

9 years ago

1.9.4

10 years ago

1.9.3

10 years ago

1.9.2

10 years ago

1.9.1

10 years ago

1.9.0

10 years ago

1.7.0

10 years ago

1.6.2

10 years ago

1.6.1

10 years ago

1.6.0

10 years ago

1.5.1

10 years ago

1.5.0

10 years ago

1.3.1

11 years ago

1.3.0

11 years ago