# Gettext in models

**URL:** <https://www.ruby-forum.com/t/gettext-in-models/48376>\
**Category:** Rails\
**Created:** [November 19, 2005, 5:07pm UTC](https://www.ruby-forum.com/t/gettext-in-models/48376 "2005-11-19T17:07:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon.Santoro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@Simon.Santoro](https://www.ruby-forum.com/u/Simon.Santoro)\
**Post date:** [November 19, 2005, 5:07pm UTC](https://www.ruby-forum.com/t/gettext-in-models/48376/1 "2005-11-19T17:07:37Z")

</div>

hello!  
i would like to translate the error messages in my models like this:

class Person \< ActiveRecord::Base  
validates\_presence\_of :name, :message =\> \_(‘Please insert a name’)  
end

but i get  
undefined method `\_’ for Person:Class

why? can i change this behaviour?

btw, it would also be nice if there was a  
ActiveRecord::Errors.full\_messages() without the  
@base.class.human\_attribute\_name(attr), so i would be able to translate  
the whole message.

---

<div class="post-metadata">

**Author:** ![Simon.Santoro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@Simon.Santoro](https://www.ruby-forum.com/u/Simon.Santoro)\
**Post date:** [November 19, 2005, 8:23pm UTC](https://www.ruby-forum.com/t/gettext-in-models/48376/2 "2005-11-19T20:23:29Z")

</div>

Masao M. wrote:

> 

Thank you Masao! For the second time 🙂  
Thanks for being on the list, and thanks for making rgettext

---

<div class="post-metadata">

**Author:** ![Simon.Santoro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@Simon.Santoro](https://www.ruby-forum.com/u/Simon.Santoro)\
**Post date:** [November 19, 2005, 8:19pm UTC](https://www.ruby-forum.com/t/gettext-in-models/48376/3 "2005-11-19T20:19:15Z")

</div>

Hi,

On Sat, 19 Nov 2005 17:04:46 +0100  
Simon S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> why? can i change this behaviour?

# == include GetText::Rails #You can call this on another file once #such as config/environment.rb after requiring #“gettext/rails”. class Article \< ActiveRecord::Base textdomain(“yourapp”) validates\_presence\_of :description, :message =\> \_(‘Please insert a name’) end
