diff options
author | Shel R <Yiskah.Raphen@gmail.com> | 2017-04-07 21:34:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-07 21:34:41 -0400 |
commit | bc237d17a71320829dce55d8dca4013d5f772665 (patch) | |
tree | 006e8e3df6d3ba1e9967c32cc7d27885d0a19914 /app/controllers/concerns/localized.rb | |
parent | c441208e29cc86cbf514851879bdaa9130351b22 (diff) | |
parent | a872f2f4c64f4a370fa1a92a28f9c07c1dd3b06d (diff) |
Merge branch 'master' into patch-1
Diffstat (limited to 'app/controllers/concerns/localized.rb')
-rw-r--r-- | app/controllers/concerns/localized.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/controllers/concerns/localized.rb b/app/controllers/concerns/localized.rb new file mode 100644 index 000000000..b6f868090 --- /dev/null +++ b/app/controllers/concerns/localized.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Localized + extend ActiveSupport::Concern + + included do + before_action :set_locale + end + + def set_locale + I18n.locale = current_user.try(:locale) || default_locale + rescue I18n::InvalidLocale + I18n.locale = default_locale + end + + def default_locale + ENV.fetch('DEFAULT_LOCALE') { I18n.default_locale } + end +end |