X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/418668a7daaaa100fc80be66fbac1a3537dcd1c1..85e99d3127e5febcf4698c9d2576f653775af787:/config/initializers/action_mailer.rb diff --git a/config/initializers/action_mailer.rb b/config/initializers/action_mailer.rb index 2ccc71ff4..e6ef8a1c8 100644 --- a/config/initializers/action_mailer.rb +++ b/config/initializers/action_mailer.rb @@ -5,15 +5,24 @@ ActionMailer::Base.smtp_settings = { :domain => 'localhost', } -# This will let you more easily use helpers based on url_for in your mailers. -ActionMailer::Base.default_url_options[:host] = APP_CONFIG['host'] +# Monkey patch to allow sending of messages in specific locales +module ActionMailer + class Base + adv_attr_accessor :locale + private + alias_method :old_render_message, :render_message -# Monkey patch to fix return-path bug in ActionMailer 2.2.2 -# Can be removed once we go to 2.3 -module Net - class SMTP - def sendmail(msgstr, from_addr, *to_addrs) - send_message(msgstr, from_addr.to_s.sub(/^<(.*)>$/, "\\1"), *to_addrs) + def render_message(method_name, body) + old_locale= I18n.locale + + begin + I18n.locale = @locale + message = old_render_message(method_name, body) + ensure + I18n.locale = old_locale + end + + message end end end