Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[39835] Actually localize the announcement mail

Oliver Günther2ef8ac543163
diff --git a/app/mailers/announcement_mailer.rb b/app/mailers/announcement_mailer.rb
index 8ef95ff3da3..eff36740452 100644
--- a/app/mailers/announcement_mailer.rb
+++ b/app/mailers/announcement_mailer.rb
@@ -37,14 +37,16 @@ class AnnouncementMailer < ApplicationMailer
def announce(user, subject:, body:, body_header: nil, body_subheader: nil)
with_locale_for(user) do
+ localized_subject = localized(subject)
+
mail to: user.mail,
- subject: subject do |format|
+ subject: localized_subject do |format|
locals = {
- body: body,
+ body: localized(body),
user: user,
- header_summary: subject,
- body_header: body_header,
- body_subheader: body_subheader
+ header_summary: localized_subject,
+ body_header: localized(body_header),
+ body_subheader: localized(body_subheader)
}
format.html { render locals: locals }
@@ -52,4 +54,14 @@ class AnnouncementMailer < ApplicationMailer
end
end
end
+
+ private
+
+ def localized(input)
+ if input.is_a?(Symbol)
+ I18n.t(input)
+ else
+ input
+ end
+ end
end
diff --git a/db/migrate/20211105142202_queue_notification_update_mail.rb b/db/migrate/20211105142202_queue_notification_update_mail.rb
index 33358069a1a..52c9c949a64 100644
--- a/db/migrate/20211105142202_queue_notification_update_mail.rb
+++ b/db/migrate/20211105142202_queue_notification_update_mail.rb
@@ -1,9 +1,9 @@
class QueueNotificationUpdateMail < ActiveRecord::Migration[6.1]
def up
::Announcements::SchedulerJob
- .perform_later subject: I18n.t(:'notifications.update_info_mail.subject'),
- body: I18n.t(:'notifications.update_info_mail.body'),
- body_header: I18n.t(:'notifications.update_info_mail.body_header'),
- body_subheader: I18n.t(:'notifications.update_info_mail.body_subheader')
+ .perform_later subject: :'notifications.update_info_mail.subject',
+ body: :'notifications.update_info_mail.body',
+ body_header: :'notifications.update_info_mail.body_header',
+ body_subheader: :'notifications.update_info_mail.body_subheader'
end
end