-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improve Serializer.pluralize to guess more plurals #919
Conversation
I wonder if in long term, we should rely on an extenral lib, like https://github.com/stefanpenner/ember-inflector/ |
An external lib like @stefanpenner 's inflector is necessary to cover all possibilities. However the amount of code required makes it very difficult for it to be introduced into core, and using an external lib would be the best option. My PR is an attempt to cover as many possibilities as possible with as little amount of code possible. Since Ember.js always aims to reduce as much configuration as possible, I think it would be good to have a smarter pluralization function built into core (although obviously not perfect due to the size limitation). IMO the amount of code added in this PR is small compared to the amount of configuration that will be eliminated. |
This makes sense, ATM this is probably a good compromise. Thanks :) |
Would this work for words that are the same in both the singular and plural form? E.g. "series". Ember does not like it if the singular and plural form are the same. The _pluralizeAliases method barfs out an error.
It gives me the error:
|
Probably a separate issue from this, but I think we need something similar to Rails support for "uncountables". http://markembling.info/2011/06/uncountable-nouns-rails-3-resource-routing |
@teddyzeenny we should collab on this |
I started digging into the issue with uncountable model names and came across a race condition in the serializer. |
I've got hit by this one too ... |
I think we need a true inflector with rules or we will just end up with inconsistencies. |
@stefanpenner agreed, closing this for now, until we come up with a more comprehensive solution; which would probably be based on your inflector. |
@teddyzeenny sounds good. |
I created a PR for the smallest possible fix for the uncountable issue: #940 |
I changed the
pluralize
/singularize
functions to guess more common cases, so we can reduce the need forconfigure('plurals')
to a minimum.Two main things I did:
criterion
,pluralize
can guess the plural forsystem_criterion
y
,s
,x
... etc