Skip to content

Commit

Permalink
Add header_instructions overridable translation for email headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltrout committed Dec 7, 2015
1 parent a3ba564 commit b781b6a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/views/email/notification.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<div id='main' class=<%= classes %>>

<div class='header-instructions'>%{header_instructions}</div>

<%= render partial: 'email/post', locals: { post: post } %>

<% if context_posts.present? %>
Expand Down
13 changes: 13 additions & 0 deletions config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Expand Down Expand Up @@ -1934,6 +1935,8 @@ en:
user_replied:
subject_template: "[%{site_name}] %{topic_title}"
text_body_template: |
%{header_instructions}
%{message}
%{context}
Expand All @@ -1944,6 +1947,8 @@ en:
user_quoted:
subject_template: "[%{site_name}] %{topic_title}"
text_body_template: |
%{header_instructions}
%{message}
%{context}
Expand All @@ -1954,6 +1959,8 @@ en:
user_mentioned:
subject_template: "[%{site_name}] %{topic_title}"
text_body_template: |
%{header_instructions}
%{message}
%{context}
Expand All @@ -1964,6 +1971,8 @@ en:
user_group_mentioned:
subject_template: "[%{site_name}] %{topic_title}"
text_body_template: |
%{header_instructions}
%{message}
%{context}
Expand All @@ -1974,6 +1983,8 @@ en:
user_posted:
subject_template: "[%{site_name}] %{topic_title}"
text_body_template: |
%{header_instructions}
%{message}
%{context}
Expand All @@ -1984,6 +1995,8 @@ en:
user_posted_pm:
subject_template: "[%{site_name}] [PM] %{topic_title}"
text_body_template: |
%{header_instructions}
%{message}
%{context}
Expand Down
10 changes: 10 additions & 0 deletions lib/email/message_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def initialize(to, opts=nil)
}.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
Expand Down Expand Up @@ -65,6 +67,14 @@ def html_part
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)
Expand Down

0 comments on commit b781b6a

Please sign in to comment.