From andy at stud.fh-dortmund.de Mon Aug 7 08:24:19 2006 From: andy at stud.fh-dortmund.de (Andreas Neuhaus) Date: Mon, 7 Aug 2006 14:24:19 +0200 Subject: [gettext-u-en] [patch] Two little problems with ActiveRecord::Errors Message-ID: <200608071424.25566.andy@stud.fh-dortmund.de> Dear list, I think I found two little bugs in ruby-gettext 1.7.0: 1) When using ActiveRecord::Errors, the on() method does not return an array error messages if there are more than one. Instead, it always returns the last error message. This problem originates in the localize_error_messages method, which does not handle multiple error message per attribute correctly. 2) The error_messages_for helper does only display one error message per attribute, even if there are more than one. This results in an error box being rendered, that e.g. says "there are 3 errors", but only 2 errors are listed because one attribute has two errors. This problem originates in the full_messages method which returns a nested list of messages where it should return a flattened list. Here's the patch that fixes both problems for me: --- lib/gettext/rails.rb.orig 2006-07-20 23:31:00.000000000 +0200 +++ lib/gettext/rails.rb 2006-08-07 14:05:18.000000000 +0200 @@ -360,7 +360,8 @@ else full_message = @base.class.human_attribute_name(attr) + " " + custom_msg end - errors[attr] = full_message + errors[attr] ||= [] + errors[attr] << full_message end end errors @@ -380,9 +381,11 @@ def full_messages #:nodoc: full_messages = [] errors = localize_error_messages - errors.each do |attr, msg| - next if msg.nil? - full_messages << msg + errors.each_key do |attr| + errors[attr].each do |msg| + next if msg.nil? + full_messages << msg + end end full_messages end regards, Andreas Neuhaus -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://rubyforge.org/pipermail/gettext-users-en/attachments/20060807/d89014e4/attachment.bin From mutoh at highway.ne.jp Tue Aug 8 08:06:14 2006 From: mutoh at highway.ne.jp (Masao Mutoh) Date: Tue, 8 Aug 2006 21:06:14 +0900 Subject: [gettext-u-en] [patch] Two little problems with ActiveRecord::Errors In-Reply-To: <200608071424.25566.andy@stud.fh-dortmund.de> References: <200608071424.25566.andy@stud.fh-dortmund.de> Message-ID: <20060808210614.1286c38e.mutoh@highway.ne.jp> Hi, Thanks. Applied to CVS. On Mon, 7 Aug 2006 14:24:19 +0200 Andreas Neuhaus wrote: > Dear list, > > I think I found two little bugs in ruby-gettext 1.7.0: > > 1) When using ActiveRecord::Errors, the on() method does not return an array > error messages if there are more than one. Instead, it always returns the > last error message. This problem originates in the localize_error_messages > method, which does not handle multiple error message per attribute correctly. > > 2) The error_messages_for helper does only display one error message per > attribute, even if there are more than one. This results in an error box > being rendered, that e.g. says "there are 3 errors", but only 2 errors are > listed because one attribute has two errors. This problem originates in the > full_messages method which returns a nested list of messages where it should > return a flattened list. > > > Here's the patch that fixes both problems for me: > > --- lib/gettext/rails.rb.orig 2006-07-20 23:31:00.000000000 +0200 > +++ lib/gettext/rails.rb 2006-08-07 14:05:18.000000000 +0200 > @@ -360,7 +360,8 @@ > else > full_message = @base.class.human_attribute_name(attr) + " " + > custom_msg > end > - errors[attr] = full_message > + errors[attr] ||= [] > + errors[attr] << full_message > end > end > errors > @@ -380,9 +381,11 @@ > def full_messages #:nodoc: > full_messages = [] > errors = localize_error_messages > - errors.each do |attr, msg| > - next if msg.nil? > - full_messages << msg > + errors.each_key do |attr| > + errors[attr].each do |msg| > + next if msg.nil? > + full_messages << msg > + end > end > full_messages > end > > > regards, > Andreas Neuhaus > -- -- .:% Masao Mutoh From juanseph at gmail.com Mon Aug 14 13:13:39 2006 From: juanseph at gmail.com (=?ISO-8859-1?Q?Juanse_P=E9rez_Herrero?=) Date: Mon, 14 Aug 2006 19:13:39 +0200 Subject: [gettext-u-en] ActionMailer and _ method Message-ID: <7ac199f30608141013t78201df1qa4dcea9c7c0399de@mail.gmail.com> Hi list, I have upgraded to gettext 1.7.0 but the _ method doesn't seem to work in the corresponding mail view. The only way to make it work is to write a different view like blabla_es.rhtml. For us it is important to do it via po files since translators use pootle to translate the app. I have checked this thread but didn't help either http://lists.rubyonrails.org/pipermail/rails/2006-March/021960.html Thanks in advanced. Some code class TestController < ApplicationController def index InvitationNotifier::deliver_invitation("xxxxxx at gmail.com", "", "") end end class InvitationNotifier < ActionMailer::Base def invitation(email, subject, body) @recipients = email @from = "xxxxx" @sent_on = Time.now @subject = subject @body[:content] = body end end index.rhtml #action view displays translated text ok <%= _("text test") %> invitation.rhtml # mail view does not send translated text by email <%= _("text test") %> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/gettext-users-en/attachments/20060814/89dcfec6/attachment.html From mutoh at highway.ne.jp Tue Aug 15 09:46:36 2006 From: mutoh at highway.ne.jp (Masao Mutoh) Date: Tue, 15 Aug 2006 22:46:36 +0900 Subject: [gettext-u-en] ActionMailer and _ method In-Reply-To: <7ac199f30608141013t78201df1qa4dcea9c7c0399de@mail.gmail.com> References: <7ac199f30608141013t78201df1qa4dcea9c7c0399de@mail.gmail.com> Message-ID: <20060815224636.0bb1a3e1.mutoh@highway.ne.jp> Hi, How about this patch to gettext/rails.rb ? --- rails.rb.old 2006-08-15 00:31:42.000000000 +0900 +++ rails.rb 2006-08-15 00:33:08.000000000 +0900 @@ -60,7 +60,7 @@ # They are remained for backward compatibility. # def bindtextdomain(domainname, options = {}, locale = nil, charset = nil, with_model = true) - opt = {:with_helper => true, :with_model => true} + opt = {:with_helper => true, :with_model => true, :with_mailer => true} if options.kind_of? CGI # For backward compatibility opt.merge!(:cgi => options, :locale => locale, :charset => charset, :with_model => with_model) @@ -73,6 +73,7 @@ ret = _bindtextdomain(domainname, opt) bindtextdomain_to(ActiveRecord::Base, domainname) if opt[:with_model] bindtextdomain_to(ApplicationHelper, domainname) if opt[:with_helper] + bindtextdomain_to(ActionMailer::Base, domainname) if opt[:with_mailer] ret end On Mon, 14 Aug 2006 19:13:39 +0200 "Juanse P$(D+1(Brez Herrero" wrote: > Hi list, > > I have upgraded to gettext 1.7.0 but the _ method doesn't seem to work in > the corresponding mail view. The only way to make it work is to write a > different view like blabla_es.rhtml. For us it is important to do it via po > files since translators use pootle to translate the app. > > I have checked this thread but didn't help either > http://lists.rubyonrails.org/pipermail/rails/2006-March/021960.html > > Thanks in advanced. > > Some code > > class TestController < ApplicationController > def index > InvitationNotifier::deliver_invitation("xxxxxx at gmail.com", "", "") > end > end > > class InvitationNotifier < ActionMailer::Base > def invitation(email, subject, body) > @recipients = email > @from = "xxxxx" > @sent_on = Time.now > @subject = subject > @body[:content] = body > end > end > > > index.rhtml #action view displays translated text ok > <%= _("text test") %> > > invitation.rhtml # mail view does not send translated text by email > <%= _("text test") %> > -- -- .:% Masao Mutoh From juanseph at gmail.com Wed Aug 16 13:37:54 2006 From: juanseph at gmail.com (=?ISO-8859-1?Q?Juanse_P=E9rez_Herrero?=) Date: Wed, 16 Aug 2006 19:37:54 +0200 Subject: [gettext-u-en] ActionMailer and _ method In-Reply-To: <7ac199f30608161020u61ef639cj627964c8be2a4d46@mail.gmail.com> References: <7ac199f30608141013t78201df1qa4dcea9c7c0399de@mail.gmail.com> <20060815224636.0bb1a3e1.mutoh@highway.ne.jp> <7ac199f30608161020u61ef639cj627964c8be2a4d46@mail.gmail.com> Message-ID: <7ac199f30608161037j39dc7e2bpdd93cda2c25121f0@mail.gmail.com> The patch didn't work, sorry for late response. I am using actionmailer 1.2.5 On 8/15/06, Masao Mutoh < mutoh at highway.ne.jp> wrote: > Hi, How about this patch to gettext/rails.rb ? --- rails.rb.old 2006-08-15 00:31:42.000000000 +0900 +++ rails.rb 2006-08-15 00:33:08.000000000 +0900 @@ -60,7 +60,7 @@ # They are remained for backward compatibility. # def bindtextdomain(domainname, options = {}, locale = nil, charset = nil, with_model = true) - opt = {:with_helper => true, :with_model => true} + opt = {:with_helper => true, :with_model => true, :with_mailer => true} if options.kind_of? CGI # For backward compatibility opt.merge!(:cgi => options, :locale => locale, :charset => charset, :with_model => with_model) @@ -73,6 +73,7 @@ ret = _bindtextdomain(domainname, opt) bindtextdomain_to(ActiveRecord::Base, domainname) if opt[:with_model] bindtextdomain_to(ApplicationHelper, domainname) if opt[:with_helper] + bindtextdomain_to(ActionMailer::Base, domainname) if opt[:with_mailer] ret end On Mon, 14 Aug 2006 19:13:39 +0200 "Juanse P?D+1rez Herrero" wrote: > Hi list, > > I have upgraded to gettext 1.7.0 but the _ method doesn't seem to work in > the corresponding mail view. The only way to make it work is to write a > different view like blabla_es.rhtml. For us it is important to do it via po > files since translators use pootle to translate the app. > > I have checked this thread but didn't help either > http://lists.rubyonrails.org/pipermail/rails/2006-March/021960.html > > Thanks in advanced. > > Some code > > class TestController < ApplicationController > def index > InvitationNotifier::deliver_invitation(" xxxxxx at gmail.com", "", "") > end > end > > class InvitationNotifier < ActionMailer::Base > def invitation(email, subject, body) > @recipients = email > @from = "xxxxx" > @sent_on = Time.now > @subject = subject > @body[:content] = body > end > end > > > index.rhtml #action view displays translated text ok > <%= _("text test") %> > > invitation.rhtml # mail view does not send translated text by email > <%= _("text test") %> > -- -- .:% Masao Mutoh< mutoh at highway.ne.jp> _______________________________________________ gettext-users-en mailing list gettext-users-en at rubyforge.org http://rubyforge.org/mailman/listinfo/gettext-users-en -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/gettext-users-en/attachments/20060816/fa06f237/attachment-0001.html From erkki at itech.ee Wed Aug 16 16:29:45 2006 From: erkki at itech.ee (Erkki Eilonen) Date: Wed, 16 Aug 2006 23:29:45 +0300 Subject: [gettext-u-en] rails, i18n of virtual attribute names Message-ID: <1155760185.31092.9.camel@cmj.ddns.erkki.itech.ee> Hello, Could anyone tell me if they have any experience in translating virtual attributes names of rails models. For example, I have an application that has a following validation line: --- validates_confirmation_of :password, :password_confirmation --- As both of the attributes are just ruby instance variables, ruby-gettext doesn't collect the msgids "password" or "Password". Even if one would add the translations to the .mo file manually, the attribute names are still not translated. I guess that they never go through the GetText._() or GetText.N_() method calls (I haven't made sense of the ruby gettext code that does that). Any ideas? -- Erkki Eilonen iTech Solutions From edgargonzalez at gmail.com Wed Aug 16 17:06:07 2006 From: edgargonzalez at gmail.com (Edgar Gonzalez) Date: Wed, 16 Aug 2006 17:06:07 -0400 Subject: [gettext-u-en] rails, i18n of virtual attribute names In-Reply-To: <1155760185.31092.9.camel@cmj.ddns.erkki.itech.ee> References: <1155760185.31092.9.camel@cmj.ddns.erkki.itech.ee> Message-ID: Do you try this? http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html#Translate+the+attributes+which+doesn%27t+exist+in+your+Database class User < ActiveRecord::Base attr_accessor :password, :password_confirmation N_("User|Password") N_("User|Password confirmation") validates_presence_of :password def validate errors.add("password", _("%{fn} is wrong!")) unless password == password_confirmation end end On 8/16/06, Erkki Eilonen wrote: > Hello, > > Could anyone tell me if they have any experience in translating virtual > attributes names of rails models. For example, I have an application > that has a following validation line: > --- > validates_confirmation_of :password, :password_confirmation > --- > > As both of the attributes are just ruby instance variables, ruby-gettext > doesn't collect the msgids "password" or "Password". Even if one would > add the translations to the .mo file manually, the attribute names are > still not translated. I guess that they never go through the GetText._() > or GetText.N_() method calls (I haven't made sense of the ruby gettext > code that does that). > > Any ideas? > > -- > Erkki Eilonen > iTech Solutions > > _______________________________________________ > gettext-users-en mailing list > gettext-users-en at rubyforge.org > http://rubyforge.org/mailman/listinfo/gettext-users-en > -- Edgar Gonz?lez Gonz?lez E-mail: edgargonzalez at gmail.com http://vp.com.ve http://lacaraoscura.com http://rubycorner.com -- From mutoh at highway.ne.jp Thu Aug 17 21:49:06 2006 From: mutoh at highway.ne.jp (Masao Mutoh) Date: Fri, 18 Aug 2006 10:49:06 +0900 Subject: [gettext-u-en] ActionMailer and _ method In-Reply-To: <7ac199f30608161037j39dc7e2bpdd93cda2c25121f0@mail.gmail.com> References: <7ac199f30608141013t78201df1qa4dcea9c7c0399de@mail.gmail.com> <20060815224636.0bb1a3e1.mutoh@highway.ne.jp> <7ac199f30608161020u61ef639cj627964c8be2a4d46@mail.gmail.com> <7ac199f30608161037j39dc7e2bpdd93cda2c25121f0@mail.gmail.com> Message-ID: <20060818104906.7e108a75.mutoh@highway.ne.jp> Hi, Could you send here the complete sample ? # Small one is preferable. On Wed, 16 Aug 2006 19:37:54 +0200 "Juanse P?rez Herrero" wrote: > The patch didn't work, sorry for late response. I am using actionmailer > 1.2.5 > > > > On 8/15/06, Masao Mutoh < mutoh at highway.ne.jp> wrote: > > > Hi, > > How about this patch to gettext/rails.rb ? > > --- rails.rb.old 2006-08-15 00:31:42.000000000 +0900 > +++ rails.rb 2006-08-15 00:33:08.000000000 +0900 > @@ -60,7 +60,7 @@ > # They are remained for backward compatibility. > # > def bindtextdomain(domainname, options = {}, locale = nil, charset = > nil, with_model = true) > - opt = {:with_helper => true, :with_model => true} > + opt = {:with_helper => true, :with_model => true, :with_mailer => > true} > if options.kind_of? CGI > # For backward compatibility > opt.merge!(:cgi => options, :locale => locale, :charset => charset, > :with_model => with_model) > @@ -73,6 +73,7 @@ > ret = _bindtextdomain(domainname, opt) > bindtextdomain_to(ActiveRecord::Base, domainname) if opt[:with_model] > > bindtextdomain_to(ApplicationHelper, domainname) if opt[:with_helper] > + bindtextdomain_to(ActionMailer::Base, domainname) if > opt[:with_mailer] > ret > end > > > > > On Mon, 14 Aug 2006 19:13:39 +0200 > "Juanse P?D+1rez Herrero" wrote: > > > Hi list, > > > > I have upgraded to gettext 1.7.0 but the _ method doesn't seem to work in > > the corresponding mail view. The only way to make it work is to write a > > different view like blabla_es.rhtml. For us it is important to do it via > po > > files since translators use pootle to translate the app. > > > > I have checked this thread but didn't help either > > http://lists.rubyonrails.org/pipermail/rails/2006-March/021960.html > > > > Thanks in advanced. > > > > Some code > > > > class TestController < ApplicationController > > def index > > InvitationNotifier::deliver_invitation(" xxxxxx at gmail.com", "", "") > > end > > end > > > > class InvitationNotifier < ActionMailer::Base > > def invitation(email, subject, body) > > @recipients = email > > @from = "xxxxx" > > @sent_on = Time.now > > @subject = subject > > @body[:content] = body > > end > > end > > > > > > index.rhtml #action view displays translated text ok > > <%= _("text test") %> > > > > invitation.rhtml # mail view does not send translated text by email > > <%= _("text test") %> > > > > > -- > -- > .:% Masao Mutoh< mutoh at highway.ne.jp> > > > _______________________________________________ > gettext-users-en mailing list > gettext-users-en at rubyforge.org > http://rubyforge.org/mailman/listinfo/gettext-users-en -- -- .:% Masao Mutoh From juanseph at gmail.com Fri Aug 18 15:38:56 2006 From: juanseph at gmail.com (=?ISO-8859-1?Q?Juanse_P=E9rez_Herrero?=) Date: Fri, 18 Aug 2006 21:38:56 +0200 Subject: [gettext-u-en] ActionMailer and _ method In-Reply-To: <20060818104906.7e108a75.mutoh@highway.ne.jp> References: <7ac199f30608141013t78201df1qa4dcea9c7c0399de@mail.gmail.com> <20060815224636.0bb1a3e1.mutoh@highway.ne.jp> <7ac199f30608161020u61ef639cj627964c8be2a4d46@mail.gmail.com> <7ac199f30608161037j39dc7e2bpdd93cda2c25121f0@mail.gmail.com> <20060818104906.7e108a75.mutoh@highway.ne.jp> Message-ID: <7ac199f30608181238sdf19347k1fc5712096a915d6@mail.gmail.com> Thanks for your answer. The sample was included on my first email on this thread, I belive there is nothing special on it. If you need any additional info, please contact me. #app/controller/test_controler.rb class TestController < ApplicationController def index InvitationNotifier::deliver_invitation("xxxxxx at gmail.com", "", "") end end #app/models/invitation_motifier.rb class InvitationNotifier < ActionMailer::Base def invitation(email, subject, body) @recipients = email @from = "xxxxx" @sent_on = Time.now @subject = subject @body[:content] = body end end #app/views/test/index.rhtml #action view displays translated text ok <%= _("text test") %> #app/views/invitation_notifier/invitation.rhtml # mail view does not send translated text by email <%= _("text test") %> #after applying the patch I got this on #/usr/local/lib/ruby/gems/1.8/gems/gettext-1.7.0/lib/gettext/rails.rb def bindtextdomain(domainname, options = {}, locale = nil, charset = nil, with_model = true) opt = {:with_helper => true, :with_model => true, :with_mailer => true} if options.kind_of? CGI # For backward compatibility opt.merge!(:cgi => options, :locale => locale, :charset => charset, :with_model => with_model) else opt.merge!(options) end opt[:path] ||= File.join(RAILS_ROOT, "locale") Locale.set_current(nil) # IMPORTANT! current locale should be nil once(default is used). set_cgi(opt[:cgi]) if opt[:cgi] ret = _bindtextdomain(domainname, opt) bindtextdomain_to(ActiveRecord::Base, domainname) if opt[:with_model] bindtextdomain_to(ApplicationHelper, domainname) if opt[:with_helper] bindtextdomain_to(ActionMailer::Base, domainname) if opt[:with_mailer] ret end Thanks On 8/18/06, Masao Mutoh wrote: > > Hi, > > Could you send here the complete sample ? > # Small one is preferable. > > On Wed, 16 Aug 2006 19:37:54 +0200 > "Juanse P?rez Herrero" wrote: > > > The patch didn't work, sorry for late response. I am using actionmailer > > 1.2.5 > > > > > > > > On 8/15/06, Masao Mutoh < mutoh at highway.ne.jp> wrote: > > > > > Hi, > > > > How about this patch to gettext/rails.rb ? > > > > --- rails.rb.old 2006-08-15 00:31:42.000000000 +0900 > > +++ rails.rb 2006-08-15 00:33:08.000000000 +0900 > > @@ -60,7 +60,7 @@ > > # They are remained for backward compatibility. > > # > > def bindtextdomain(domainname, options = {}, locale = nil, charset > = > > nil, with_model = true) > > - opt = {:with_helper => true, :with_model => true} > > + opt = {:with_helper => true, :with_model => true, :with_mailer => > > true} > > if options.kind_of? CGI > > # For backward compatibility > > opt.merge!(:cgi => options, :locale => locale, :charset => > charset, > > :with_model => with_model) > > @@ -73,6 +73,7 @@ > > ret = _bindtextdomain(domainname, opt) > > bindtextdomain_to(ActiveRecord::Base, domainname) if > opt[:with_model] > > > > bindtextdomain_to(ApplicationHelper, domainname) if > opt[:with_helper] > > + bindtextdomain_to(ActionMailer::Base, domainname) if > > opt[:with_mailer] > > ret > > end > > > > > > > > > > On Mon, 14 Aug 2006 19:13:39 +0200 > > "Juanse P?D+1rez Herrero" wrote: > > > > > Hi list, > > > > > > I have upgraded to gettext 1.7.0 but the _ method doesn't seem to work > in > > > the corresponding mail view. The only way to make it work is to write > a > > > different view like blabla_es.rhtml. For us it is important to do it > via > > po > > > files since translators use pootle to translate the app. > > > > > > I have checked this thread but didn't help either > > > http://lists.rubyonrails.org/pipermail/rails/2006-March/021960.html > > > > > > Thanks in advanced. > > > > > > Some code > > > > > > class TestController < ApplicationController > > > def index > > > InvitationNotifier::deliver_invitation(" xxxxxx at gmail.com", "", > "") > > > end > > > end > > > > > > class InvitationNotifier < ActionMailer::Base > > > def invitation(email, subject, body) > > > @recipients = email > > > @from = "xxxxx" > > > @sent_on = Time.now > > > @subject = subject > > > @body[:content] = body > > > end > > > end > > > > > > > > > index.rhtml #action view displays translated text ok > > > <%= _("text test") %> > > > > > > invitation.rhtml # mail view does not send translated text by email > > > <%= _("text test") %> > > > > > > > > > -- > > -- > > .:% Masao Mutoh< mutoh at highway.ne.jp> > > > > > > _______________________________________________ > > gettext-users-en mailing list > > gettext-users-en at rubyforge.org > > http://rubyforge.org/mailman/listinfo/gettext-users-en > > > -- > -- > .:% Masao Mutoh > _______________________________________________ > gettext-users-en mailing list > gettext-users-en at rubyforge.org > http://rubyforge.org/mailman/listinfo/gettext-users-en -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/gettext-users-en/attachments/20060818/3e80219c/attachment-0001.html From mutoh at highway.ne.jp Sat Aug 19 11:12:52 2006 From: mutoh at highway.ne.jp (Masao Mutoh) Date: Sun, 20 Aug 2006 00:12:52 +0900 Subject: [gettext-u-en] ActionMailer and _ method In-Reply-To: <7ac199f30608181238sdf19347k1fc5712096a915d6@mail.gmail.com> References: <7ac199f30608141013t78201df1qa4dcea9c7c0399de@mail.gmail.com> <20060815224636.0bb1a3e1.mutoh@highway.ne.jp> <7ac199f30608161020u61ef639cj627964c8be2a4d46@mail.gmail.com> <7ac199f30608161037j39dc7e2bpdd93cda2c25121f0@mail.gmail.com> <20060818104906.7e108a75.mutoh@highway.ne.jp> <7ac199f30608181238sdf19347k1fc5712096a915d6@mail.gmail.com> Message-ID: <20060820001252.621aaeef.mutoh@highway.ne.jp> Hi, Is it really "complete" sample? OK. I haven't test it yet, but I think you need to define updatepo/makemo task in Rakefile and run updatepo task first. Then, you need to copy pot file to po/#{lang}/foo.po and translate the files. After that you need to run makemo task. Then execute your application. See http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html On Fri, 18 Aug 2006 21:38:56 +0200 "Juanse P?rez Herrero" wrote: > Thanks for your answer. > > The sample was included on my first email on this thread, I belive there is > nothing special on it. If you need any additional info, please contact me. > > #app/controller/test_controler.rb > class TestController < ApplicationController > def index > InvitationNotifier::deliver_invitation("xxxxxx at gmail.com", "", "") > end > end > > #app/models/invitation_motifier.rb > class InvitationNotifier < ActionMailer::Base > def invitation(email, subject, body) > @recipients = email > @from = "xxxxx" > @sent_on = Time.now > @subject = subject > @body[:content] = body > end > end > > #app/views/test/index.rhtml > #action view displays translated text ok > <%= _("text test") %> > > #app/views/invitation_notifier/invitation.rhtml > # mail view does not send translated text by email > <%= _("text test") %> > > #after applying the patch I got this on > #/usr/local/lib/ruby/gems/1.8/gems/gettext-1.7.0/lib/gettext/rails.rb > def bindtextdomain(domainname, options = {}, locale = nil, charset = nil, > with_model = true) > opt = {:with_helper => true, :with_model => true, :with_mailer => > true} > if options.kind_of? CGI > # For backward compatibility > opt.merge!(:cgi => options, :locale => locale, :charset => charset, > :with_model => with_model) > else > opt.merge!(options) > end > opt[:path] ||= File.join(RAILS_ROOT, "locale") > Locale.set_current(nil) # IMPORTANT! current locale should be nil > once(default is used). > set_cgi(opt[:cgi]) if opt[:cgi] > ret = _bindtextdomain(domainname, opt) > bindtextdomain_to(ActiveRecord::Base, domainname) if opt[:with_model] > bindtextdomain_to(ApplicationHelper, domainname) if opt[:with_helper] > bindtextdomain_to(ActionMailer::Base, domainname) if opt[:with_mailer] > ret > end > > Thanks > > > On 8/18/06, Masao Mutoh wrote: > > > > Hi, > > > > Could you send here the complete sample ? > > # Small one is preferable. > > > > On Wed, 16 Aug 2006 19:37:54 +0200 > > "Juanse P?rez Herrero" wrote: > > > > > The patch didn't work, sorry for late response. I am using actionmailer > > > 1.2.5 > > > > > > > > > > > > On 8/15/06, Masao Mutoh < mutoh at highway.ne.jp> wrote: > > > > > > > Hi, > > > > > > How about this patch to gettext/rails.rb ? > > > > > > --- rails.rb.old 2006-08-15 00:31:42.000000000 +0900 > > > +++ rails.rb 2006-08-15 00:33:08.000000000 +0900 > > > @@ -60,7 +60,7 @@ > > > # They are remained for backward compatibility. > > > # > > > def bindtextdomain(domainname, options = {}, locale = nil, charset > > = > > > nil, with_model = true) > > > - opt = {:with_helper => true, :with_model => true} > > > + opt = {:with_helper => true, :with_model => true, :with_mailer => > > > true} > > > if options.kind_of? CGI > > > # For backward compatibility > > > opt.merge!(:cgi => options, :locale => locale, :charset => > > charset, > > > :with_model => with_model) > > > @@ -73,6 +73,7 @@ > > > ret = _bindtextdomain(domainname, opt) > > > bindtextdomain_to(ActiveRecord::Base, domainname) if > > opt[:with_model] > > > > > > bindtextdomain_to(ApplicationHelper, domainname) if > > opt[:with_helper] > > > + bindtextdomain_to(ActionMailer::Base, domainname) if > > > opt[:with_mailer] > > > ret > > > end > > > > > > > > > > > > > > > On Mon, 14 Aug 2006 19:13:39 +0200 > > > "Juanse P?D+1rez Herrero" wrote: > > > > > > > Hi list, > > > > > > > > I have upgraded to gettext 1.7.0 but the _ method doesn't seem to work > > in > > > > the corresponding mail view. The only way to make it work is to write > > a > > > > different view like blabla_es.rhtml. For us it is important to do it > > via > > > po > > > > files since translators use pootle to translate the app. > > > > > > > > I have checked this thread but didn't help either > > > > http://lists.rubyonrails.org/pipermail/rails/2006-March/021960.html > > > > > > > > Thanks in advanced. > > > > > > > > Some code > > > > > > > > class TestController < ApplicationController > > > > def index > > > > InvitationNotifier::deliver_invitation(" xxxxxx at gmail.com", "", > > "") > > > > end > > > > end > > > > > > > > class InvitationNotifier < ActionMailer::Base > > > > def invitation(email, subject, body) > > > > @recipients = email > > > > @from = "xxxxx" > > > > @sent_on = Time.now > > > > @subject = subject > > > > @body[:content] = body > > > > end > > > > end > > > > > > > > > > > > index.rhtml #action view displays translated text ok > > > > <%= _("text test") %> > > > > > > > > invitation.rhtml # mail view does not send translated text by email > > > > <%= _("text test") %> > > > > > > > > > > > > > -- > > > -- > > > .:% Masao Mutoh< mutoh at highway.ne.jp> > > > > > > > > > _______________________________________________ > > > gettext-users-en mailing list > > > gettext-users-en at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/gettext-users-en > > > > > > -- > > -- > > .:% Masao Mutoh > > _______________________________________________ > > gettext-users-en mailing list > > gettext-users-en at rubyforge.org > > http://rubyforge.org/mailman/listinfo/gettext-users-en -- -- .:% Masao Mutoh From edgargonzalez at gmail.com Mon Aug 21 17:41:09 2006 From: edgargonzalez at gmail.com (Edgar Gonzalez) Date: Mon, 21 Aug 2006 17:41:09 -0400 Subject: [gettext-u-en] Best way to i18n my plugin Message-ID: Hi, I'm developing a plugin to select languages -- lang_options_helper. My code looks like this: require 'gettext' module ActionView module Helpers module LangOptionsHelper include GetText bindtextdomain("lang_options_helper", :path => File.join(RAILS_ROOT, "vendor/plugins/lang_options_helper/locale")) .... .... LANGS = { 'af' => 'afrikaans', 'ar' => 'arabic', 'az' => 'azerbaijani', 'bg' => 'bulgarian', ... 'zh' => 'chinese' } unless const_defined?("LANGS") end class InstanceTag include LangOptionsHelper def to_lang_select_tag(priority_langs, options, html_options) html_options = html_options.stringify_keys add_default_name_and_id(html_options) content_tag("select", add_options(lang_options_for_select(value, priority_langs), options, value), html_options) end end class FormBuilder def lang_select(method, priority_langs = nil, options = {}, html_options = {}) @template.lang_select(@object_name, method, priority_langs, options.merge(:object => @object), html_options) end end end end I want the language names to be i18n. I'm think I must use N_(), something in this way: LANGS = { 'af' => N_('afrikaans'), but don't works. However if I use: LANGS = { 'af' => _('afrikaans'), the language name appear to be translated, but with encoding problems. Any idea? Thanks -- Edgar Gonz?lez Gonz?lez E-mail: edgargonzalez at gmail.com http://vp.com.ve http://lacaraoscura.com http://rubycorner.com -- From mutoh at highway.ne.jp Tue Aug 22 11:23:53 2006 From: mutoh at highway.ne.jp (Masao Mutoh) Date: Wed, 23 Aug 2006 00:23:53 +0900 Subject: [gettext-u-en] Best way to i18n my plugin In-Reply-To: References: Message-ID: <20060823002353.6029e290.mutoh@highway.ne.jp> Hi, On Mon, 21 Aug 2006 17:41:09 -0400 "Edgar Gonzalez" wrote: > Hi, > > I'm developing a plugin to select languages -- lang_options_helper. > > My code looks like this: > > require 'gettext' > > module ActionView > module Helpers > module LangOptionsHelper > > include GetText > bindtextdomain("lang_options_helper", :path => > File.join(RAILS_ROOT, "vendor/plugins/lang_options_helper/locale")) > > .... > > .... > > LANGS = { > 'af' => 'afrikaans', > 'ar' => 'arabic', > 'az' => 'azerbaijani', > 'bg' => 'bulgarian', > ... > 'zh' => 'chinese' > } unless const_defined?("LANGS") > end > > class InstanceTag > include LangOptionsHelper > > def to_lang_select_tag(priority_langs, options, html_options) > html_options = html_options.stringify_keys > add_default_name_and_id(html_options) > content_tag("select", > add_options(lang_options_for_select(value, priority_langs), options, > value), html_options) > end > > end > > class FormBuilder > def lang_select(method, priority_langs = nil, options = {}, > html_options = {}) > @template.lang_select(@object_name, method, priority_langs, > options.merge(:object => @object), html_options) > end > end > end > end > > > I want the language names to be i18n. I'm think I must use N_(), > something in this way: > > LANGS = { > 'af' => N_('afrikaans'), > > but don't works. However if I use: > > LANGS = { > 'af' => _('afrikaans'), > > the language name appear to be translated, but with encoding problems. > > Any idea? You should use N_() here. And anywhere you have the code such as: lang = 'af' - LANGS[lang] + _(LANGS[lang]) # Rewrite like this. -- .:% Masao Mutoh From edgargonzalez at gmail.com Tue Aug 22 13:47:50 2006 From: edgargonzalez at gmail.com (Edgar Gonzalez) Date: Tue, 22 Aug 2006 13:47:50 -0400 Subject: [gettext-u-en] Best way to i18n my plugin In-Reply-To: <20060823002353.6029e290.mutoh@highway.ne.jp> References: <20060823002353.6029e290.mutoh@highway.ne.jp> Message-ID: Masao, Thanks, I tried this, but I still got encoding problems, e.g spanish translations for several languages: spanish => espa?ol => espa?ol english => ingl?s => ingl?s All the application is already i18n and works fine - no encoding problems - except the languages translations in the plugin. Any idea ? On 8/22/06, Masao Mutoh wrote: > Hi, > > On Mon, 21 Aug 2006 17:41:09 -0400 > "Edgar Gonzalez" wrote: > > > Hi, > > > > I'm developing a plugin to select languages -- lang_options_helper. > > > > My code looks like this: > > > > require 'gettext' > > > > module ActionView > > module Helpers > > module LangOptionsHelper > > > > include GetText > > bindtextdomain("lang_options_helper", :path => > > File.join(RAILS_ROOT, "vendor/plugins/lang_options_helper/locale")) > > > > .... > > > > .... > > > > LANGS = { > > 'af' => 'afrikaans', > > 'ar' => 'arabic', > > 'az' => 'azerbaijani', > > 'bg' => 'bulgarian', > > ... > > 'zh' => 'chinese' > > } unless const_defined?("LANGS") > > end > > > > class InstanceTag > > include LangOptionsHelper > > > > def to_lang_select_tag(priority_langs, options, html_options) > > html_options = html_options.stringify_keys > > add_default_name_and_id(html_options) > > content_tag("select", > > add_options(lang_options_for_select(value, priority_langs), options, > > value), html_options) > > end > > > > end > > > > class FormBuilder > > def lang_select(method, priority_langs = nil, options = {}, > > html_options = {}) > > @template.lang_select(@object_name, method, priority_langs, > > options.merge(:object => @object), html_options) > > end > > end > > end > > end > > > > > > I want the language names to be i18n. I'm think I must use N_(), > > something in this way: > > > > LANGS = { > > 'af' => N_('afrikaans'), > > > > but don't works. However if I use: > > > > LANGS = { > > 'af' => _('afrikaans'), > > > > the language name appear to be translated, but with encoding problems. > > > > Any idea? > > You should use N_() here. > > And anywhere you have the code such as: > > lang = 'af' > - LANGS[lang] > + _(LANGS[lang]) # Rewrite like this. > > > > -- > .:% Masao Mutoh > _______________________________________________ > gettext-users-en mailing list > gettext-users-en at rubyforge.org > http://rubyforge.org/mailman/listinfo/gettext-users-en > -- Edgar Gonz?lez Gonz?lez E-mail: edgargonzalez at gmail.com http://vp.com.ve http://lacaraoscura.com http://rubycorner.com -- From edgargonzalez at gmail.com Tue Aug 22 15:45:18 2006 From: edgargonzalez at gmail.com (Edgar Gonzalez) Date: Tue, 22 Aug 2006 15:45:18 -0400 Subject: [gettext-u-en] Best way to i18n my plugin In-Reply-To: References: <20060823002353.6029e290.mutoh@highway.ne.jp> Message-ID: Masao, I found the problem. I was using: require 'gettext' ... include GetText instead of: require 'gettext/rails' ... include GetText::Rails regards, On 8/22/06, Edgar Gonzalez wrote: > Masao, > > Thanks, I tried this, but > > I still got encoding problems, e.g spanish translations for several languages: > spanish => espa?ol => espa?ol > english => ingl?s => ingl?s > > All the application is already i18n and works fine - no encoding > problems - except the languages translations in the plugin. > > Any idea ? > > > > On 8/22/06, Masao Mutoh wrote: > > Hi, > > > > On Mon, 21 Aug 2006 17:41:09 -0400 > > "Edgar Gonzalez" wrote: > > > > > Hi, > > > > > > I'm developing a plugin to select languages -- lang_options_helper. > > > > > > My code looks like this: > > > > > > require 'gettext' > > > > > > module ActionView > > > module Helpers > > > module LangOptionsHelper > > > > > > include GetText > > > bindtextdomain("lang_options_helper", :path => > > > File.join(RAILS_ROOT, "vendor/plugins/lang_options_helper/locale")) > > > > > > .... > > > > > > .... > > > > > > LANGS = { > > > 'af' => 'afrikaans', > > > 'ar' => 'arabic', > > > 'az' => 'azerbaijani', > > > 'bg' => 'bulgarian', > > > ... > > > 'zh' => 'chinese' > > > } unless const_defined?("LANGS") > > > end > > > > > > class InstanceTag > > > include LangOptionsHelper > > > > > > def to_lang_select_tag(priority_langs, options, html_options) > > > html_options = html_options.stringify_keys > > > add_default_name_and_id(html_options) > > > content_tag("select", > > > add_options(lang_options_for_select(value, priority_langs), options, > > > value), html_options) > > > end > > > > > > end > > > > > > class FormBuilder > > > def lang_select(method, priority_langs = nil, options = {}, > > > html_options = {}) > > > @template.lang_select(@object_name, method, priority_langs, > > > options.merge(:object => @object), html_options) > > > end > > > end > > > end > > > end > > > > > > > > > I want the language names to be i18n. I'm think I must use N_(), > > > something in this way: > > > > > > LANGS = { > > > 'af' => N_('afrikaans'), > > > > > > but don't works. However if I use: > > > > > > LANGS = { > > > 'af' => _('afrikaans'), > > > > > > the language name appear to be translated, but with encoding problems. > > > > > > Any idea? > > > > You should use N_() here. > > > > And anywhere you have the code such as: > > > > lang = 'af' > > - LANGS[lang] > > + _(LANGS[lang]) # Rewrite like this. > > > > > > > > -- > > .:% Masao Mutoh > > _______________________________________________ > > gettext-users-en mailing list > > gettext-users-en at rubyforge.org > > http://rubyforge.org/mailman/listinfo/gettext-users-en > > > > > -- > Edgar Gonz?lez Gonz?lez > E-mail: edgargonzalez at gmail.com > http://vp.com.ve > http://lacaraoscura.com > http://rubycorner.com > -- > -- Edgar Gonz?lez Gonz?lez E-mail: edgargonzalez at gmail.com http://vp.com.ve http://lacaraoscura.com http://rubycorner.com -- From juanseph at gmail.com Wed Aug 23 08:04:50 2006 From: juanseph at gmail.com (=?ISO-8859-1?Q?Juanse_P=E9rez_Herrero?=) Date: Wed, 23 Aug 2006 14:04:50 +0200 Subject: [gettext-u-en] ActionMailer and _ method In-Reply-To: <20060820001252.621aaeef.mutoh@highway.ne.jp> References: <7ac199f30608141013t78201df1qa4dcea9c7c0399de@mail.gmail.com> <20060815224636.0bb1a3e1.mutoh@highway.ne.jp> <7ac199f30608161020u61ef639cj627964c8be2a4d46@mail.gmail.com> <7ac199f30608161037j39dc7e2bpdd93cda2c25121f0@mail.gmail.com> <20060818104906.7e108a75.mutoh@highway.ne.jp> <7ac199f30608181238sdf19347k1fc5712096a915d6@mail.gmail.com> <20060820001252.621aaeef.mutoh@highway.ne.jp> Message-ID: <7ac199f30608230504p274bad9x92be6a59849aed67@mail.gmail.com> Hi Masao, I have found a not quite satisfying way to fix it New code: class InvitationNotifier < ActionMailer::Base include GetText bindtextdomain "app" def invitation(email, subject, body) @recipients = email @from = "xx at xx.com" @sent_on = Time.now @subject = _("text test") @body[:content] = body end end in the mail body view also <%bindtextdomain "app"%> <%= _("text test") %> I guess there must be an easier way to do this, any idea? Thanks a lot On 8/19/06, Masao Mutoh wrote: > > Hi, > > Is it really "complete" sample? > > OK. I haven't test it yet, but I think you need to > define updatepo/makemo task in Rakefile and run updatepo > task first. > Then, you need to copy pot file to po/#{lang}/foo.po > and translate the files. > After that you need to run makemo task. Then execute your > application. > > See http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html > > > > On Fri, 18 Aug 2006 21:38:56 +0200 > "Juanse P?rez Herrero" wrote: > > > Thanks for your answer. > > > > The sample was included on my first email on this thread, I belive there > is > > nothing special on it. If you need any additional info, please contact > me. > > > > #app/controller/test_controler.rb > > class TestController < ApplicationController > > def index > > InvitationNotifier::deliver_invitation("xxxxxx at gmail.com", "", "") > > end > > end > > > > #app/models/invitation_motifier.rb > > class InvitationNotifier < ActionMailer::Base > > def invitation(email, subject, body) > > @recipients = email > > @from = "xxxxx" > > @sent_on = Time.now > > @subject = subject > > @body[:content] = body > > end > > end > > > > #app/views/test/index.rhtml > > #action view displays translated text ok > > <%= _("text test") %> > > > > #app/views/invitation_notifier/invitation.rhtml > > # mail view does not send translated text by email > > <%= _("text test") %> > > > > #after applying the patch I got this on > > #/usr/local/lib/ruby/gems/1.8/gems/gettext-1.7.0/lib/gettext/rails.rb > > def bindtextdomain(domainname, options = {}, locale = nil, charset = > nil, > > with_model = true) > > opt = {:with_helper => true, :with_model => true, :with_mailer => > > true} > > if options.kind_of? CGI > > # For backward compatibility > > opt.merge!(:cgi => options, :locale => locale, :charset => > charset, > > :with_model => with_model) > > else > > opt.merge!(options) > > end > > opt[:path] ||= File.join(RAILS_ROOT, "locale") > > Locale.set_current(nil) # IMPORTANT! current locale should be nil > > once(default is used). > > set_cgi(opt[:cgi]) if opt[:cgi] > > ret = _bindtextdomain(domainname, opt) > > bindtextdomain_to(ActiveRecord::Base, domainname) if > opt[:with_model] > > bindtextdomain_to(ApplicationHelper, domainname) if > opt[:with_helper] > > bindtextdomain_to(ActionMailer::Base, domainname) if > opt[:with_mailer] > > ret > > end > > > > Thanks > > > > > > On 8/18/06, Masao Mutoh wrote: > > > > > > Hi, > > > > > > Could you send here the complete sample ? > > > # Small one is preferable. > > > > > > On Wed, 16 Aug 2006 19:37:54 +0200 > > > "Juanse P?rez Herrero" wrote: > > > > > > > The patch didn't work, sorry for late response. I am using > actionmailer > > > > 1.2.5 > > > > > > > > > > > > > > > > On 8/15/06, Masao Mutoh < mutoh at highway.ne.jp> wrote: > > > > > > > > > Hi, > > > > > > > > How about this patch to gettext/rails.rb ? > > > > > > > > --- rails.rb.old 2006-08-15 00:31:42.000000000 +0900 > > > > +++ rails.rb 2006-08-15 00:33:08.000000000 +0900 > > > > @@ -60,7 +60,7 @@ > > > > # They are remained for backward compatibility. > > > > # > > > > def bindtextdomain(domainname, options = {}, locale = nil, > charset > > > = > > > > nil, with_model = true) > > > > - opt = {:with_helper => true, :with_model => true} > > > > + opt = {:with_helper => true, :with_model => true, > :with_mailer => > > > > true} > > > > if options.kind_of? CGI > > > > # For backward compatibility > > > > opt.merge!(:cgi => options, :locale => locale, :charset => > > > charset, > > > > :with_model => with_model) > > > > @@ -73,6 +73,7 @@ > > > > ret = _bindtextdomain(domainname, opt) > > > > bindtextdomain_to(ActiveRecord::Base, domainname) if > > > opt[:with_model] > > > > > > > > bindtextdomain_to(ApplicationHelper, domainname) if > > > opt[:with_helper] > > > > + bindtextdomain_to(ActionMailer::Base, domainname) if > > > > opt[:with_mailer] > > > > ret > > > > end > > > > > > > > > > > > > > > > > > > > On Mon, 14 Aug 2006 19:13:39 +0200 > > > > "Juanse P?D+1rez Herrero" wrote: > > > > > > > > > Hi list, > > > > > > > > > > I have upgraded to gettext 1.7.0 but the _ method doesn't seem to > work > > > in > > > > > the corresponding mail view. The only way to make it work is to > write > > > a > > > > > different view like blabla_es.rhtml. For us it is important to do > it > > > via > > > > po > > > > > files since translators use pootle to translate the app. > > > > > > > > > > I have checked this thread but didn't help either > > > > > > http://lists.rubyonrails.org/pipermail/rails/2006-March/021960.html > > > > > > > > > > Thanks in advanced. > > > > > > > > > > Some code > > > > > > > > > > class TestController < ApplicationController > > > > > def index > > > > > InvitationNotifier::deliver_invitation(" xxxxxx at gmail.com", > "", > > > "") > > > > > end > > > > > end > > > > > > > > > > class InvitationNotifier < ActionMailer::Base > > > > > def invitation(email, subject, body) > > > > > @recipients = email > > > > > @from = "xxxxx" > > > > > @sent_on = Time.now > > > > > @subject = subject > > > > > @body[:content] = body > > > > > end > > > > > end > > > > > > > > > > > > > > > index.rhtml #action view displays translated text ok > > > > > <%= _("text test") %> > > > > > > > > > > invitation.rhtml # mail view does not send translated text by > email > > > > > <%= _("text test") %> > > > > > > > > > > > > > > > > > -- > > > > -- > > > > .:% Masao Mutoh< mutoh at highway.ne.jp> > > > > > > > > > > > > _______________________________________________ > > > > gettext-users-en mailing list > > > > gettext-users-en at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/gettext-users-en > > > > > > > > > -- > > > -- > > > .:% Masao Mutoh > > > _______________________________________________ > > > gettext-users-en mailing list > > > gettext-users-en at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/gettext-users-en > > > -- > -- > .:% Masao Mutoh > _______________________________________________ > gettext-users-en mailing list > gettext-users-en at rubyforge.org > http://rubyforge.org/mailman/listinfo/gettext-users-en -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/gettext-users-en/attachments/20060823/b5a4654a/attachment-0001.html From mutoh at highway.ne.jp Wed Aug 23 09:22:45 2006 From: mutoh at highway.ne.jp (Masao Mutoh) Date: Wed, 23 Aug 2006 22:22:45 +0900 Subject: [gettext-u-en] ActionMailer and _ method In-Reply-To: <7ac199f30608230504p274bad9x92be6a59849aed67@mail.gmail.com> References: <7ac199f30608141013t78201df1qa4dcea9c7c0399de@mail.gmail.com> <20060815224636.0bb1a3e1.mutoh@highway.ne.jp> <7ac199f30608161020u61ef639cj627964c8be2a4d46@mail.gmail.com> <7ac199f30608161037j39dc7e2bpdd93cda2c25121f0@mail.gmail.com> <20060818104906.7e108a75.mutoh@highway.ne.jp> <7ac199f30608181238sdf19347k1fc5712096a915d6@mail.gmail.com> <20060820001252.621aaeef.mutoh@highway.ne.jp> <7ac199f30608230504p274bad9x92be6a59849aed67@mail.gmail.com> Message-ID: <20060823222245.6ae05a8a.mutoh@highway.ne.jp> Hi, In my environment, it worked with my patch unless your new code.So I don't know why you need this. I suspect you have some wrong configuration. But I don't think to investigate this problem anymore and I can't help you. Because I don't have your "complete" sample code. On Wed, 23 Aug 2006 14:04:50 +0200 "Juanse P?rez Herrero" wrote: > Hi Masao, I have found a not quite satisfying way to fix it > > New code: > > class InvitationNotifier < ActionMailer::Base > include GetText > > bindtextdomain "app" > > def invitation(email, subject, body) > @recipients = email > @from = "xx at xx.com" > @sent_on = Time.now > @subject = _("text test") > @body[:content] = body > end > end > > in the mail body view also > > <%bindtextdomain "app"%> > > <%= _("text test") %> > > I guess there must be an easier way to do this, any idea? > > Thanks a lot > > > On 8/19/06, Masao Mutoh wrote: > > > > Hi, > > > > Is it really "complete" sample? > > > > OK. I haven't test it yet, but I think you need to > > define updatepo/makemo task in Rakefile and run updatepo > > task first. > > Then, you need to copy pot file to po/#{lang}/foo.po > > and translate the files. > > After that you need to run makemo task. Then execute your > > application. > > > > See http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html > > > > > > > > On Fri, 18 Aug 2006 21:38:56 +0200 > > "Juanse P?rez Herrero" wrote: > > > > > Thanks for your answer. > > > > > > The sample was included on my first email on this thread, I belive there > > is > > > nothing special on it. If you need any additional info, please contact > > me. > > > > > > #app/controller/test_controler.rb > > > class TestController < ApplicationController > > > def index > > > InvitationNotifier::deliver_invitation("xxxxxx at gmail.com", "", "") > > > end > > > end > > > > > > #app/models/invitation_motifier.rb > > > class InvitationNotifier < ActionMailer::Base > > > def invitation(email, subject, body) > > > @recipients = email > > > @from = "xxxxx" > > > @sent_on = Time.now > > > @subject = subject > > > @body[:content] = body > > > end > > > end > > > > > > #app/views/test/index.rhtml > > > #action view displays translated text ok > > > <%= _("text test") %> > > > > > > #app/views/invitation_notifier/invitation.rhtml > > > # mail view does not send translated text by email > > > <%= _("text test") %> > > > > > > #after applying the patch I got this on > > > #/usr/local/lib/ruby/gems/1.8/gems/gettext-1.7.0/lib/gettext/rails.rb > > > def bindtextdomain(domainname, options = {}, locale = nil, charset = > > nil, > > > with_model = true) > > > opt = {:with_helper => true, :with_model => true, :with_mailer => > > > true} > > > if options.kind_of? CGI > > > # For backward compatibility > > > opt.merge!(:cgi => options, :locale => locale, :charset => > > charset, > > > :with_model => with_model) > > > else > > > opt.merge!(options) > > > end > > > opt[:path] ||= File.join(RAILS_ROOT, "locale") > > > Locale.set_current(nil) # IMPORTANT! current locale should be nil > > > once(default is used). > > > set_cgi(opt[:cgi]) if opt[:cgi] > > > ret = _bindtextdomain(domainname, opt) > > > bindtextdomain_to(ActiveRecord::Base, domainname) if > > opt[:with_model] > > > bindtextdomain_to(ApplicationHelper, domainname) if > > opt[:with_helper] > > > bindtextdomain_to(ActionMailer::Base, domainname) if > > opt[:with_mailer] > > > ret > > > end > > > > > > Thanks > > > > > > > > > On 8/18/06, Masao Mutoh wrote: > > > > > > > > Hi, > > > > > > > > Could you send here the complete sample ? > > > > # Small one is preferable. > > > > > > > > On Wed, 16 Aug 2006 19:37:54 +0200 > > > > "Juanse P?rez Herrero" wrote: > > > > > > > > > The patch didn't work, sorry for late response. I am using > > actionmailer > > > > > 1.2.5 > > > > > > > > > > > > > > > > > > > > On 8/15/06, Masao Mutoh < mutoh at highway.ne.jp> wrote: > > > > > > > > > > > Hi, > > > > > > > > > > How about this patch to gettext/rails.rb ? > > > > > > > > > > --- rails.rb.old 2006-08-15 00:31:42.000000000 +0900 > > > > > +++ rails.rb 2006-08-15 00:33:08.000000000 +0900 > > > > > @@ -60,7 +60,7 @@ > > > > > # They are remained for backward compatibility. > > > > > # > > > > > def bindtextdomain(domainname, options = {}, locale = nil, > > charset > > > > = > > > > > nil, with_model = true) > > > > > - opt = {:with_helper => true, :with_model => true} > > > > > + opt = {:with_helper => true, :with_model => true, > > :with_mailer => > > > > > true} > > > > > if options.kind_of? CGI > > > > > # For backward compatibility > > > > > opt.merge!(:cgi => options, :locale => locale, :charset => > > > > charset, > > > > > :with_model => with_model) > > > > > @@ -73,6 +73,7 @@ > > > > > ret = _bindtextdomain(domainname, opt) > > > > > bindtextdomain_to(ActiveRecord::Base, domainname) if > > > > opt[:with_model] > > > > > > > > > > bindtextdomain_to(ApplicationHelper, domainname) if > > > > opt[:with_helper] > > > > > + bindtextdomain_to(ActionMailer::Base, domainname) if > > > > > opt[:with_mailer] > > > > > ret > > > > > end > > > > > > > > > > > > > > > > > > > > > > > > > On Mon, 14 Aug 2006 19:13:39 +0200 > > > > > "Juanse P?D+1rez Herrero" wrote: > > > > > > > > > > > Hi list, > > > > > > > > > > > > I have upgraded to gettext 1.7.0 but the _ method doesn't seem to > > work > > > > in > > > > > > the corresponding mail view. The only way to make it work is to > > write > > > > a > > > > > > different view like blabla_es.rhtml. For us it is important to do > > it > > > > via > > > > > po > > > > > > files since translators use pootle to translate the app. > > > > > > > > > > > > I have checked this thread but didn't help either > > > > > > > > http://lists.rubyonrails.org/pipermail/rails/2006-March/021960.html > > > > > > > > > > > > Thanks in advanced. > > > > > > > > > > > > Some code > > > > > > > > > > > > class TestController < ApplicationController > > > > > > def index > > > > > > InvitationNotifier::deliver_invitation(" xxxxxx at gmail.com", > > "", > > > > "") > > > > > > end > > > > > > end > > > > > > > > > > > > class InvitationNotifier < ActionMailer::Base > > > > > > def invitation(email, subject, body) > > > > > > @recipients = email > > > > > > @from = "xxxxx" > > > > > > @sent_on = Time.now > > > > > > @subject = subject > > > > > > @body[:content] = body > > > > > > end > > > > > > end > > > > > > > > > > > > > > > > > > index.rhtml #action view displays translated text ok > > > > > > <%= _("text test") %> > > > > > > > > > > > > invitation.rhtml # mail view does not send translated text by > > email > > > > > > <%= _("text test") %> > > > > > > > > > > > > > > > > > > > > > -- > > > > > -- > > > > > .:% Masao Mutoh< mutoh at highway.ne.jp> > > > > > > > > > > > > > > > _______________________________________________ > > > > > gettext-users-en mailing list > > > > > gettext-users-en at rubyforge.org > > > > > http://rubyforge.org/mailman/listinfo/gettext-users-en > > > > > > > > > > > > -- > > > > -- > > > > .:% Masao Mutoh > > > > _______________________________________________ > > > > gettext-users-en mailing list > > > > gettext-users-en at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/gettext-users-en > > > > > > -- > > -- > > .:% Masao Mutoh > > _______________________________________________ > > gettext-users-en mailing list > > gettext-users-en at rubyforge.org > > http://rubyforge.org/mailman/listinfo/gettext-users-en -- -- .:% Masao Mutoh From edgargonzalez at gmail.com Wed Aug 23 14:22:33 2006 From: edgargonzalez at gmail.com (Edgar Gonzalez) Date: Wed, 23 Aug 2006 14:22:33 -0400 Subject: [gettext-u-en] Best way to freeze a GetText gem in a Rails application Message-ID: Hi, How is the best way to freeze a GetText gem in a Rails application? I have an application running with GetText 1.1.1 + Rails 1.0.0, and I want to deploy another application which one use GetText 1.7.0 + Rails 1.1.6 I know how to freeze Rails, but what is the best way to freeze GetText? Thanks -- Edgar Gonz?lez Gonz?lez E-mail: edgargonzalez at gmail.com http://vp.com.ve http://lacaraoscura.com http://rubycorner.com -- From mutoh at highway.ne.jp Wed Aug 23 20:08:46 2006 From: mutoh at highway.ne.jp (Masao Mutoh) Date: Thu, 24 Aug 2006 09:08:46 +0900 Subject: [gettext-u-en] Best way to freeze a GetText gem in a Rails application In-Reply-To: References: Message-ID: <20060824090846.01420385.mutoh@highway.ne.jp> Hi, Follow Gem way. http://docs.rubygems.org/read/chapter/4#page71 On Wed, 23 Aug 2006 14:22:33 -0400 "Edgar Gonzalez" wrote: > Hi, > > How is the best way to freeze a GetText gem in a Rails application? > > I have an application running with GetText 1.1.1 + Rails 1.0.0, and I > want to deploy another application which one use GetText 1.7.0 + Rails > 1.1.6 > > I know how to freeze Rails, but what is the best way to freeze GetText? > > Thanks > > -- > Edgar Gonz$(D+!(Blez Gonz$(D+!(Blez > E-mail: edgargonzalez at gmail.com > http://vp.com.ve > http://lacaraoscura.com > http://rubycorner.com > -- > _______________________________________________ > gettext-users-en mailing list > gettext-users-en at rubyforge.org > http://rubyforge.org/mailman/listinfo/gettext-users-en > -- -- .:% Masao Mutoh From kerforn56 at wanadoo.fr Thu Aug 31 11:33:58 2006 From: kerforn56 at wanadoo.fr (kerforn56) Date: Thu, 31 Aug 2006 17:33:58 +0200 Subject: [gettext-u-en] Engine Localization Message-ID: I am trying to localize the Login engine, almost done for messages... but as I cannot get the 'user' model fields localized I performed correctly the rake processes in the vendor/plugins/ login_engine, got the .pot/.po files and the locale/fr_FR/LC_MESSAGES complex trick comes from the login_engine/app/models/user.rb stating -----user.rb class User < ActiveRecord::Base include LoginEngine::AuthenticatedUser # all logic has been moved into login_engine/lib/login_engine/ authenticated_user.rb end -------------- ------login_engine/lib/login_engine/authenticated_user.rb require 'digest/sha1' # this model expects a certain database layout and its based on the name/login pattern. module LoginEngine module AuthenticatedUser def self.included(base) base.class_eval do # use the table name given set_table_name LoginEngine.config(:user_table) ........ attr_accessor :password, :password_confirmation N_("User|Password") # => the rake update.po got it N_("User|Password confirmation") # => the rake update.po got it ..... ------------------- why the rake update.po did not get the 'user' fields ? how can I make it right ? hereafter is the localized error panel : 5 erreurs ont empech? l'enregistrement 'user' d'?tre sauv? Il y a eu des probl?mes avec les champs suivants: * Mot de passe ne peut ?tre blanc * Login ne peut ?tre blanc * Email est invalide so the class name 'user' is not translated Login is not translated Email is not translated thanks for your help (special thanks to Museo who support me before I found this user-list ..) Yves