Class: Tao::Generators::LocaleGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Tao::Generators::LocaleGenerator
- Defined in:
- lib/generators/tao/locale/locale_generator.rb
Instance Attribute Summary collapse
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
Instance Method Summary collapse
Instance Attribute Details
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
11 12 13 |
# File 'lib/generators/tao/locale/locale_generator.rb', line 11 def locale @locale end |
Instance Method Details
#copy_to_model ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/generators/tao/locale/locale_generator.rb', line 13 def copy_to_model return unless [:model] locales.each do |locale| @locale = locale template "model.yml.erb", File.join('config/locales/models', name.pluralize, "#{locale}.yml") end end |
#copy_to_view ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/generators/tao/locale/locale_generator.rb', line 21 def copy_to_view return unless [:view] file_content = (class_path + [plural_name]).reverse.inject(nil) do |content, path| { path => content } end locales.each do |locale| @locale = locale create_file File.join('config/locales/views', name.pluralize, "#{locale}.yml"), {locale => file_content}.to_yaml end end |