Class: AlchemyI18n::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/alchemy_i18n/install/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descriptionObject



11
12
13
14
# File 'lib/generators/alchemy_i18n/install/install_generator.rb', line 11

def self.description
  locales = Alchemy::I18n.available_locales.to_sentence
  "Available locales are #{locales}"
end

Instance Method Details

#add_rails_i18nObject



40
41
42
43
44
# File 'lib/generators/alchemy_i18n/install/install_generator.rb', line 40

def add_rails_i18n
  environment do
    "config.i18n.available_locales = #{locales.inspect}"
  end
end

#add_russian_gemObject



46
47
48
49
50
# File 'lib/generators/alchemy_i18n/install/install_generator.rb', line 46

def add_russian_gem
  if locales.include?('ru')
    gem 'russian', '~> 0.6'
  end
end

#append_assetsObject



23
24
25
26
27
28
29
30
# File 'lib/generators/alchemy_i18n/install/install_generator.rb', line 23

def append_assets
  additional_locales.each do |locale|
    append_file 'vendor/assets/javascripts/alchemy/admin/all.js', <<~ASSETS
      //= require alchemy_i18n/#{locale}
      //= require select2_locale_#{locale}
    ASSETS
  end
end

#append_manifestObject



32
33
34
35
36
37
38
# File 'lib/generators/alchemy_i18n/install/install_generator.rb', line 32

def append_manifest
  additional_locales.each do |locale|
    append_file 'app/assets/config/manifest.js', <<~MANIFEST
      //= link tinymce/langs/#{locale}.js
    MANIFEST
  end
end