gem http_accept_language installed and (de)activable with feature flag

This commit is contained in:
Judith 2020-08-27 11:37:03 +02:00 committed by Pierre de La Morinerie
parent ea16e71a8d
commit af25fdd77c
4 changed files with 13 additions and 3 deletions

View file

@ -40,6 +40,7 @@ gem 'graphql_playground-rails'
gem 'groupdate' gem 'groupdate'
gem 'haml-rails' gem 'haml-rails'
gem 'hashie' gem 'hashie'
gem 'http_accept_language'
gem 'jquery-rails' # Use jquery as the JavaScript library gem 'jquery-rails' # Use jquery as the JavaScript library
gem 'jwt' gem 'jwt'
gem 'kaminari', '1.2.1' # Pagination gem 'kaminari', '1.2.1' # Pagination

View file

@ -19,6 +19,7 @@ class ApplicationController < ActionController::Base
before_action :set_active_storage_host before_action :set_active_storage_host
before_action :setup_javascript_settings before_action :setup_javascript_settings
before_action :setup_tracking before_action :setup_tracking
before_action :set_locale
helper_method :multiple_devise_profile_connect?, :instructeur_signed_in?, :current_instructeur, helper_method :multiple_devise_profile_connect?, :instructeur_signed_in?, :current_instructeur,
:administrateur_signed_in?, :current_administrateur, :current_account :administrateur_signed_in?, :current_administrateur, :current_account
@ -299,4 +300,10 @@ class ApplicationController < ActionController::Base
def current_email def current_email
current_user&.email current_user&.email
end end
def set_locale
if feature_enabled?(:localization)
I18n.locale = http_accept_language.compatible_language_from(I18n.available_locales)
end
end
end end

View file

@ -25,11 +25,12 @@ module TPS
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
config.time_zone = 'Paris' config.time_zone = 'Paris'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # The default locale is :fr and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :fr config.i18n.default_locale = :fr
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
config.i18n.available_locales = [:fr] config.i18n.available_locales = [:fr, :en]
config.i18n.fallbacks = [:fr]
config.assets.paths << Rails.root.join('app', 'assets', 'javascript') config.assets.paths << Rails.root.join('app', 'assets', 'javascript')
config.assets.paths << Rails.root.join('app', 'assets', 'fonts') config.assets.paths << Rails.root.join('app', 'assets', 'fonts')

View file

@ -36,7 +36,8 @@ features = [
:operation_log_serialize_subject, :operation_log_serialize_subject,
:pre_maintenance_mode, :pre_maintenance_mode,
:xray, :xray,
:carte_ign :carte_ign,
:localization
] ]
def database_exists? def database_exists?