Class: TranslationCenter::AddLangGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- TranslationCenter::AddLangGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/translation_center/add_lang/add_lang_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(path) ⇒ Object
8 9 10 |
# File 'lib/generators/translation_center/add_lang/add_lang_generator.rb', line 8 def self.next_migration_number(path) @migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S%6N").to_i.to_s end |
Instance Method Details
#add_lang ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/generators/translation_center/add_lang/add_lang_generator.rb', line 12 def add_lang if langs.blank? puts 'Please provide a language to add to the translation center' return end langs.each do |lang| @lang = lang # check if language already supported if(TranslationCenter::TranslationKey.column_names.include? "#{lang.downcase.gsub("-","_")}_status") puts 'This language is already supported, just make sure it is listed in config/translation_center.yml' return end # Generate migration templates for the models needed migration_template 'migrations/add_lang_status_translation_keys.rb', "db/migrate/add_#{lang.downcase.gsub("-","_")}_status_translation_center_translation_keys.rb" end puts "Language(s) added, don't forget to add the language(s) to config/translation_center.yml" end |