I cannot figure out how to translate model data in Rails (3.0.1) with I18n.
Example Situation:
I have a form where a registrant selects their sport. The sport select is a dropdown populated by calling:
Sport.all.collect{ |s| [s.name, s.id]}
I’m tempted to naively write:
Sport.all.collect{ |s| [t(s.name), s.id]}
But I don’t see how rails would know to search for names like “Track and Field”. How would I provide the names in different languages? What are best practices for implementing this?
Thanks all!
If
Sportis a model in the database, you’d be better off keeping translations in the database as well. Add alanguagecolumn to your Sport model and populate with