diff options
author | foxiehkins <foxiehkins@gmail.com> | 2017-04-07 14:01:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-07 14:01:20 +0100 |
commit | 41396de7a90f23dd0afe1afa3dab1be43b7b6ecd (patch) | |
tree | 5cacec3a442a671990f972196fa90c90903e83cf /app/controllers/concerns | |
parent | ac1989d2c07b707699641987d62697103698393c (diff) | |
parent | 4e41cd9ab8f51120d558b70528b163c98993be53 (diff) |
Merge branch 'master' into master
Diffstat (limited to 'app/controllers/concerns')
-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 |