From 604b6f6b593a7e6ebe5e431eed718498ee567f2b Mon Sep 17 00:00:00 2001 From: Nuwan Date: Mon, 4 Nov 2024 17:27:23 +0530 Subject: [PATCH] localize matched new users email --- jam-ui/src/i18n/config.js | 1 + ruby/lib/jam_ruby/app/mailers/user_mailer.rb | 2 +- .../user_mailer/new_musicians_match.html.erb | 53 ++++++++----------- ruby/spec/mailers/render_emails_spec.rb | 3 +- web/config/locales/en.yml | 12 +++++ web/config/locales/es.yml | 12 +++++ 6 files changed, 51 insertions(+), 32 deletions(-) create mode 100644 web/config/locales/es.yml diff --git a/jam-ui/src/i18n/config.js b/jam-ui/src/i18n/config.js index 17193c009..61b69e706 100644 --- a/jam-ui/src/i18n/config.js +++ b/jam-ui/src/i18n/config.js @@ -14,6 +14,7 @@ import affiliateEN from './locales/en/affiliate.json' import jamTracksEn from './locales/en/jamtracks.json' import checkoutEN from './locales/en/checkout.json' import checkoutSuccessEN from './locales/en/checkout_success.json' +import emailsEn from './locales/en/emails.json' import commonTranslationsES from './locales/es/common.json' import homeTranslationsES from './locales/es/home.json' diff --git a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb index 8855a235b..8bb38cde7 100644 --- a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb +++ b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb @@ -49,7 +49,7 @@ module JamRuby mail(:to => user.email, :subject => "Welcome to JamKazam") do |format| format.text - format.html + format.html { render layout: "user_mailer_beta" } end end diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians_match.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians_match.html.erb index 9662fdf67..8ec16f28c 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians_match.html.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians_match.html.erb @@ -1,68 +1,61 @@ -

Hi <%= @user.first_name -%>,

+

<%= I18n.t 'user_mailer.new_musicians_match.greeting' -%> <%= @user.first_name -%>,

- The following musicians have joined JamKazam within the last week and - have low internet latency to you that will support enjoyable sessions. - If you'd like to make more musical connections, we encourage you to use - the links below to send these new users a welcome message and perhaps - arrange a session to play together. + <%= I18n.t 'user_mailer.new_musicians_match.paragraph1' -%>

- <% - @musicians_data.each do | data | -%> - <% - musicians = data[:musicians] - latencies = data[:latencies] - musicians.each do |musician| - latency = latencies.find{|l| l[:user_id] == musician.id } - -%> + <% @musicians_data.each do | data | + musicians = data[:musicians] + latencies = data[:latencies] + + musicians.each do | musician | + %> - <% end -%> - <% end -%> + <% end %> + <% end %>
- <%= image_tag musician.photo_url.blank?? "avatar.png" : musician.photo_url, height: '32', width: '32', host: APP_CONFIG.action_mailer.assets_host, alt="Photo" -%> + <%= image_tag musician.photo_url.blank?? "avatar.png" : musician.photo_url, height: '32', width: '32', host: APP_CONFIG.action_mailer.assets_host, alt: 'photo' -%>

<%= musician.first_name %> <%= musician.last_name %>
- Latency To You: <%= latency_info(latency) %> - <% if musician.last_active_timestamp -%> + + <% latency = latencies.find{|l| l[:user_id] == musician.id } %> + <%= I18n.t 'user_mailer.new_musicians_match.latency_to_you' -%>: <%= latency_info(latency) %> + <% if musician.last_active_timestamp %>
- Last Active: <%= time_ago_in_words(Time.at(musician.last_active_timestamp)) %> ago + <%= I18n.t 'user_mailer.new_musicians_match.last_active' -%>: <%= time_ago_in_words(Time.at(musician.last_active_timestamp)) %> <%= I18n.t 'user_mailer.new_musicians_match.ago' -%> <% end %>

- <% musician.musician_instruments.each do |mi| -%> + <% musician.musician_instruments.each do |mi| %> - <% end -%> + <% end %>
<%= mi.description %>: <%= @instrument_proficiencies[mi.proficiency_level.to_s.to_sym] %>
- + - + - +
View Profile<%= I18n.t 'user_mailer.new_musicians_match.view_profile' -%>
Send Message<%= I18n.t 'user_mailer.new_musicians_match.send_message' -%>
Send Friend Request<%= I18n.t 'user_mailer.new_musicians_match.send_friend_request' -%>

- To find great musical matches across the entire JamKazam commiunity and - make new connections, use the button below to access our musician search - feature. This let you filter JamKazammers by latency, instruments, skill - level, genre interests, last active day and more. + <%= I18n.t 'user_mailer.new_musicians_match.paragraph2' -%>

Search JamKazam Musicians<%= I18n.t 'user_mailer.new_musicians_match.search_musicians' -%>
\ No newline at end of file diff --git a/ruby/spec/mailers/render_emails_spec.rb b/ruby/spec/mailers/render_emails_spec.rb index 6c560fbc5..26e38c635 100644 --- a/ruby/spec/mailers/render_emails_spec.rb +++ b/ruby/spec/mailers/render_emails_spec.rb @@ -524,7 +524,7 @@ describe "RenderMailers" do end end - describe "New Musician Match email" do + describe "New Musician Match email", focus: true do let(:user) { FactoryGirl.create(:user) } let(:user1) { FactoryGirl.create(:user, first_name: 'David', last_name: 'Macmillan', updated_at: 2.day.ago.to_i) } let(:user2) { FactoryGirl.create(:user, first_name: 'Tom', last_name: 'Cluff', last_jam_updated_at: 1.days.ago.to_i) } @@ -543,6 +543,7 @@ describe "RenderMailers" do before(:each) do User.delete_all ActionMailer::Base.deliveries.clear + I18n.default_locale = :en end after(:each) do diff --git a/web/config/locales/en.yml b/web/config/locales/en.yml index f2ab8d805..20e9f7e0d 100644 --- a/web/config/locales/en.yml +++ b/web/config/locales/en.yml @@ -6,3 +6,15 @@ en: attributes: user: password_digest: "Password" + user_mailer: + new_musicians_match: + greeting: "Hi" + paragraph1: "The following musicians have joined JamKazam within the last week and have low internet latency to you that will support enjoyable sessions. If you'd like to make more musical connections, we encourage you to use the links below to send these new users a welcome message and perhaps arrange a session to play together." + latency_to_you: "Latency to You" + last_active: "Last Active" + ago: "ago" + view_profile: "View Profile" + send_message: "Send Message" + send_friend_request: "Send Friend Request" + paragraph2: "To find great musical matches across the entire JamKazam commiunity and make new connections, use the button below to access our musician search feature. This let you filter JamKazammers by latency, instruments, skill level, genre interests, last active day and more." + search_musicians: "Search JamKazam Musicians" diff --git a/web/config/locales/es.yml b/web/config/locales/es.yml new file mode 100644 index 000000000..91d6d1468 --- /dev/null +++ b/web/config/locales/es.yml @@ -0,0 +1,12 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + activerecord: + attributes: + user: + password_digest: "Password" + user_mailer: + new_musicians_match: + greeting: "Hola" + view_profile: "Ver Perfil"