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

Irregular inflector behavior #110

Open
escobera opened this issue Oct 11, 2016 · 4 comments
Open

Irregular inflector behavior #110

escobera opened this issue Oct 11, 2016 · 4 comments

Comments

@escobera
Copy link

Hello there,

I have these rules (among others) in my app.

inflector.irregular('arma-branca', 'armas-brancas');
inflector.irregular('acessorio-arma-branca', 'acessorios-armas-brancas');

With this config I get this result:
selection_006

It seems the second irregular rule is never met, this line looks like the culprit. It checks for the end of the rule, so, strings ending the same way can respond wrongly.

Another thing I notice is that this code makes the irregular declaration order specific. If I invert the order like so:

inflector.irregular('acessorio-arma-branca', 'acessorios-armas-brancas');
inflector.irregular('arma-branca', 'armas-brancas');

I get the right result:
selection_007

Can we make the irregulars check for the whole expression first?

@oskarrough
Copy link

I'm hoping my issue is related. Here's a failed attempt to pluralize human as humans.

inflector.irregular('human', 'humans');
console.log(inflector.pluralize('human')); // --> "humen"

@tomoguisuru
Copy link

I'm having a similar issue but with uncountable
The uncountable rule seems to be applied to anything that has settings in rather than just for the specific instance listed.

Example.

Inflector.inflector.uncountable('settings')
Models
|- settings.js
|- bolo-setting.js

expected behavior
settings is uncountable but bolo-setting is countable

This is causing an issue when I do the following

this.store.query('bolo-setting', { org_id: 1 });

which results in the following error message

Error: Assertion Failed: The response to store.query is expected to be an array but it was a single record. Please wrap your response in an array or usestore.queryRecordto query for a single record.

Removing the Uncountable rule corrects the issue for the bolo-setting model but causes issues for the setting model

I discovered this issue when updating to Ember-CLI 2.9.0 from Ember-CLI 1.13.13 and removing the Ember inflector per the deprecations

@brunowego
Copy link

brunowego commented Mar 23, 2017

Yep, same issue here.

import Inflector from 'ember-inflector';

export function initialize() {
  Inflector.inflector.irregular('human', 'humans'); // FIXME:
}

export default {
  name: 'inflectors',
  initialize
};

On backend:

ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'human', 'humans'
end

@sandstrom
Copy link
Contributor

Is this an inconsistency between this repo and Rails inflector API?

If not, then it's better to use the API to make your own adjustments. The goal of this project is to provide a base-set that mirrors Rails inflector API.

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

5 participants