1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-21 06:09:38 +02:00
Maybe/app/controllers/concerns/localize.rb

20 lines
438 B
Ruby
Raw Normal View History

module Localize
extend ActiveSupport::Concern
included do
around_action :switch_locale
around_action :switch_timezone
end
private
def switch_locale(&action)
locale = Current.family.try(:locale) || I18n.default_locale
I18n.with_locale(locale, &action)
end
def switch_timezone(&action)
timezone = Current.family.try(:timezone) || Time.zone
Time.use_zone(timezone, &action)
end
end