From: Tom Hughes Date: Wed, 3 Jul 2019 08:49:46 +0000 (+0100) Subject: Fix styling of email notifications in RTL languages X-Git-Tag: live~2499 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/f9109b7a75f91c208a7b5f68cc64ba253a9041c5?hp=ee8ed3c682699e78fa5952b1ad554a09db546638 Fix styling of email notifications in RTL languages Fixes #2297 --- 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" ) %> -
+ <%= raw style_message(yield) %>
+ <%= body %>