diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index ae2f7e02..91cfca6c 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -33,7 +33,9 @@ class AccountsController < ApplicationController Docuseal.refresh_default_url_options! - redirect_to settings_account_path, notice: I18n.t('account_information_has_been_updated') + with_locale do + redirect_to settings_account_path, notice: I18n.t('account_information_has_been_updated') + end rescue ActiveRecord::RecordInvalid render :show, status: :unprocessable_entity end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 970c9d94..a5114318 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/setup_controller.rb b/app/controllers/setup_controller.rb index c6a08c58..9b49b1f8 100644 --- a/app/controllers/setup_controller.rb +++ b/app/controllers/setup_controller.rb @@ -56,7 +56,7 @@ class SetupController < ApplicationController def account_params return {} unless params[:account] - params.require(:account).permit(:name, :timezone) + params.require(:account).permit(:name, :timezone, :locale) end def encrypted_config_params diff --git a/app/javascript/form.js b/app/javascript/form.js index eca075ab..6d1eeaa7 100644 --- a/app/javascript/form.js +++ b/app/javascript/form.js @@ -21,6 +21,7 @@ safeRegisterElement('submission-form', class extends HTMLElement { isDemo: this.dataset.isDemo === 'true', attribution: this.dataset.attribution !== 'false', scrollPadding: this.dataset.scrollPadding || '-80px', + language: this.dataset.language, dryRun: this.dataset.dryRun === 'true', expand: ['true', 'false'].includes(this.dataset.expand) ? this.dataset.expand === 'true' : null, withSignatureId: this.dataset.withSignatureId === 'true', diff --git a/app/models/template.rb b/app/models/template.rb index 54d29a43..ec4ecec8 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -46,7 +46,7 @@ class Template < ApplicationRecord attribute :preferences, :string, default: -> { {} } attribute :fields, :string, default: -> { [] } attribute :schema, :string, default: -> { [] } - attribute :submitters, :string, default: -> { [{ name: DEFAULT_SUBMITTER_NAME, uuid: SecureRandom.uuid }] } + attribute :submitters, :string, default: -> { [{ name: I18n.t(:first_party), uuid: SecureRandom.uuid }] } attribute :slug, :string, default: -> { SecureRandom.base58(14) } attribute :source, :string, default: 'native' diff --git a/app/views/accounts/show.html.erb b/app/views/accounts/show.html.erb index e4d6e49f..2ea9a167 100644 --- a/app/views/accounts/show.html.erb +++ b/app/views/accounts/show.html.erb @@ -19,7 +19,7 @@
<%= ff.label :locale, t('language'), class: 'label' %> - <%= ff.select :locale, options_for_select(controller.class::LOCALE_OPTIONS.invert, current_account.locale), {}, class: 'base-select' %> + <%= ff.select :locale, options_for_select(AccountsController::LOCALE_OPTIONS.invert, current_account.locale), {}, class: 'base-select' %>
<% end %> diff --git a/app/views/esign_settings/_default_signature_row.html.erb b/app/views/esign_settings/_default_signature_row.html.erb index 387db8a1..4bfc2572 100644 --- a/app/views/esign_settings/_default_signature_row.html.erb +++ b/app/views/esign_settings/_default_signature_row.html.erb @@ -2,19 +2,19 @@ <%= svg_icon('discount_check_filled', class: 'w-6 h-6 text-green-500') %> - DocuSeal Trusted Signature -
+ <%= t('docuseal_trusted_signature') %> +
<%= svg_icon('circle_question', class: 'w-4 h-4 stroke-1') %>
" class="btn btn-neutral btn-sm text-white"> - Upgrade to Pro + <%= t('unlock_with_docuseal_pro') %> -
+
<%= button_to settings_esign_path, method: :put, params: { name: Docuseal::AATL_CERT_NAME }, class: 'btn btn-outline btn-neutral btn-xs whitespace-nowrap', title: t('make_default'), disabled: true do %> <%= t('make_default') %> <% end %> diff --git a/app/views/setup/index.html.erb b/app/views/setup/index.html.erb index dc9cbc25..f043513b 100644 --- a/app/views/setup/index.html.erb +++ b/app/views/setup/index.html.erb @@ -56,6 +56,12 @@ <%= ff.text_field :value, required: true, class: 'base-input' %>
<% end %> + <%= fields_for @account do |ff| %> +
+ <%= ff.label :locale, t('language'), class: 'label' %> + <%= ff.select :locale, options_for_select(AccountsController::LOCALE_OPTIONS.invert, @account.locale), {}, class: 'base-select' %> +
+ <% end %>
<%= f.button button_title, class: 'base-button' %> diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb index 328af108..0bb4c41d 100644 --- a/app/views/shared/_navbar.html.erb +++ b/app/views/shared/_navbar.html.erb @@ -26,7 +26,7 @@ -
<% end %> @@ -173,7 +177,7 @@