Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ApplicationController < ActionController::Base
- protected
- def set_locale
- session[:locale] = params[:locale] if params[:locale]
- I18n.locale = session[:locale] || I18n.default_locale
- locale_path = "#{LOCALES_DIRECTORY}#{I18n.locale}.yml"
- unless I18n.load_path.include? locale_path
- I18n.load_path << locale_path
- I18n.backend.send(:init_translations)
- end
- rescue Exception => err
- logger.error err
- flash.now[:notice] = "#{I18n.locale} translation not available"
- I18n.load_path -= [locale_path]
- I18n.locale = session[:locale] = I18n.default_locale
- end
- end
- end
Add Comment
Please, Sign In to add comment