aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer/delivery_job.rb
diff options
context:
space:
mode:
authorJohannes Opper <johannes.opper@gmail.com>2015-07-02 14:36:40 +0200
committerJohannes Opper <johannes.opper@gmail.com>2015-07-05 20:21:25 +0200
commitca2387eb0145c0b8639f06ac7acb642fb3755c72 (patch)
tree419ec4b65b40fd9e425581310a5891404a77f809 /actionmailer/lib/action_mailer/delivery_job.rb
parent776e5991a9abf11818cb803e80976cea8b454c17 (diff)
downloadrails-ca2387eb0145c0b8639f06ac7acb642fb3755c72.tar.gz
rails-ca2387eb0145c0b8639f06ac7acb642fb3755c72.tar.bz2
rails-ca2387eb0145c0b8639f06ac7acb642fb3755c72.zip
ActionMailer::MessageDelivery respects current I18n.locale
When #deliver_now is called all translations within the generated email will be looked up for the current I18n locale. I18n.locale = ‘de’ mail.deliver_now # Generates german email, correct In #enqueue_delivery the locale was not considered and the resulting job uses the default locale. I18n.locale = ‘de’ mail.deliver_later # Generate english email, incorrect In order to achieve a consistent behaviour the current locale is now always passed to `ActionMailer::DeliveryJob`.
Diffstat (limited to 'actionmailer/lib/action_mailer/delivery_job.rb')
-rw-r--r--actionmailer/lib/action_mailer/delivery_job.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/actionmailer/lib/action_mailer/delivery_job.rb b/actionmailer/lib/action_mailer/delivery_job.rb
index 52772af2d3..f008671a72 100644
--- a/actionmailer/lib/action_mailer/delivery_job.rb
+++ b/actionmailer/lib/action_mailer/delivery_job.rb
@@ -6,8 +6,10 @@ module ActionMailer
class DeliveryJob < ActiveJob::Base # :nodoc:
queue_as { ActionMailer::Base.deliver_later_queue_name }
- def perform(mailer, mail_method, delivery_method, *args) #:nodoc:
- mailer.constantize.public_send(mail_method, *args).send(delivery_method)
+ def perform(mailer, mail_method, delivery_method, locale, *args) #:nodoc:
+ I18n.with_locale(locale) do
+ mailer.constantize.public_send(mail_method, *args).send(delivery_method)
+ end
end
end
end