Browse Source

Add direction tags to HTML e-mails for RTL languages (#6373)

pull/4/head
Eugen Rochko 6 years ago
committed by GitHub
parent
commit
79bc3d5845
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 4 deletions
  1. +9
    -1
      app/helpers/application_helper.rb
  2. +1
    -0
      app/mailers/application_mailer.rb
  3. +1
    -0
      app/mailers/user_mailer.rb
  4. +1
    -1
      app/views/layouts/mailer.html.haml
  5. +3
    -2
      app/views/notification_mailer/_status.html.haml

+ 9
- 1
app/helpers/application_helper.rb View File

@ -22,10 +22,18 @@ module ApplicationHelper
end
def add_rtl_body_class(other_classes)
other_classes = "#{other_classes} rtl" if [:ar, :fa, :he].include?(I18n.locale)
other_classes = "#{other_classes} rtl" if locale_direction == 'rtl'
other_classes
end
def locale_direction
if [:ar, :fa, :he].include?(I18n.locale)
'rtl'
else
'ltr'
end
end
def favicon_path
env_suffix = Rails.env.production? ? '' : '-dev'
"/favicon#{env_suffix}.ico"

+ 1
- 0
app/mailers/application_mailer.rb View File

@ -3,6 +3,7 @@
class ApplicationMailer < ActionMailer::Base
layout 'mailer'
helper :application
helper :instance
helper :mailer

+ 1
- 0
app/mailers/user_mailer.rb View File

@ -3,6 +3,7 @@
class UserMailer < Devise::Mailer
layout 'mailer'
helper :application
helper :instance
add_template_helper RoutingHelper

+ 1
- 1
app/views/layouts/mailer.html.haml View File

@ -7,7 +7,7 @@
%title/
= stylesheet_pack_tag 'mailer'
%body
%body{ dir: locale_direction }
%table.email-table{ cellspacing: 0, cellpadding: 0 }
%tbody
%tr

+ 3
- 2
app/views/notification_mailer/_status.html.haml View File

@ -1,6 +1,6 @@
- i ||= 0
%table.email-table{ cellspacing: 0, cellpadding: 0 }
%table.email-table{ cellspacing: 0, cellpadding: 0, dir: 'ltr' }
%tbody
%tr
%td.email-body
@ -24,7 +24,8 @@
%bdi= display_name(status.account)
= "@#{status.account.acct}"
= Formatter.instance.format(status)
%div{ dir: rtl_status?(status) ? 'rtl' : 'ltr' }
= Formatter.instance.format(status)
%p.status-footer
= link_to l(status.created_at), web_url("statuses/#{status.id}")

Loading…
Cancel
Save