Closed dsimard closed 10 years ago
I don't think your code would fix everyone's problem here. Does this help you: http://stackoverflow.com/questions/6166064/i18n-pluralization
The line model_class.model_name.human(count:@broomsticks.size)
will use the default translations for the model name (model_class
would be Broomstick
in our case) specified in the locale file as I wrote earlier.
The line model_class.model_name.human.pluralize
as used in the templates doesn't pluralize it correctly (will return manche à balais with a s at the end of balai).
The line model_class.model_name.human(count:@broomsticks.size)
pluralizes it correctly (will return manches à balai with a s at the end of manche).
I'm sorry if I just rewrote my issue, it's just that I don't understand why you sent me the link above and maybe we don't understand each other well. I just suggested a code change but if there's a better way of doing it, I'm really ok with that...
We couldn't use an instance variable here, that's why I'm gun shy on taking your suggestion here. The gem generates the template with the assumption of english. While I don't disagree with your point, I'm not concerned as its meant to be a scaffolding tool. We'd need something like
model_class.model_name.human(count: model_class.count)
But you still have to add the translation you want and how you want to handle it either through the locales.yml or inflections. We would have to know beforehand what the model is called for it to work, as well as what the proper pluralization of it would be.
In the views generated by scaffold, it would be better to use
count
instead ofpluralize
(see this line : https://github.com/seyhunak/twitter-bootstrap-rails/blob/v2.1.0/lib/generators/bootstrap/themed/templates/index.html.erb#L3).pluralize
doesn't care about the locales. Example, I have thisfr.yml
file :pluralize
will display 'manche à balais' instead of 'manches à balai' as specified in the locale file.The line should be something like :