2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-03 14:22:44 -05:00
|
|
|
class Rtl
|
2024-06-08 14:24:39 -05:00
|
|
|
LOCALES = %w[ar fa_IR he ug ur]
|
|
|
|
|
2014-08-27 06:38:03 -05:00
|
|
|
attr_reader :user
|
|
|
|
|
|
|
|
def initialize(user)
|
|
|
|
@user = user
|
|
|
|
end
|
|
|
|
|
|
|
|
def enabled?
|
|
|
|
site_locale_rtl? || current_user_rtl?
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_user_rtl?
|
2024-06-08 14:24:39 -05:00
|
|
|
SiteSetting.allow_user_locale && (user&.locale || SiteSetting.default_locale).in?(LOCALES)
|
2014-08-27 06:38:03 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def site_locale_rtl?
|
2024-06-08 14:24:39 -05:00
|
|
|
!SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(LOCALES)
|
2014-08-27 06:38:03 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def css_class
|
2023-01-09 06:10:19 -06:00
|
|
|
enabled? ? "rtl" : ""
|
2014-08-27 06:38:03 -05:00
|
|
|
end
|
|
|
|
end
|