add signer user forms translations

This commit is contained in:
Pete Matsyburka
2024-01-09 01:25:11 +02:00
parent 4db77c18e3
commit 9356247ef0
11 changed files with 250 additions and 38 deletions
+17
View File
@@ -1,6 +1,8 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base
BROWSER_LOCALE_REGEXP = /\A\w{2}(?:-\w{2})?/
include ActiveStorage::SetCurrent
include Pagy::Backend
@@ -32,6 +34,21 @@ class ApplicationController < ActionController::Base
private
def with_browser_locale(&)
locale = request.env['HTTP_ACCEPT_LANGUAGE'].to_s[BROWSER_LOCALE_REGEXP].to_s
locale =
if locale.starts_with?('en-') && locale != 'en-US'
'en-GB'
else
locale.split('-').first.presence || 'en-GB'
end
locale = 'en-GB' unless I18n.locale_available?(locale)
I18n.with_locale(locale, &)
end
def sign_in_for_demo
sign_in(User.active.order('random()').take) unless signed_in?
end
+1
View File
@@ -6,6 +6,7 @@ class StartFormController < ApplicationController
skip_before_action :authenticate_user!
skip_authorization_check
around_action :with_browser_locale, only: %i[show completed]
before_action :load_template
def show
@@ -3,6 +3,7 @@
class SubmitFormController < ApplicationController
layout 'form'
around_action :with_browser_locale, only: %i[show completed]
skip_before_action :authenticate_user!
skip_authorization_check