It should work with Business.model_name.human(:count => 2)
spanish locale in rails - model names
-
30-07-2021 - |
Question
I looked around and it seems that to set pluralization rules for model names you put the following in your locale file
# es.yml
es:
activerecord:
models:
business:
one: Lugar
other: Lugares
However, when the model name is translated in plural, I still get Lugars
instead of Lugares
Not sure what's wrong
Solution
OTHER TIPS
Your problem is that you are mixing up two forms of pluralization of strings in Rails. The first is meant for internal purposes: for naming classes, variables, methods, table names, etc. This is pluralize
, and to make it properly handle exceptions etc. you can define inflections in config/initializers/inflections.rb.
But this type of pluralization is not appropriate for translations. For that, you should use Business.model_name.human(:count => 2)
(as @doesterr suggested), which will reference the locale file for the locale you are in, which is what you want.
For details see this answer.