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

Was it helpful?

Solution

It should work with Business.model_name.human(:count => 2)

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top