blob: 396219bd696f4fa26027a83ee517c4b5cb3e2f31 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
module Internationalizationable
extend ActiveSupport::Concern
included do
around_action :with_time_zone, if: :current_user
around_action :with_locale
end
private
def with_time_zone
Time.use_zone(current_user.time_zone) { yield }
end
def with_locale
I18n.with_locale(current_locale) { yield }
end
def current_locale(locales = I18n.available_locales)
params[:locale] || http_accept_language.compatible_language_from(locales)
end
end
|