Thanks Walter,
I was using a trick :
class ActionMailer::Localized < ActionMailer::Base
private
# we override the template_path to render localized templates (since
rails does not support that :-( )
# This thing is not testable since you cannot access the instance of
a mailer...
def initialize_defaults(method_name)
super
@template = "#{method_name}.#{I18n.locale}"
end
end
seems to be a very bad idea... I'm moving to another folder
structure,
views
> user_mailer
> en_GB
> membership_renew.html.erb
> membership_renew.text.erb
> es_ES
> membership_renew.html.erb
> membership_renew.text.erb
so I need the template path to be:
@template = "#{ActionMailer::Base::template_root}/user_mailer/
{user.language || 'en_GB'}.erb"
where should I write it ? directly in the mailer method ?...
will it handle the formats : html/text ?
def membership_renew(user, membership, clip)
....
==> @template = "#{ActionMailer::Base::template_root}/user_mailer/
{user.language || 'en_GB'}/membership_renew.erb"
mail(:to => user.email, :subject => "Your Swing Analysis Request")
do |format|
format.html { render :layout => "/mailer/sbga_user_mail" }
format.text
end
end
On 21 mai, 22:07, Walter McGinnis <[email protected]> wrote:
> On May 21, 2011, at 11:55 PM, Erwin <[email protected]> wrote:
>
>
>
>
>
> > I agree , not very clear .... I was referring to mailer template
> > views
> > I tested many cases and it seems I need to define .en_GB views
> > ( including the locale)
>
> > I am using already the fallback...
> > config.i18n.fallbacks = true
> > config.i18n.default_locale = :en_EN
>
> > but I am concerned by mailer ? which seems to handle locale
> > differently. Here is a case :
>
> > I am logged in as current_user
> > I select :en_ES as locale for display
> > I visit the site ..
> > and I some point the system need to send a message to the site
> > admin...
>
> > as mailer views I MUST have templates like : welcome.en_GB.html.erb
> > and NOT welcome.html.erb
>
> Huh? That doesn't sound correct to me. Specifying the locale in the template
> filename seems very odd. Can you point me at documentation on where this
> would required?
>
>
>
>
>
> > On 20 mai, 22:02, comopasta Gr <[email protected]> wrote:
> >> Kad Kerforn wrote in post #999856:
>
> >>> [RAILS3]
>
> >>> I hesitate on how handling thelocaleview templates to default to
> >>> one language only ..
>
> >>> sending admin emails will go only to onelocale 'en_GB'
>
> >>> should I set it up into the template name and set I18n.localeto
> >>> 'en_GB'
>
> >>> membership_renew.en_GB.html.erb
>
> >>> OR
>
> >>> whatever localeis used , if I have :
>
> >>> membership_renew.html
>
> >>> it will be the default ?
>
> >> Hi, at least I didn't completely get your problem.
> >> The way I set a defaultlocaleis:
>
> >> config.i18n.fallbacks = true
> >> config.i18n.default_locale = :en
>
> >> I have 3 languages and if one translation is not found it fallback to
> >> english.
>
> >> But again, I maybe didn't get your goal.
>
> >> Cheers.
>
> >> --
> >> Posted viahttp://www.ruby-forum.com/.
>
> > --
> > 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 [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group
> > athttp://groups.google.com/group/rubyonrails-talk?hl=en.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.