From f0bd4394869305fc6605463efff53ecc6ff61046 Mon Sep 17 00:00:00 2001 From: David Authier Date: Sun, 9 Apr 2017 18:40:24 +0200 Subject: Use HTTP Accept-Language to detect locale (#1166) * Use HTTP Accept-Language to detect locale * Fix gem order to comply with codeclimate * Sort gem to comply with rubocop * I18n.default_locale fallback when there is no accept-language header --- app/controllers/concerns/localized.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/concerns/localized.rb b/app/controllers/concerns/localized.rb index 6528ce45e..bcf3fd0a0 100644 --- a/app/controllers/concerns/localized.rb +++ b/app/controllers/concerns/localized.rb @@ -26,6 +26,8 @@ module Localized end def default_locale - ENV.fetch('DEFAULT_LOCALE') { I18n.default_locale } + ENV.fetch('DEFAULT_LOCALE') { + http_accept_language.compatible_language_from(I18n.available_locales) || I18n.default_locale + } end end -- cgit