Set the default locale in config (#6580)

Previously the default locale was set by Localized concern for controllers,
but it was not enforced for mailers.

config is enforced throughout the application and an appropriate place to
set the default locale.
This commit is contained in:
Akihiko Odaki 2018-03-04 17:21:35 +09:00 committed by Eugen Rochko
parent 9110db41c5
commit 51d760960c
4 changed files with 28 additions and 51 deletions

View File

@ -17,11 +17,7 @@ module Localized
end end
def default_locale def default_locale
request_locale || env_locale || I18n.default_locale request_locale || I18n.default_locale
end
def env_locale
ENV['DEFAULT_LOCALE']
end end
def request_locale def request_locale
@ -29,12 +25,10 @@ module Localized
end end
def preferred_locale def preferred_locale
http_accept_language.preferred_language_from([env_locale]) || http_accept_language.preferred_language_from(I18n.available_locales)
http_accept_language.preferred_language_from(I18n.available_locales)
end end
def compatible_locale def compatible_locale
http_accept_language.compatible_language_from([env_locale]) || http_accept_language.compatible_language_from(I18n.available_locales)
http_accept_language.compatible_language_from(I18n.available_locales)
end end
end end

View File