Guest User

Untitled

a guest
Jun 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. class ApplicationController < ActionController::Base
  2.  
  3. protected
  4. def set_locale
  5. session[:locale] = params[:locale] if params[:locale]
  6. I18n.locale = session[:locale] || I18n.default_locale
  7. locale_path = "#{LOCALES_DIRECTORY}#{I18n.locale}.yml"
  8. unless I18n.load_path.include? locale_path
  9. I18n.load_path << locale_path
  10. I18n.backend.send(:init_translations)
  11. end
  12. rescue Exception => err
  13. logger.error err
  14. flash.now[:notice] = "#{I18n.locale} translation not available"
  15. I18n.load_path -= [locale_path]
  16. I18n.locale = session[:locale] = I18n.default_locale
  17. end
  18. end
  19. end
Add Comment
Please, Sign In to add comment