Class: Qbrick::Cms::BackendController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/qbrick/cms/backend_controller.rb

Instance Method Summary collapse

Instance Method Details

#default_url_optionsObject



29
30
31
# File 'app/controllers/qbrick/cms/backend_controller.rb', line 29

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

#reset_remembered_localeObject



23
24
25
26
27
# File 'app/controllers/qbrick/cms/backend_controller.rb', line 23

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

  I18n.locale = session.delete 'remembered_locale'
end

#set_content_localeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/qbrick/cms/backend_controller.rb', line 9

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