Home

Awesome

ActionMailer::LocalizedPreview

This gem extends ActionMailer::Preview to allow previews of emails in all available locales.

Usage

Simply include ActionMailer::LocalizedPreview in your preview class

require 'action_mailer/localized_preview'

class NotifierPreview < ActionMailer::Preview
  include ActionMailer::LocalizedPreview

  def account_confirmation
    account = Account.new(name: "Cosmo Kramer")
    Notifier.account_confirmation(account)
  end

end

Assuming that I18n.available_locales is set to [:en, :fr, :nl], it will make the following preview methods available:

If you want direct access to the current locale in your mailer preview method, you may add a parameter to your method signature and the locale will be passed on:

require 'action_mailer/localized_preview'

class NotifierPreview < ActionMailer::Preview
  include ActionMailer::LocalizedPreview

  def account_confirmation(locale)
    account = Account.new(name: "Cosmo Kramer", prefered_language: locale)
    Notifier.account_confirmation(account)
  end

end

Caveats

Installation

Add this line to your application's Gemfile:

gem 'actionmailer-localized_preview'

And then execute:

$ bundle

Or install it yourself as:

$ gem install actionmailer-localized_preview

Contributing

  1. Fork it ( https://github.com/xavier/actionmailer-localized_preview/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request