From cd9f7df502e5a7c2fc95449caa3fba91be506190 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 1 Sep 2021 18:51:29 +0200 Subject: [PATCH] feat(i18n): send dossier notifications with its user locale --- app/mailers/notification_mailer.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index 056240dc2..d3c5324f1 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -22,7 +22,9 @@ class NotificationMailer < ApplicationMailer @logo_url = attach_logo(@dossier.procedure) @rendered_template = sanitize(@body) - mail(subject: @subject, to: @email, template_name: 'send_notification') + I18n.with_locale(@dossier.user_locale) do + mail(subject: @subject, to: @email, template_name: 'send_notification') + end end def self.send_en_construction_notification(dossier) @@ -53,12 +55,14 @@ class NotificationMailer < ApplicationMailer if @dossier.user_deleted? mail.perform_deliveries = false else - mail_template = @dossier.procedure.mail_template_for(params[:state]) + I18n.with_locale(@dossier.user_locale) do + mail_template = @dossier.procedure.mail_template_for(params[:state]) - @email = @dossier.user_email_for(:notification) - @subject = mail_template.subject_for_dossier(@dossier) - @body = mail_template.body_for_dossier(@dossier) - @actions = mail_template.actions_for_dossier(@dossier) + @email = @dossier.user_email_for(:notification) + @subject = mail_template.subject_for_dossier(@dossier) + @body = mail_template.body_for_dossier(@dossier) + @actions = mail_template.actions_for_dossier(@dossier) + end end end