add traductions

This commit is contained in:
2021-04-24 23:46:16 +02:00
parent f43ba76984
commit 9082e5255e
62 changed files with 413 additions and 38 deletions

View File

@@ -2,11 +2,25 @@ class ApplicationController < ActionController::Base
around_action :switch_locale
def switch_locale(&action)
locale = I18n.locale_available?(request.headers['Locale']) ? request.headers['Locale'] : I18n.default_locale
locale = extract_locale
I18n.with_locale(locale, &action)
end
def new_session_path(_scope)
new_user_session_path
end
def extract_locale
if params[:locale]
I18n.locale_available?(params[:locale]) ? params[:locale] : I18n.default_locale
elsif request.env['HTTP_ACCEPT_LANGUAGE']
I18n.locale_available?(request.env['HTTP_ACCEPT_LANGUAGE']) ? request.env['HTTP_ACCEPT_LANGUAGE'] : I18n.default_locale
else
I18n.default_locale
end
end
def default_url_options
{ locale: I18n.locale }
end
end