Skip to content

Instantly share code, notes, and snippets.

@Sija
Created July 1, 2015 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sija/ace2efa3aedba9292528 to your computer and use it in GitHub Desktop.
Save Sija/ace2efa3aedba9292528 to your computer and use it in GitHub Desktop.
Make Rails' 4.2 ActionMailer locale aware or i18n for ya emailz
module ActionMailer
class MessageDelivery
private
def enqueue_delivery(delivery_method, options={})
args = @mailer.name, @mail_method.to_s, delivery_method.to_s, I18n.locale.to_s, *@args
ActionMailer::DeliveryJob.set(options).perform_later(*args)
end
end
class DeliveryJob
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
@Sija
Copy link
Author

Sija commented Jul 1, 2015

This should ideally land in upstream or even in ActiveJob. And since it's possible to support it transparently to the user... @rails team, could we plz? :)

@seuros
Copy link

seuros commented Jul 1, 2015

Send a pull request with tests so everybody can see it.

@Sija
Copy link
Author

Sija commented Aug 20, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment