localize email headers and footers based on I18n.fallbacks

pull/41/head
Martin Linkhorst 13 years ago
parent 95a8b4f51b
commit 3c5aaeeb77
  1. 20
      app/models/setting.rb
  2. 4
      app/views/layouts/mailer.text.html.erb
  3. 4
      app/views/layouts/mailer.text.plain.erb

@ -128,14 +128,20 @@ class Setting < ActiveRecord::Base
class_eval src, __FILE__, __LINE__
end
def self.localized_emails_header
self.emails_header[I18n.locale.to_s] || ''
end
def self.localized_emails_footer
self.emails_footer[I18n.locale.to_s] || ''
# this should be fixed with globalize plugin
[:emails_header, :emails_footer].each do |mail|
src = <<-END_SRC
def self.#{mail}
I18n.fallbacks[I18n.locale].each do |lang|
text = self[:#{mail}][lang.to_s]
return text unless text.blank?
end
''
end
END_SRC
class_eval src, __FILE__, __LINE__
end
# Helper that returns an array based on per_page_options setting
def self.per_page_options_array
per_page_options.split(%r{[\s,]}).collect(&:to_i).select {|n| n > 0}.sort

@ -31,11 +31,11 @@ blockquote {
</style>
</head>
<body>
<span class="header"><%= Redmine::WikiFormatting.to_html(Setting.text_formatting, Setting.localized_emails_header) %></span>
<span class="header"><%= Redmine::WikiFormatting.to_html(Setting.text_formatting, Setting.emails_header) %></span>
<%= call_hook(:view_layouts_mailer_html_before_content, self.assigns) %>
<%= yield %>
<%= call_hook(:view_layouts_mailer_html_after_content, self.assigns) %>
<hr />
<span class="footer"><%= Redmine::WikiFormatting.to_html(Setting.text_formatting, Setting.localized_emails_footer) %></span>
<span class="footer"><%= Redmine::WikiFormatting.to_html(Setting.text_formatting, Setting.emails_footer) %></span>
</body>
</html>

@ -1,6 +1,6 @@
<%= Setting.localized_emails_header %>
<%= Setting.emails_header %>
<%= call_hook(:view_layouts_mailer_plain_before_content, self.assigns) %>
<%= yield %>
<%= call_hook(:view_layouts_mailer_plain_after_content, self.assigns) %>
--
<%= Setting.localized_emails_footer %>
<%= Setting.emails_footer %>

Loading…
Cancel
Save