2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-08-17 18:04:11 +08:00
discourse/lib/rtl.rb

27 lines
494 B
Ruby

# frozen_string_literal: true
class Rtl
LOCALES = %w[ar fa_IR he ug ur]
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?(LOCALES)
end
def site_locale_rtl?
!SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(LOCALES)
end
def css_class
enabled? ? "rtl" : ""
end
end