about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorDavid Authier <aweaoftheworld@gmail.com>2017-04-09 18:40:24 +0200
committerEugen <eugen@zeonfederated.com>2017-04-09 18:40:24 +0200
commitf0bd4394869305fc6605463efff53ecc6ff61046 (patch)
tree41c43583d8f7300ec34d4c1dc327fcf0bf29bf77 /app
parentb16fbd52b2c5471d401dbfe397a3e7dbaaa21225 (diff)
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
Diffstat (limited to 'app')
-rw-r--r--app/controllers/concerns/localized.rb4
1 files changed, 3 insertions, 1 deletions
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