Irregular inflector behavior
escobera opened this issue · 4 comments
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:
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');
Can we make the irregulars check for the whole expression first?
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"
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 use
store.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
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
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.