I do not.
I’ll enclose snippets from my setup with what may help you out with
getting it to work. There are snippets not included for the actual
setting of the locale which I’ll assume you have since you have this
working elsewhere.
One note is that I have my controller, model and view one directory
level deeper than you likely do. This won’t affect success, but does
affect the directory paths, etc that you see below.
RAILS_ROOT/app/controllers/application.rb:
…
require ‘gettext/rails’
…
RAILS_ROOT/app/controllers/netreport/report_controller.rb:
…
def emailreport
...
Netreport::Reporter.deliver_emailreport(@user, @locale)
...
end
…
RAILS_ROOT/app/models/netreport/reporter.rb:
class Netreport::Reporter < ActionMailer::Base
…
def emailreport(user, locale)
require 'iconv'
ActionMailer::Base.default_charset = “iso-8859-1”
C = Iconv.new('ISO-8859-1', 'UTF-8')
...
NR_setlocale(locale)
@subject = C.iconv(_("My subject"))
hash_body = {"user" => user, "locale" => locale}
@body = C.iconv(render_message("emailreport", hash_body))
...
end
…
RAILS_ROOT/app/views/netreport/reporter/emailreport.rhtml:
…
NR_setlocale(@locale)
_("Report for ")
…
Non gettext related notes are that we use iconv for translated emails at
present because several web mail providers are very inconsistent with
presentation of UTF8 character encoded emails. This did and will work
w/o needing to use iconv, but I don’t have the time today to revert back
to our previous code to make sure the snippets I post are working. I
know the above are, as they are in production right now. Make sure you
set the locale in the view, or you could very well not get the proper
translations.
Myk OLeary - [email protected]
Web Services Developer
Pure Networks - http://www.purenetworks.com