diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-01-29 00:22:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-29 00:22:20 +0100 |
commit | 79bc3d58456a850a7f2d99a2c0e15ff1618c1a0e (patch) | |
tree | 5bec2a3bf54ff6e840884771b2e8a49db11d6380 /app | |
parent | 106efba800a63d508aabdc661cb0551c2b82110c (diff) |
Add direction tags to HTML e-mails for RTL languages (#6373)
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/application_helper.rb | 10 | ||||
-rw-r--r-- | app/mailers/application_mailer.rb | 1 | ||||
-rw-r--r-- | app/mailers/user_mailer.rb | 1 | ||||
-rw-r--r-- | app/views/layouts/mailer.html.haml | 2 | ||||
-rw-r--r-- | app/views/notification_mailer/_status.html.haml | 5 |
5 files changed, 15 insertions, 4 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8ed5c8bda..bab4615a1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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" diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 683b60c86..bf161b9be 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -3,6 +3,7 @@ class ApplicationMailer < ActionMailer::Base layout 'mailer' + helper :application helper :instance helper :mailer diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 4104f6cd2..2fc9caba3 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -3,6 +3,7 @@ class UserMailer < Devise::Mailer layout 'mailer' + helper :application helper :instance add_template_helper RoutingHelper diff --git a/app/views/layouts/mailer.html.haml b/app/views/layouts/mailer.html.haml index 6687546fb..e401df10f 100644 --- a/app/views/layouts/mailer.html.haml +++ b/app/views/layouts/mailer.html.haml @@ -7,7 +7,7 @@ %title/ = stylesheet_pack_tag 'mailer' - %body + %body{ dir: locale_direction } %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody %tr diff --git a/app/views/notification_mailer/_status.html.haml b/app/views/notification_mailer/_status.html.haml index 727e914dc..f82ada146 100644 --- a/app/views/notification_mailer/_status.html.haml +++ b/app/views/notification_mailer/_status.html.haml @@ -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}") |