From b781b6aea3e74f4fcdd6c97bdddeea07c5fb07ab Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 7 Dec 2015 16:52:10 -0500 Subject: [PATCH] Add `header_instructions` overridable translation for email headers. --- app/views/email/notification.html.erb | 2 ++ config/locales/server.en.yml | 13 +++++++++++++ lib/email/message_builder.rb | 10 ++++++++++ 3 files changed, 25 insertions(+) diff --git a/app/views/email/notification.html.erb b/app/views/email/notification.html.erb index bf5e2869c04..044de835272 100644 --- a/app/views/email/notification.html.erb +++ b/app/views/email/notification.html.erb @@ -1,5 +1,7 @@
> +
%{header_instructions}
+ <%= render partial: 'email/post', locals: { post: post } %> <% if context_posts.present? %> diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index d035d192fce..a2aa0612f23 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1894,6 +1894,7 @@ en: title: "Unsubscribe" description: "Not interested in getting these emails? No problem! Click below to unsubscribe instantly:" + header_instructions: '' reply_by_email: "To respond, reply to this email or [visit the topic](%{base_url}%{url}) in your browser." visit_link_to_respond: "To respond, [visit the topic](%{base_url}%{url}) in your browser." @@ -1934,6 +1935,8 @@ en: user_replied: subject_template: "[%{site_name}] %{topic_title}" text_body_template: | + %{header_instructions} + %{message} %{context} @@ -1944,6 +1947,8 @@ en: user_quoted: subject_template: "[%{site_name}] %{topic_title}" text_body_template: | + %{header_instructions} + %{message} %{context} @@ -1954,6 +1959,8 @@ en: user_mentioned: subject_template: "[%{site_name}] %{topic_title}" text_body_template: | + %{header_instructions} + %{message} %{context} @@ -1964,6 +1971,8 @@ en: user_group_mentioned: subject_template: "[%{site_name}] %{topic_title}" text_body_template: | + %{header_instructions} + %{message} %{context} @@ -1974,6 +1983,8 @@ en: user_posted: subject_template: "[%{site_name}] %{topic_title}" text_body_template: | + %{header_instructions} + %{message} %{context} @@ -1984,6 +1995,8 @@ en: user_posted_pm: subject_template: "[%{site_name}] [PM] %{topic_title}" text_body_template: | + %{header_instructions} + %{message} %{context} diff --git a/lib/email/message_builder.rb b/lib/email/message_builder.rb index 2e875a69e59..665c1455de9 100644 --- a/lib/email/message_builder.rb +++ b/lib/email/message_builder.rb @@ -28,6 +28,8 @@ module Email }.merge!(@opts) if @template_args[:url].present? + @template_args[:header_instructions] = I18n.t('user_notifications.header_instructions') + if @opts[:include_respond_instructions] == false @template_args[:respond_instructions] = '' else @@ -65,6 +67,14 @@ module Email html_override.gsub!("%{unsubscribe_link}", "") end + header_instructions = @template_args[:header_instructions] + if header_instructions.present? + header_instructions = PrettyText.cook(header_instructions).html_safe + html_override.gsub!("%{header_instructions}", header_instructions) + else + html_override.gsub!("%{header_instructions}", "") + end + if response_instructions = @template_args[:respond_instructions] respond_instructions = PrettyText.cook(response_instructions).html_safe html_override.gsub!("%{respond_instructions}", respond_instructions)