Rails3 mailer how to use a safe mailer not taking in account the I18n.locale

in a multilingual site dev, I need to send localized emails…
as I need to define the @template in the mailer method, I don’t want
to take in account the I18n.locale:

I wrote in my mailer method

def welcome(user, message)
  @user = user
  language = user.language  # es_ES testing
  @template = "#{ActionMailer::Base::template_root}/user_mailer/

#{language}/welcome"
@message = message
mail(:to => user.email, :subject => “Welcome”) do |format|
format.html { render :layout => “/mailer/
sbga_user_mail”, :template => @template }
format.text {render :layout => false, :template =>
@template}
end
end

and I have the views :
views
----- user_mailer
---------- -en_GB
--------------- welcome.html.erb
--------------- welcome.text.erb
--------- -es_ES
--------------- welcome.html.erb
--------------- welcome.text.erb

but sending an email to a Spanish user,
UserMailer.welcome(current_user, “Lorem ipsum dolor”).deliver , with
I18n.locale = :en_GB raises an error :

ActionView::MissingTemplate: Missing template /Users/yves/Sites/rails/
testsbga/app/views/user_mailer/es_ES/welcome with
{:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml, :haml],
:formats=>[:html], :locale=>[:en_GB]}
in view paths

as I18n.locale is defined to :en_GB…
it seems to be looking for welcome.en_GB.html.erb in /views/
user_mailer/es_ES/

how can I inform mailer that I don’t want to use locale views … ?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs