From 6f9c3abfbc79d8339eb99a0558d5c281b51feb71 Mon Sep 17 00:00:00 2001 From: lydiasan <> Date: Wed, 1 Sep 2021 15:52:24 +0200 Subject: [PATCH] i18n: display language selector on non-french accept-languages --- app/controllers/application_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 072c3f483..76c3583bc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -72,7 +72,11 @@ class ApplicationController < ActionController::Base alias_method :pundit_user, :current_account def localization_enabled? - ENV.fetch('LOCALIZATION_ENABLED', 'false') == 'true' || cookies[:locale].present? + ENV.fetch('LOCALIZATION_ENABLED', 'false') == 'true' || cookies[:locale].present? || !browser_prefers_french? + end + + def browser_prefers_french? + http_accept_language.compatible_language_from(I18n.available_locales) == 'fr' end def set_locale(locale)