samedi 14 décembre 2019

In Ember, how can I access the custom inflector defined in my initializers?

I'm defining custom inflector rules in app/initializers/custom-inflector-rules like so:

// app/initializers/custom-inflector-rules

import Inflector from 'ember-inflector';

export function initialize(/* application */) {
  const inflector = Inflector.inflector;

  // Tell the inflector that the plural of "campus" is "campuses"
  inflector.irregular('campus', 'campuses');
}

export default {
  name: 'custom-inflector-rules',
  initialize
};

How can I access my initialized inflector with these custom rules within my application?

For example, in a serializer file, I want to be able to call pluralize like so:

import ??? as Inflector from ???

Inflector.inflector.pluralize("campus"); // campuses



Aucun commentaire:

Enregistrer un commentaire