From 822dd275097fdad48f973326d5c5011e3423d797 Mon Sep 17 00:00:00 2001 From: Rafael Baldasso Audibert <32079912+rafaeelaudibert@users.noreply.github.com> Date: Thu, 11 Apr 2019 12:30:50 -0300 Subject: [PATCH] Added mailer i18n (#436) * Added mailer i18n * Added translation to mailer in the JS Also added a generic way to add JS translation through a javascript entry in the locale file * Moved line-breaks from translations to JS file --- app/assets/javascripts/room.js | 12 ++++++---- app/helpers/application_helper.rb | 6 +++++ app/views/layouts/application.html.erb | 20 ++++++++++++++++ app/views/user_mailer/password_reset.html.erb | 14 ++++++----- app/views/user_mailer/password_reset.text.erb | 10 ++++---- app/views/user_mailer/verify_email.html.erb | 16 +++++++------ app/views/user_mailer/verify_email.text.erb | 8 +++---- config/locales/en.yml | 23 +++++++++++++++++++ 8 files changed, 83 insertions(+), 26 deletions(-) diff --git a/app/assets/javascripts/room.js b/app/assets/javascripts/room.js index c4361069..93dbd5cc 100644 --- a/app/assets/javascripts/room.js +++ b/app/assets/javascripts/room.js @@ -43,10 +43,14 @@ $(document).on('turbolinks:load', function(){ // Handle recording emails. $('.email-link').each(function(){ $(this).click(function(){ - var subject = $(".username").text() + " has invited you to view a recording."; - var body = "To view the recording, follow the link below:\n\n" + $(this).attr("data-pres-link"); - var footer = "\n\nThis e-mail is auto-generated by BigBlueButton.\nBigBlueButton is an open source web conferencing system. For more information on BigBlueButton, see https://bigbluebutton.org/." - var win = window.open("mailto:?subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(body) + encodeURIComponent(footer), '_blank'); + var subject = $(".username").text() + " " + t('room.mailer.subject'); + var body = t('room.mailer.body') + "\n\n" + $(this).attr("data-pres-link"); + var autogenerated = "\n\n" + t('room.mailer.autogenerated') + "\n"; + var footer = t('room.mailer.footer'); + + var url = "mailto:?subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(body) + encodeURIComponent(autogenerated) + encodeURIComponent(footer); + var win = window.open(url, '_blank'); + win.focus(); }); }); diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0de2a1c8..09e14627 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -89,4 +89,10 @@ module ApplicationHelper false end end + + # Return all the translations available in the client side through javascript + def current_translations + @translations ||= I18n.backend.send(:translations) + @translations[I18n.locale].with_indifferent_access[:javascript] || {} + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e1fc5e24..94df89f5 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -32,6 +32,26 @@ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + +
"> diff --git a/app/views/user_mailer/password_reset.html.erb b/app/views/user_mailer/password_reset.html.erb index 373249b4..52d1fdf7 100644 --- a/app/views/user_mailer/password_reset.html.erb +++ b/app/views/user_mailer/password_reset.html.erb @@ -19,28 +19,30 @@- It seems like you forgot your password for <%= t('bigbluebutton') %> + <%= t('mailer.user.password_reset.welcome', bigbluebutton: t('bigbluebutton')) %>
- If this is true, please click the link below to reset your password: + <%= t('mailer.user.password_reset.message') %>
- Reset Password + <%= t('mailer.user.password_reset.reset_link') %>- This link will expire in two hours. + <%= t('mailer.user.password_reset.expire') %>
- You can safely ignore this email if you did not request a password reset. + <%= t('mailer.user.password_reset.ignore') %>
- You have successfully registered your <%= t('bigbluebutton') %> account, your username is: - <%= @user[:email] %>. + <%= t('mailer.user.verify_email.success', bigbluebutton: t('bigbluebutton'), email: @user[:email]) %>
- To verify your account, just click the button below. + <%= t('mailer.user.verify_email.verify') %>
- Verify Account + <%= t('mailer.user.verify_email.verify_link') %> -Thanks for joining and have a great day!
++ <%= t('mailer.user.verify_email.thanks') %> +