diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/concerns/localized.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/app/controllers/concerns/localized.rb b/app/controllers/concerns/localized.rb index 5501b6793..a9ea60f7d 100644 --- a/app/controllers/concerns/localized.rb +++ b/app/controllers/concerns/localized.rb @@ -17,12 +17,24 @@ module Localized end def default_locale - ENV.fetch('DEFAULT_LOCALE') do - user_supplied_locale || I18n.default_locale - end + request_locale || env_locale || I18n.default_locale end - def user_supplied_locale - http_accept_language.language_region_compatible_from(I18n.available_locales) + def env_locale + ENV['DEFAULT_LOCALE'] + end + + def request_locale + preferred_locale || compatible_locale + end + + def preferred_locale + http_accept_language.preferred_language_from([env_locale]) || + http_accept_language.preferred_language_from(I18n.available_locales) + end + + def compatible_locale + http_accept_language.compatible_language_from([env_locale]) || + http_accept_language.compatible_language_from(I18n.available_locales) end end |