Sha256: 1ec712ab34f93ab87462071a5dfba1d4f94fab17b8b13bfb6443edafb22c01b2

Contents?: true

Size: 817 Bytes

Versions: 3

Compression:

Stored size: 817 Bytes

Contents

# encoding: utf-8

module PagesCore
  class ApplicationController < ActionController::Base
    include PagesCore::Authentication
    include PagesCore::DomainBasedCache
    include PagesCore::ExceptionHandler
    include PagesCore::ProcessTitler
    include PagesCore::PoliciesHelper

    before_action :set_locale
    after_action :set_content_language_header

    protected

    # Sets @locale from params[:locale], with I18n.default_locale as fallback
    def set_locale
      legacy_locales = {
        "nor" => "nb",
        "eng" => "en"
      }
      @locale = params[:locale] || I18n.default_locale.to_s
      @locale = legacy_locales[@locale] if legacy_locales[@locale]
    end

    def set_content_language_header
      return unless locale
      headers["Content-Language"] = locale.to_s
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pages_core-3.4.3 app/controllers/pages_core/application_controller.rb
pages_core-3.5.1 app/controllers/pages_core/application_controller.rb
pages_core-3.4.2 app/controllers/pages_core/application_controller.rb