Hi Im using the newest GetText gem, and Im having problems with classes outside rails, they don''t get translated. For example: I have a class representing access in my app, and it is not a ActiveRecord, just a normal class. When require ''gettext'' and include it in the class, I can use the _('''') methods fine. They get picked upp by rake updatepo. But they dont get translated in my app. I then tried adding the line - bindtextdomain("myapp") but I couldnt get it to work, it claimed there was no such method. What am I doing wrong here? Regards, Albert
Hi Albert, On Tue Feb 28 04:25:15 JST 2006 Albert Ramstedt <soma@home.se> wrote:> Hi > > Im using the newest GetText gem, and Im having problems with classes > outside rails, they don''t get translated. For example: I have a class > representing access in my app, and it is not a ActiveRecord, just a > normal class. When require ''gettext'' and include it in the class, I can > use the _('''') methods fine. They get picked upp by rake updatepo. But > they dont get translated in my app. I then tried adding the line - > bindtextdomain("myapp") but I couldnt get it to work, it claimed there > was no such method. What am I doing wrong here?It may be a bug of Ruby-GetText. I would like to investigate it. Could you send your app or a sample code to me directly?
Hi folks Masao solved the problem I had, and I''ll post the solution here for you: In every module that you need translations add this at the top: helper GetText::Rails include GetText::Rails extend GetText::Rails Then if you do the init_gettext in your application.rb you should be all set. Child classes get the extension automatically, so you only need to edit the ancestor class. In our app, we solve the DRY conundrum by making a module like this: module Translate helper GetText::Rails include GetText::Rails extend GetText::Rails end And include this in every class instead of the three lines above. Minor change, but makes it easier to handle changes in the gettext api. Also, we noticed that ActionMailer::Base dont get the gettext goodies, so include this somewhere to make it join the multilingual club: module ActionMailer #:nodoc: class Base helper GetText::Rails include GetText::Rails extend GetText::Rails end end Regards, Albert / http://albert.delamednoll.se Albert Ramstedt wrote:> Hi > > Im using the newest GetText gem, and Im having problems with classes > outside rails, they don''t get translated. For example: I have a class > representing access in my app, and it is not a ActiveRecord, just a > normal class. When require ''gettext'' and include it in the class, I > can use the _('''') methods fine. They get picked upp by rake updatepo. > But they dont get translated in my app. I then tried adding the line - > bindtextdomain("myapp") but I couldnt get it to work, it claimed there > was no such method. What am I doing wrong here? > > Regards, > Albert > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
Hi Albert, On Thu, 02 Mar 2006 14:11:09 +0100 Albert Ramstedt <soma@home.se> wrote:> Hi folks> Also, we noticed that ActionMailer::Base dont get the gettext goodies, > so include this somewhere to make it join the multilingual club: > > module ActionMailer #:nodoc: > class Base > helper GetText::Rails > include GetText::Rails > extend GetText::Rails > end > endI''ll add this feature to next release of ruby-gettext. Thanks so much! Masao -- .:% Masao Mutoh<mutoh@highway.ne.jp>
> In our app, we solve the DRY conundrum by making a module like this: > > module Translate > helper GetText::Rails > include GetText::Rails > extend GetText::Rails > end >Just a small remark. In module Translation don''t call `helper'' I think that''s a call to a Rails-method. ;) /Kristian