From 581627cd3fef57ff3a87d5aec913ac5ee2658018 Mon Sep 17 00:00:00 2001 From: drummer83 Date: Tue, 30 Jan 2024 22:07:53 +0100 Subject: [PATCH] Add translations to shipment mailer to send the mail in the customer's language --- app/mailers/spree/shipment_mailer.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/mailers/spree/shipment_mailer.rb b/app/mailers/spree/shipment_mailer.rb index 5d1795eb35..04bedcf874 100644 --- a/app/mailers/spree/shipment_mailer.rb +++ b/app/mailers/spree/shipment_mailer.rb @@ -2,6 +2,7 @@ module Spree class ShipmentMailer < ApplicationMailer + include I18nHelper helper MailerHelper def shipped_email(shipment, delivery:) @@ -9,12 +10,14 @@ module Spree @order = @shipment.order @hide_ofn_navigation = @shipment.order.distributor.hide_ofn_navigation @delivery = delivery - subject = t(base_subject, - number: @order.number, - distributor: @order.distributor.name) - mail(to: @shipment.order.email, - subject:, - reply_to: @order.distributor.contact.email) + I18n.with_locale valid_locale(@order.user) do + subject = t(base_subject, + number: @order.number, + distributor: @order.distributor.name) + mail(to: @shipment.order.email, + subject:, + reply_to: @order.distributor.contact.email) + end end private