In most languages that I know (English, Dutch), the plural case can be
derived from the singular – modulo a few irregularities e.g. boy/boys,
sheep/sheep, straat/straten, auto/auto’s, etc.
In a great many other languages, however, it is not possible to know the
plural without some additional datum e.g. the genitive singular form.
As implemented, the arity of
pluralize is strictly one. If it were to
permit variable arguments after that single required argument an
enterprising soul might alter the behavior of
pluralize to take those additional data into consideration when
the pluralization. What would the feeling be about changing this
While the applicability of Latin to modern development is dubious, the
fact that there are languages whose plurals can’t be derived from the
nominative has wider applicability. If this idea were deemed to be too
niche merely altering the method’s interface would allow something like
ActiveSupport::CasedLanguage.pluralize(singular, *args) to implement
features for those who desire it.
Let me give more specifics:
in Latin, for example, there are ambiguities around some endings,
particularly a noun ending in ‘us’. Consider ‘dominus’ and ‘currus’.
matching a RegEx on /us$/ would give us dominus -> domini (right) but
currus -> curri (wrong).
Latin students memorize dominus as: ‘dominus, domini (singular
masculine’ and currus as ‘currus, currūs, masculine’. This is how
disambiguate the two.
So, now, how to handle that in ActiveSupport?
It seems like we should be able to say:
‘currus’.pluralize(:la) #=> ‘currūs’
dominus’.pluralize(:la) #=> ‘domini’
But this produces the wrong results, as mentioned above. If pluralize
a second argument of an array we might be able to do something
‘currus’.pluralize(:la, currūs) #=> ‘currūs’
dominus’.pluralize(:la) #=> ‘domini’ - WORKS
‘currus’.pluralize(:la, ‘currūs’) #=> ‘currūs’ - WORKS
This design would also allow me to support the 3rd declension of Latin
verbs which are identified by the genitive not by the nominative.
A list of rules based on the nominative ending will fail to catch this
arx’.pluralize(:la) #=> wtf?
‘arx’.pluralize(:la, ‘arcis’) #=> ‘arces’ - WORKS
It also might allow a gateway to something like
‘arx’.pluralize(:la, ‘arcis’, :ablative) # => ‘arcibus’