2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-04 03:22:44 +08:00
|
|
|
class Rtl
|
2014-08-27 19:38:03 +08:00
|
|
|
attr_reader :user
|
|
|
|
|
|
|
|
def initialize(user)
|
|
|
|
@user = user
|
|
|
|
end
|
|
|
|
|
|
|
|
def enabled?
|
|
|
|
site_locale_rtl? || current_user_rtl?
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_user_rtl?
|
2019-11-27 04:01:37 +08:00
|
|
|
SiteSetting.allow_user_locale && (user&.locale || SiteSetting.default_locale).in?(rtl_locales)
|
2014-08-27 19:38:03 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def site_locale_rtl?
|
|
|
|
!SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(rtl_locales)
|
|
|
|
end
|
|
|
|
|
|
|
|
def rtl_locales
|
2016-12-04 12:17:51 +08:00
|
|
|
%w[he ar ur fa_IR]
|
2014-08-27 19:38:03 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def css_class
|
|
|
|
enabled? ? "rtl" : ""
|
|
|
|
end
|
|
|
|
end
|