Merge pull request #5504 from betagouv/locate-with-ff
Localisation : quand le feature-flag `localization` est activé, la langue par défaut est choisie en fonction des préférences exprimées par le navigateur
This commit is contained in:
commit
7118fc88aa
4 changed files with 13 additions and 3 deletions
1
Gemfile
1
Gemfile
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -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?
|
||||||
|
|
Loading…
Reference in a new issue