since rails 2.2 doesn’t work with gettext anymore I decided to use a
gettext dummy method until the gettext team relases a working version
for rails 2.2. My application doesn’t need any i18n support right now
and this way i figured it would be very easy to integrate gettext
later. Just setup the plugin and go.
So I need a method called _ which is available in alle models, views,
controllers, helpers, doing of nothing else then:
def _(str)
str
end
I’m still a newbie so I tried a lot but didn’t come to a good
solution. I just don’t know where to define this method to make it
globally available.
Thanks, I tried that, but it doesnt work. I added to the end of
enviroment.rb the following code:
class Object
def _(s)
s
end
end
I also tried
class ActiveRecord::Base
def _(s)
s
end
end
But I still get a method missing error for:
class Customer < ActiveRecord::Base
validates_inclusion_of :gender, :in => [‘f’, ‘m’],
:allow_blank => true,
:message => _(“Required field cannot be left blank”)
end
but nothing worked. I also looked at the gettext gem and it looks to
me that they just have a module where the _() method is defined and
this module is then required in the enviroment.rb, so I tried that
also but without any luck.
It can’t be that hard to make a method globally available, or can it?