Sha256: f0e0ce1e1b12d57bdd19b6664de965030b48538657dc9b3c9e63b1cafc9ed139

Contents?: true

Size: 1.11 KB

Versions: 13

Compression:

Stored size: 1.11 KB

Contents

module Qbrick
  module Cms
    class BackendController < ActionController::Base
      respond_to :html
      layout 'qbrick/cms/application'
      before_action :set_content_locale, :authenticate_admin!
      after_action :reset_remembered_locale

      def set_content_locale
        # this was taken from: https://github.com/screenconcept/hieronymus_shop/pull/218/files
        # and needs further work:
        # TODO: document how to implement in frontend
        # TODO: implement frontend part in our rails_template
        # TODO: add specs
        new_locale = params[:content_locale] || session['backend_locale'] || I18n.locale
        session['backend_locale'] = new_locale.to_s
        return if I18n.locale == new_locale || !I18n.locale_available?(new_locale)

        session['remembered_locale'] = I18n.locale
        I18n.locale = new_locale
      end

      def reset_remembered_locale
        return if session['remembered_locale'].blank?

        I18n.locale = session.delete 'remembered_locale'
      end

      def default_url_options
        { content_locale: I18n.locale }.merge(super)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
qbrick-2.7.1 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.7 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.6.10 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.6.9 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.6.8 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.6.7 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.6.6 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.6.5 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.6.4 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.6.3 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.6.2 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.6.1 app/controllers/qbrick/cms/backend_controller.rb
qbrick-2.6.0 app/controllers/qbrick/cms/backend_controller.rb