lib/generators/toronto/install/install_generator.rb in toronto-0.0.2 vs lib/generators/toronto/install/install_generator.rb in toronto-0.0.3
- old
+ new
@@ -42,20 +42,21 @@
end
def copy_locale_files
copy_file 'config/initializers/locales.rb', 'config/initializers/locales.rb'
copy_file 'controllers/locales_controller.rb', 'app/controllers/locales_controller.rb'
+ end
+ def patch_locale_files
# TODO : use a template file
data = %{
def set_locale
I18n.locale = session[:locale] || I18n.default_locale
end
}
insert_into_file 'app/controllers/application_controller.rb', data, :before => /^end/
data = "\n before_action :set_locale"
-
insert_into_file 'app/controllers/application_controller.rb', data, :after => /^class ApplicationController < ActionController::Base/
end
def inject_locales_route
route = "\n put 'set_locale/:locale', constraints: { locale: /en|fr/ }, to: 'locales#set'\n"