From 646f48f0afa32aa58b8e9bc32716e5c504a0fcc5 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Tue, 14 Jul 2020 14:32:47 +0100 Subject: [PATCH] Add translation keys for test and shipment emails and make them lazy lookups --- app/mailers/spree/base_mailer.rb | 1 - app/mailers/spree/shipment_mailer.rb | 2 +- app/mailers/spree/test_mailer.rb | 2 +- .../shipment_mailer/shipped_email.html.haml | 12 +++--- .../spree/test_mailer/test_email.html.haml | 4 +- config/locales/en.yml | 38 +++++++++++++------ 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/app/mailers/spree/base_mailer.rb b/app/mailers/spree/base_mailer.rb index d0f86d8ace..fb46bf54bc 100644 --- a/app/mailers/spree/base_mailer.rb +++ b/app/mailers/spree/base_mailer.rb @@ -5,7 +5,6 @@ module Spree # Inline stylesheets include Roadie::Rails::Automatic - # Define layout layout 'mailer' def from_address diff --git a/app/mailers/spree/shipment_mailer.rb b/app/mailers/spree/shipment_mailer.rb index ccbac24efe..3b25885f81 100644 --- a/app/mailers/spree/shipment_mailer.rb +++ b/app/mailers/spree/shipment_mailer.rb @@ -5,7 +5,7 @@ module Spree def shipped_email(shipment, resend = false) @shipment = shipment.respond_to?(:id) ? shipment : Spree::Shipment.find(shipment) subject = (resend ? "[#{Spree.t(:resend).upcase}] " : '') - base_subject = Spree.t('shipment_mailer.shipped_email.subject') + base_subject = t('spree.shipment_mailer.shipped_email.subject') subject += "#{Spree::Config[:site_name]} #{base_subject} ##{@shipment.order.number}" mail(to: @shipment.order.email, from: from_address, subject: subject) end diff --git a/app/mailers/spree/test_mailer.rb b/app/mailers/spree/test_mailer.rb index 1f41f55a52..316de40341 100644 --- a/app/mailers/spree/test_mailer.rb +++ b/app/mailers/spree/test_mailer.rb @@ -4,7 +4,7 @@ module Spree class TestMailer < BaseMailer def test_email(user) recipient = user.respond_to?(:id) ? user : Spree.user_class.find(user) - subject = "#{Spree::Config[:site_name]} #{Spree.t('test_mailer.test_email.subject')}" + subject = "#{Spree::Config[:site_name]} #{t('spree.test_mailer.test_email.subject')}" mail(to: recipient.email, from: from_address, subject: subject) end end diff --git a/app/views/spree/shipment_mailer/shipped_email.html.haml b/app/views/spree/shipment_mailer/shipped_email.html.haml index 96aa8403db..04c8368787 100644 --- a/app/views/spree/shipment_mailer/shipped_email.html.haml +++ b/app/views/spree/shipment_mailer/shipped_email.html.haml @@ -1,9 +1,9 @@ -= Spree.t('shipment_mailer.shipped_email.dear_customer') += t('.dear_customer') -= Spree.t('shipment_mailer.shipped_email.instructions') += t('.instructions') = "============================================================" -= Spree.t('shipment_mailer.shipped_email.shipment_summary') += t('.shipment_summary') = "============================================================" - @shipment.manifest.each do |item| = item.variant.sku @@ -12,8 +12,8 @@ = "============================================================" - if @shipment.tracking - = Spree.t('shipment_mailer.shipped_email.track_information', tracking: @shipment.tracking) + = t('.track_information', tracking: @shipment.tracking) - if @shipment.tracking_url - = Spree.t('shipment_mailer.shipped_email.track_link', url: @shipment.tracking_url) + = t('.track_link', url: @shipment.tracking_url) -= Spree.t('shipment_mailer.shipped_email.thanks') += t('.thanks') diff --git a/app/views/spree/test_mailer/test_email.html.haml b/app/views/spree/test_mailer/test_email.html.haml index 024e6cab4c..6f9e2e771c 100644 --- a/app/views/spree/test_mailer/test_email.html.haml +++ b/app/views/spree/test_mailer/test_email.html.haml @@ -1,4 +1,4 @@ -= t('test_mailer.test_email.greeting') += t('.greeting') = "================" -= t('test_mailer.test_email.message') += t('.message') diff --git a/config/locales/en.yml b/config/locales/en.yml index 3726167337..7cd051f0fb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3508,6 +3508,32 @@ See the %{link} to find out more about %{sitename}'s features and to start using invoice_email: hi: "Hi %{name}" invoice_attached_text: Please find attached an invoice for your recent order from + user_mailer: + reset_password_instructions: + request_sent_text: | + A request to reset your password has been made. + If you did not make this request, simply ignore this email. + link_text: > + If you did make this request just click the link below: + issue_text: | + If the above URL does not work try copying and pasting it into your browser. + If you continue to have problems please feel free to contact us. + confirmation_instructions: + subject: "Please confirm your OFN account" + shipment_mailer: + shipped_email: + dear_customer: "Dear Customer," + instructions: "Your order has been shipped" + shipment_summary: "Shipment Summary" + subject: "Shipment Notification" + thanks: "Thank you for your business." + track_information: ! "Tracking Information: %{tracking}" + track_link: ! "Tracking Link: %{url}" + test_mailer: + test_email: + greeting: "Congratulations!" + message: "If you have received this email, then your email settings are correct." + subject: "Test Mail" order_state: address: address adjustments: adjustments @@ -3529,18 +3555,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using ended: ended paused: paused canceled: cancelled - user_mailer: - reset_password_instructions: - request_sent_text: | - A request to reset your password has been made. - If you did not make this request, simply ignore this email. - link_text: > - If you did make this request just click the link below: - issue_text: | - If the above URL does not work try copying and pasting it into your browser. - If you continue to have problems please feel free to contact us. - confirmation_instructions: - subject: Please confirm your OFN account users: form: account_settings: Account Settings