Hi, 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. I would really appreciate your help! Olaf --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn
2008-Nov-17 19:58 UTC
Re: super global dummy method for gettext + rails 2.2
On Nov 17, 2008, at 2:04 PM, Olaf wrote:> Hi, > > 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: >Perhaps it would be acceptable in your situation to do: class Object> def _(str) > str > endend somewhere in your environment.rb or in an initializer. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > > 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. > > I would really appreciate your help! > > Olaf--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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
Any other ideas? What am I doing wrong?
Thanks for your help!
On 17 Nov., 20:58, Rob Biedenharn
<R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org>
wrote:> On Nov 17, 2008, at 2:04 PM, Olaf wrote:> Hi,
>
> > 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:
>
> Perhaps it would be acceptable in your situation to do:
>
> class Object> def _(str)
> > str
> > end
>
> end
>
> somewhere in your environment.rb or in an initializer.
>
> -Rob
>
> Rob Biedenharn http://agileconsultingllc.com
> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
>
>
>
> > 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.
>
> > I would really appreciate your help!
>
> > Olaf
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Rob Biedenharn
2008-Nov-17 21:33 UTC
Re: super global dummy method for gettext + rails 2.2
Try adding
class ActiveRecord::Base
def self._(s)
s
end
end
Since _ will be called as a Class method on Customer at that point.
-Rob
On Nov 17, 2008, at 4:02 PM, Olaf wrote:
>
> 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
>
> Any other ideas? What am I doing wrong?
>
> Thanks for your help!
>
> On 17 Nov., 20:58, Rob Biedenharn
<R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:
>> On Nov 17, 2008, at 2:04 PM, Olaf wrote:> Hi,
>>
>>> 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:
>>
>> Perhaps it would be acceptable in your situation to do:
>>
>> class Object> def _(str)
>>> str
>>> end
>>
>> end
>>
>> somewhere in your environment.rb or in an initializer.
>>
>> -Rob
>>
>> Rob Biedenharn http://agileconsultingllc.com
>> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
>>
>>
>>
>>> 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.
>>
>>> I would really appreciate your help!
>>
>>> Olaf
> >
Rob Biedenharn http://agileconsultingllc.com
Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
+1 513-295-4739
Skype: rob.biedenharn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I tried both
class ActiveRecord::Base
def self._(s)
s
end
end
class Object
def self._(msg)
return msg
end
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?
Thanks for your help!
On 17 Nov., 22:33, Rob Biedenharn
<R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org>
wrote:> Try adding
>
> class ActiveRecord::Base
> def self._(s)
> s
> end
> end
>
> Since _ will be called as a Class method on Customer at that point.
>
> -Rob
>
> On Nov 17, 2008, at 4:02 PM, Olaf wrote:
>
>
>
>
>
> > 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
>
> > Any other ideas? What am I doing wrong?
>
> > Thanks for your help!
>
> > On 17 Nov., 20:58, Rob Biedenharn
<R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:
> >> On Nov 17, 2008, at 2:04 PM, Olaf wrote:> Hi,
>
> >>> 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:
>
> >> Perhaps it would be acceptable in your situation to do:
>
> >> class Object> def _(str)
> >>> str
> >>> end
>
> >> end
>
> >> somewhere in your environment.rb or in an initializer.
>
> >> -Rob
>
> >> Rob Biedenharn http://agileconsultingllc.com
> >> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
>
> >>> 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.
>
> >>> I would really appreciate your help!
>
> >>> Olaf
>
> Rob Biedenharn http://agileconsultingllc.com
> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
> +1 513-295-4739
> Skype: rob.biedenharn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Sorry, my fault, I moved the following code to a file called
config/initializers/gettext_dummy.rb
class Object
def self._(msg)
return msg
end
end
The problem was that the definition was outside the init block in the
enviroment.rb. STUPID! everithing works now! Thanks
On 17 Nov., 23:18, Olaf
<olaf.spaarm...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:> I tried both
>
> class ActiveRecord::Base
> def self._(s)
> s
> end
> end
>
> class Object
> def self._(msg)
> return msg
> end
> 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?
>
> Thanks for your help!
>
> On 17 Nov., 22:33, Rob Biedenharn
<R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:
>
> > Try adding
>
> > class ActiveRecord::Base
> > def self._(s)
> > s
> > end
> > end
>
> > Since _ will be called as a Class method on Customer at that point.
>
> > -Rob
>
> > On Nov 17, 2008, at 4:02 PM, Olaf wrote:
>
> > > 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
>
> > > Any other ideas? What am I doing wrong?
>
> > > Thanks for your help!
>
> > > On 17 Nov., 20:58, Rob Biedenharn
<R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:
> > >> On Nov 17, 2008, at 2:04 PM, Olaf wrote:> Hi,
>
> > >>> 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:
>
> > >> Perhaps it would be acceptable in your situation to do:
>
> > >> class Object> def _(str)
> > >>> str
> > >>> end
>
> > >> end
>
> > >> somewhere in your environment.rb or in an initializer.
>
> > >> -Rob
>
> > >> Rob Biedenharn http://agileconsultingllc.com
> > >> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
>
> > >>> 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.
>
> > >>> I would really appreciate your help!
>
> > >>> Olaf
>
> > Rob Biedenharn http://agileconsultingllc.com
> > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
> > +1 513-295-4739
> > Skype: rob.biedenharn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Rob Biedenharn
2008-Nov-17 22:59 UTC
Re: super global dummy method for gettext + rails 2.2
You probably need both: class ActiveRecord::Base def self._(s); s; end end class Object def _(s); s; end end Together! Not one or the other. You might add other class methods as needed. (FYI, I have no idea what gettext does, but this is just Ruby stuff.) -Rob On Nov 17, 2008, at 5:18 PM, Olaf wrote:> > I tried both > > class ActiveRecord::Base > def self._(s) > s > end > end > > class Object > def self._(msg) > return msg > end > 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? > > Thanks for your help! > > On 17 Nov., 22:33, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote: >> Try adding >> >> class ActiveRecord::Base >> def self._(s) >> s >> end >> end >> >> Since _ will be called as a Class method on Customer at that point. >> >> -Rob >> >> On Nov 17, 2008, at 4:02 PM, Olaf wrote: >> >> >> >> >> >>> 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 >> >>> Any other ideas? What am I doing wrong? >> >>> Thanks for your help! >> >>> On 17 Nov., 20:58, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> >>> wrote: >>>> On Nov 17, 2008, at 2:04 PM, Olaf wrote:> Hi, >> >>>>> 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: >> >>>> Perhaps it would be acceptable in your situation to do: >> >>>> class Object> def _(str) >>>>> str >>>>> end >> >>>> end >> >>>> somewhere in your environment.rb or in an initializer. >> >>>> -Rob >> >>>> Rob Biedenharn http://agileconsultingllc.com >>>> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org >> >>>>> 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. >> >>>>> I would really appreciate your help! >> >>>>> Olaf >> >> Rob Biedenharn http://agileconsultingllc.com >> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org >> +1 513-295-4739 >> Skype: rob.biedenharn > >Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org +1 513-295-4739 Skype: rob.biedenharn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn
2008-Nov-17 23:00 UTC
Re: super global dummy method for gettext + rails 2.2
Glad you figured it out. -Rob On Nov 17, 2008, at 5:44 PM, Olaf wrote:> > Sorry, my fault, I moved the following code to a file called > > config/initializers/gettext_dummy.rb > > class Object > def self._(msg) > return msg > end > end > > The problem was that the definition was outside the init block in the > enviroment.rb. STUPID! everithing works now! Thanks > > On 17 Nov., 23:18, Olaf <olaf.spaarm...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> I tried both >> >> class ActiveRecord::Base >> def self._(s) >> s >> end >> end >> >> class Object >> def self._(msg) >> return msg >> end >> 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? >> >> Thanks for your help! >> >> On 17 Nov., 22:33, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> >> wrote: >> >>> Try adding >> >>> class ActiveRecord::Base >>> def self._(s) >>> s >>> end >>> end >> >>> Since _ will be called as a Class method on Customer at that point. >> >>> -Rob >> >>> On Nov 17, 2008, at 4:02 PM, Olaf wrote: >> >>>> 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 >> >>>> Any other ideas? What am I doing wrong? >> >>>> Thanks for your help! >> >>>> On 17 Nov., 20:58, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> >>>> wrote: >>>>> On Nov 17, 2008, at 2:04 PM, Olaf wrote:> Hi, >> >>>>>> 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: >> >>>>> Perhaps it would be acceptable in your situation to do: >> >>>>> class Object> def _(str) >>>>>> str >>>>>> end >> >>>>> end >> >>>>> somewhere in your environment.rb or in an initializer. >> >>>>> -Rob >> >>>>> Rob Biedenharn http://agileconsultingllc.com >>>>> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org >> >>>>>> 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. >> >>>>>> I would really appreciate your help! >> >>>>>> Olaf >> >>> Rob Biedenharn http://agileconsultingllc.com >>> R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org >>> +1 513-295-4739 >>> Skype: rob.biedenharn > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---