0
0
Fork 0

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
This commit is contained in:
David Authier 2017-04-09 18:40:24 +02:00 committed by Eugen
parent b16fbd52b2
commit f0bd439486
3 changed files with 25 additions and 20 deletions

View file

@ -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