Adding Translations for the Model in the Rails application

Hi ,

  I am new to ROR . I am trying add translations to my application.

I have added translations for the controllers.

   1.      Where to add translations for models as i am not having

any /config/locales -> models folder ->en.yml file .

   2.  In the model i am having lines like

validates_presence_of :name, :message => “Name cannot be blank!”

If i want to add translations for the ms Name cannot be blank , Shall i
put directly as like

validates_presence_of :name, :message => I18n.t(str_name_notblank)

Please give suggestions

which version of Rails are you using ? Rails 2 or Rails 3
answer will be different …

Kad K. wrote in post #956049:

which version of Rails are you using ? Rails 2 or Rails 3
answer will be different …

Rails 3

Here’s how to set up validation error messages in Rails 3:

http://rails.wordchuck.com/ (click on the “ActiveRecord validation
error messages” link for how-to and code examples)

The example code is .rb not .yml, but you can see how it works.

Hope that helps!
Shelly

Also see Rails Internationalization (I18n) API — Ruby on Rails Guides.