diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 16401e1f2..775afadbc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -32,7 +32,7 @@ module ApplicationHelper end def html_classes - "#{mobile_view? ? 'mobile-view' : 'desktop-view'} #{mobile_device? ? 'mobile-device' : 'not-mobile-device'} #{rtl_view? ? 'rtl' : ''}" + "#{mobile_view? ? 'mobile-view' : 'desktop-view'} #{mobile_device? ? 'mobile-device' : 'not-mobile-device'} #{RTL.html_class}" end def escape_unicode(javascript) @@ -124,21 +124,6 @@ module ApplicationHelper MobileDetection.mobile_device?(request.user_agent) end - def rtl_view? - site_default_rtl? || current_user_rtl? - end - - def current_user_rtl? - SiteSetting.allow_user_locale && current_user.try(:locale).in?(rtl_locales) - end - - def site_default_rtl? - !SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(rtl_locales) - end - - def rtl_locales - %w(he ar) - end def customization_disabled? controller.class.name.split("::").first == "Admin" || session[:disable_customization] diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index 6ada3e2e4..dec6fe7b1 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -198,7 +198,7 @@ class UserNotifications < ActionMailer::Base html = UserNotificationRenderer.new(Rails.configuration.paths["app/views"]).render( template: 'email/notification', format: :html, - locals: { context_posts: context_posts, post: post, top: top ? PrettyText.cook(top).html_safe : nil } + locals: { context_posts: context_posts, post: post, top: top ? PrettyText.cook(top).html_safe : nil, classes: RTL.html_class } ) template = "user_notifications.user_#{notification_type}" diff --git a/app/models/rtl.rb b/app/models/rtl.rb new file mode 100644 index 000000000..4fed8c917 --- /dev/null +++ b/app/models/rtl.rb @@ -0,0 +1,23 @@ +class RTL + + def self.enabled? + site_locale_rtl? || current_user_rtl? + end + + def self.current_user_rtl? + SiteSetting.allow_user_locale && current_user.try(:locale).in?(rtl_locales) + end + + def self.site_locale_rtl? + !SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(rtl_locales) + end + + def self.rtl_locales + %w(he ar) + end + + def self.html_class + enabled? ? 'rtl' : '' + end + +end diff --git a/app/views/email/notification.html.erb b/app/views/email/notification.html.erb index 8108cc693..363f2ae46 100644 --- a/app/views/email/notification.html.erb +++ b/app/views/email/notification.html.erb @@ -1,4 +1,4 @@ -