Sha256: 5f8157168195a6d161315a4cbe128982892fa7549e8c45d6ae5352c78752a23e

Contents?: true

Size: 862 Bytes

Versions: 1

Compression:

Stored size: 862 Bytes

Contents

require "active_generator/base"
require "generators/locale/base"

module Locale
  class MailerGenerator < Rails::Generators::NamedBase
    include ActiveGenerator::Base
    include Locale::Base

    source_root File.expand_path('../templates', __FILE__)
    argument :language, type: :string, required: false, default: "en", desc: "The locale alpha code"

    def copy_mailer_file
      assert_valid_language!
      template("mailer.yml", "config/locales/#{language}/mailers/#{file_name}.yml")
    end

  end
end

if ActiveGenerator.configuration.autoload_mailer_generator_locale
  begin
    require "rails/generators/rails/mailer/mailer_generator"

    Rails::Generators::MailerGenerator.class_eval do
      def generate_mailer_locale_file
        invoke("locale:mailer", [name])
      end
    end
  rescue LoadError => e
    # Skip over missing files
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_generator-2.0.11 lib/generators/locale/mailer/mailer_generator.rb