discourse/lib/rtl.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

32 lines
490 B
Ruby

# frozen_string_literal: true
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
%w(he ar ur fa_IR)
end
def css_class
enabled? ? 'rtl' : ''
end
end