From f9109b7a75f91c208a7b5f68cc64ba253a9041c5 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 3 Jul 2019 09:49:46 +0100 Subject: [PATCH 1/1] Fix styling of email notifications in RTL languages Fixes #2297 --- app/helpers/notifier_helper.rb | 8 ++++++++ app/views/layouts/notifier.html.erb | 10 +++++----- app/views/notifier/_message_body.html.erb | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/helpers/notifier_helper.rb b/app/helpers/notifier_helper.rb index 1c2e5e654..cc99898aa 100644 --- a/app/helpers/notifier_helper.rb +++ b/app/helpers/notifier_helper.rb @@ -32,4 +32,12 @@ module NotifierHelper # we apply it once here, after the message has been composed. html.gsub(/

/, '

') end + + def style_left + I18n.t("html.dir") == "ltr" ? "left" : "right" + end + + def style_right + I18n.t("html.dir") == "ltr" ? "right" : "left" + end end diff --git a/app/views/layouts/notifier.html.erb b/app/views/layouts/notifier.html.erb index 21b4e35ce..a5a8420f0 100644 --- a/app/views/layouts/notifier.html.erb +++ b/app/views/layouts/notifier.html.erb @@ -1,4 +1,4 @@ - +"> @@ -8,7 +8,7 @@ <%# having width=100% on the table and then only a fixed width on the middle cell gives us a max-width that works in Outlook %> - +
<%# the "width: 100%" here looks wrong, but I couldn't find a better way of making Outlook give this cell full width %> - @@ -27,7 +27,7 @@
@@ -16,10 +16,10 @@ + <%# NB we need "text-decoration: none" twice: GMail only honours it on the but Outlook only on the %> - OpenStreetMap + OpenStreetMap
- diff --git a/app/views/notifier/_message_body.html.erb b/app/views/notifier/_message_body.html.erb index f8a4e2621..d572fb9d0 100644 --- a/app/views/notifier/_message_body.html.erb +++ b/app/views/notifier/_message_body.html.erb @@ -14,7 +14,7 @@ :target => "_blank", :rel => "noopener" ) %> - -- 2.43.2
+ <%= raw style_message(yield) %>
+ <%= body %>