Class: I18nAttributes::ReviseModelGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
GeneratorHelpers, VkillGemsMethods::Rails::Generators::Base
Defined in:
lib/generators/i18n_attributes/revise_model/revise_model_generator.rb

Constant Summary collapse

SUPPORTED_ORMS =
%w(active_model active_record mongoid)

Instance Method Summary collapse

Methods included from GeneratorHelpers

#generate_yaml_file_data

Instance Method Details

#create_model_i18n_fileObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/i18n_attributes/revise_model/revise_model_generator.rb', line 15

def create_model_i18n_file

  say_error "#{orm} [not found]" unless SUPPORTED_ORMS.include? options.orm.to_s

  ::ActiveRecord::Base.models do |model, columns|
    ::I18nAttributes::Configuration.locales.each do |locale|
      create_file "config/locales/model_#{ locale }/#{ model.name.underscore }.yml",
              generate_yaml_file_data(
                :locale => locale,
                :singular_name => model.model_name.underscore,
                :human_name => model.model_name,
                :attributes => columns,
                :model_i18n_scope => model.i18n_scope
              ){|word| say_info "translated attribute/model_name #{word}"}.yaml_file_data
    end
  end

end