discourse/app/models/rtl.rb

30 lines
456 B
Ruby
Raw Normal View History

2014-08-27 07:38:03 -04:00
class RTL
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.try(:locale).in?(rtl_locales)
end
def site_locale_rtl?
!SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(rtl_locales)
end
def rtl_locales
2015-04-06 16:06:46 -04:00
%w(he ar fa_IR)
2014-08-27 07:38:03 -04:00
end
def css_class
enabled? ? 'rtl' : ''
end
end