discourse/lib/rtl.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
517 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class Rtl
2014-08-27 07:38:03 -04:00
attr_reader :user
def initialize(user)
@user = user
end
def enabled?
site_locale_rtl? || current_user_rtl?
end
def current_user_rtl?
SiteSetting.allow_user_locale && (user&.locale || SiteSetting.default_locale).in?(rtl_locales)
2014-08-27 07:38:03 -04:00
end
def site_locale_rtl?
!SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(rtl_locales)
end
def rtl_locales
%w(he ar ur fa_IR)
2014-08-27 07:38:03 -04:00
end
def css_class
enabled? ? 'rtl' : ''
end
end