require "active_generator/base" require "generators/locale/base" module Locale class ControllerGenerator < 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_controller_file assert_valid_language! template("controller.yml", "config/locales/#{language}/controllers/#{namespace_path}/#{file_name}.yml") end end end if ActiveGenerator.configuration.autoload_controller_generator_locale begin require "rails/generators/rails/controller/controller_generator" Rails::Generators::ControllerGenerator.class_eval do def copy_controller_locale_file invoke("locale:controller", [name]) end end rescue LoadError => e # Skip over missing files end end