Class: Rtl

Inherits:
Object
  • Object
show all
Defined in:
lib/rtl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Rtl

Returns a new instance of Rtl.



6
7
8
# File 'lib/rtl.rb', line 6

def initialize(user)
  @user = user
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'lib/rtl.rb', line 4

def user
  @user
end

Instance Method Details

#css_classObject



26
27
28
# File 'lib/rtl.rb', line 26

def css_class
  enabled? ? "rtl" : ""
end

#current_user_rtl?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rtl.rb', line 14

def current_user_rtl?
  SiteSetting.allow_user_locale && (user&.locale || SiteSetting.default_locale).in?(rtl_locales)
end

#enabled?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/rtl.rb', line 10

def enabled?
  site_locale_rtl? || current_user_rtl?
end

#rtl_localesObject



22
23
24
# File 'lib/rtl.rb', line 22

def rtl_locales
  %w[he ar ur fa_IR]
end

#site_locale_rtl?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rtl.rb', line 18

def site_locale_rtl?
  !SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(rtl_locales)
end