Forum: Rails I18n Adding Translations for the Model in the Rails application

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
1f051b9b521f8569bd574833f7ed3d42?d=identicon&s=25 Aruna C. (arunajasmine)
on 2010-10-20 13:11
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
465a674b0471ff8c76ae7597c94b075d?d=identicon&s=25 Kad K. (kadoudal)
on 2010-10-21 14:06
(Received via mailing list)
which version of Rails are you using ?  Rails 2 or Rails 3
answer will be different ...
1f051b9b521f8569bd574833f7ed3d42?d=identicon&s=25 Aruna C. (arunajasmine)
on 2010-10-21 14:11
Kad Kerforn wrote in post #956049:
> which version of Rails are you using ?  Rails 2 or Rails 3
> answer will be different ...

Rails 3
shellyroche (Guest)
on 2010-10-21 18:24
(Received via mailing list)
Here's how to set up validation error messages in Rails 3: (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!
B269a661e18295adcd1430e9716bd668?d=identicon&s=25 Henrik -. (malesca)
on 2010-10-21 20:59
(Received via mailing list)
This topic is locked and can not be replied to.