Pluralization (and singularization)

I found myself yak-shaving pretty deeply into a problem today, wondering why Ember was refusing to pluralize the word "beta" as "betas".

Ultimately I wound up at the list of pluralization rules for ember-inflector. Among them, I found the culprit:

1// ...
2inflect.plural(/(buffal|tomat)o$/i, '\1oes')
3inflect.plural(/([ti])um$/i, '\1a')
4inflect.plural(/([ti])a$/i, '\1a') // <-- This bad fellow here is the problem
5inflect.plural(/sis$/i, "ses")
6inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves')
7// ...

According to that rule, any words ending in "-ta" or "-ia" will remain unchanged when pluralized. Initially, I was a bit confused by that, but then I did some looking up to find examples of such words. Many of them are plural Latin words, such as "blastomata", "bacteria", "branchiata", "media", "data", "trivia", etc. I can see how I would not try to re-pluralize them in English.

However, there are many other words that we use in English that are caught in that rule and I would pluralize, such as "phobia", "fashionista" (and "emberista", "pythonista"), "magnolia", "pitta", "paranoia"… and of course "beta" and "delta". So annoying!

Fortunately, the library does offer a way to add your own pluralization rules, so I ended up just doing that for the words I needed.

It's worth noting that this is not just an Ember gotcha. The ember-inflector package is a direct port from the Ruby ActiveSupport::Inflector, with the same default pluralization rules, so you get the same results if you try this in, say, a Ruby on Rails codebase:

1include ActiveSupport::Inflector
2pluralize("beta") # => "beta"

And it's equally solvable by configuring the library:

1inflections do |i|
2  i.plural "beta", "betas"
4pluralize("beta") # => "betas"

If you are asking "what are these plural and inflection things?", I recommend that you read this article by Vaidehi Joshi, of the basecs podcast fame: Inflections Everywhere: Using ActiveSupport Inflector. It explains why our frameworks need to know some grammar, how they go about it, and why I'm not going to get "betas" added as a special case in these default rule sets.