class LanguagesController < ApplicationController

  before_action :set_locale_to_default
  helper_method :accept_language

  def index


  end


private

  def accept_language
    @accept_language ||= request.env['HTTP_ACCEPT_LANGUAGE'].to_s.split(',').map { |l|
      lang, q_factor = l.split(';q=')
      [lang, (q_factor || '1').to_f]
    }.sort_by { |_, q| -q }.map(&:first).first&.split('-')&.first
  end


  def set_locale_to_default
    I18n.locale = I18n.default_locale
  end

end
