Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot remove use of inflector #3873

Closed
jnfingerle opened this issue Oct 20, 2015 · 8 comments
Closed

Cannot remove use of inflector #3873

jnfingerle opened this issue Oct 20, 2015 · 8 comments

Comments

@jnfingerle
Copy link
Contributor

For a project I'm working on, we've decided to not use pluralized forms at all (partly because it doesn't get easier in German, partly because that's what the back end does anyway). I got rid of most of it through the hooks in the RESTAdapter/RESTSerializer.

Unfortunately the inflectors is also used by the store through relationship-meta.js. This is a great way to shoot myself in the foot for german words that the inflector believes to be an english plural form.

What's more, there is no public api to remove rules from the inflector, only to add additional ones.

Now, this is a request for a clean solution using either (a) a hook to replace typeForRelationshipMeta() with my own implementation or (b) a hook to replace the inflector for all things ember-data with my own version.

If there is a blessed way to do this and that I'm missing here, I'd be greatful to be pointed into the right direction.

@bmac
Copy link
Member

bmac commented Dec 22, 2015

@jnfingerle this seems like a reasonable request. Would you have time to implement a patch that supported option b?

@jnfingerle
Copy link
Contributor Author

@bmac Yes, I can give that a try, but I'm on vacation right now, so this will have to wait two weeks before I can start working on it.

@fivetanley
Copy link
Member

@bmac what if the store used the inflector as a service? Just a thought.

@jnfingerle
Copy link
Contributor Author

Back from vacation ...

@fivetanley Could you elaborate on your proposal?

My idea was making the inflector an overwritable property of the store, yet I haven't tried out which walls I might hit on my way.

@pangratz
Copy link
Member

pangratz commented Oct 23, 2016

ping @fivetanley

@RobIsHere
Copy link

I also want to get rid of the inflector. There are about 2500 languages in the world. The inflector works for 0.0004% ;)

I remember that even in english the inflector was a constant source of pain because it produced some unexpected result. What's so bad with always singular?

At the moment I'm trying to get a software done in german. It's hard! Overwriting not only all of ember-data serializer but also all stuff in ember-cli-mirage.

@stefanpenner
Copy link
Member

stefanpenner commented Apr 18, 2017

To disable the inflector, I believe the following (in your app.js) would do the trick

// app.js
Ember.Inflector.inflector = new Ember.Inflector()

@RobIsHere
Copy link

Thank you! It works!

In app.js it must be placed after "loadInitializers(...)". This is the drop-in initializer solution:

At app/initializers/inflector.js

import Ember from "ember";

export function initialize(/* application */) {

    // Disable inflector
    Ember.Inflector.inflector = new Ember.Inflector();
}

export default {
    before: 'ember-data',
    name: 'inflector',
    initialize
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants