Class: I18nAttributes::ModelGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
GeneratorHelpers, VkillGemsMethods::Rails::Generators::Base
Defined in:
lib/generators/i18n_attributes/model/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
# File 'lib/generators/i18n_attributes/model/model_generator.rb', line 15

def create_model_i18n_file

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

  I18nAttributes::Configuration.locales.each do |locale|
    create_file "config/locales/model_#{ locale }/#{ file_name }.yml",
            generate_yaml_file_data(
              :locale => locale,
              :singular_name => singular_name,
              :human_name => human_name,
              :attributes => attributes_hash(),
              :model_i18n_scope => model_i18n_scope()
            ){|word| say_info "translated attribute/model_name #{word}"}.yaml_file_data
  end

end