This commit is contained in:
Pete Matsyburka
2024-09-28 01:21:35 +03:00
committed by Oleksandr Turchyn
parent c7b08e8d30
commit 37bb987e3e
14 changed files with 90 additions and 42 deletions
+10 -10
View File
@@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
check_authorization unless: :devise_controller?
before_action :set_locale
around_action :with_locale
before_action :sign_in_for_demo, if: -> { Docuseal.demo? }
before_action :maybe_redirect_to_setup, unless: :signed_in?
before_action :authenticate_user!, unless: :devise_controller?
@@ -52,18 +52,18 @@ class ApplicationController < ActionController::Base
private
def set_locale
I18n.locale =
if Rails.env.development? && params[:locale].present?
params[:locale]
elsif current_user && current_account.locale.present?
current_account.locale.to_sym
else
I18n.default_locale
end
def with_locale(&)
return yield unless current_account
locale = params[:lang].presence if Rails.env.development?
locale ||= current_account.locale
I18n.with_locale(locale, &)
end
def with_browser_locale(&)
return yield if I18n.locale != :'en-US'
locale = params[:lang].presence
locale ||= request.env['HTTP_ACCEPT_LANGUAGE'].to_s[BROWSER_LOCALE_REGEXP].to_s