From 116ab27e081253a572b1ce7a5188b472092bbec4 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 16 Nov 2016 18:25:21 +0100 Subject: i18n for devise mailer too --- app/mailers/application_mailer.rb | 2 +- app/mailers/user_mailer.rb | 32 ++++++++++++++++++++++ .../mailer/confirmation_instructions.en.html.erb | 5 ---- .../mailer/confirmation_instructions.en.text.erb | 5 ---- app/views/auth/mailer/password_change.en.html.erb | 3 -- app/views/auth/mailer/password_change.en.text.erb | 3 -- .../mailer/reset_password_instructions.en.html.erb | 8 ------ .../mailer/reset_password_instructions.en.text.erb | 8 ------ .../confirmation_instructions.en.html.erb | 5 ++++ .../confirmation_instructions.en.text.erb | 5 ++++ app/views/user_mailer/password_change.en.html.erb | 3 ++ app/views/user_mailer/password_change.en.text.erb | 3 ++ .../reset_password_instructions.en.html.erb | 8 ++++++ .../reset_password_instructions.en.text.erb | 8 ++++++ 14 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 app/mailers/user_mailer.rb delete mode 100644 app/views/auth/mailer/confirmation_instructions.en.html.erb delete mode 100644 app/views/auth/mailer/confirmation_instructions.en.text.erb delete mode 100644 app/views/auth/mailer/password_change.en.html.erb delete mode 100644 app/views/auth/mailer/password_change.en.text.erb delete mode 100644 app/views/auth/mailer/reset_password_instructions.en.html.erb delete mode 100644 app/views/auth/mailer/reset_password_instructions.en.text.erb create mode 100644 app/views/user_mailer/confirmation_instructions.en.html.erb create mode 100644 app/views/user_mailer/confirmation_instructions.en.text.erb create mode 100644 app/views/user_mailer/password_change.en.html.erb create mode 100644 app/views/user_mailer/password_change.en.text.erb create mode 100644 app/views/user_mailer/reset_password_instructions.en.html.erb create mode 100644 app/views/user_mailer/reset_password_instructions.en.text.erb (limited to 'app') diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 2f7dd6ee5..0d9f10a08 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true class ApplicationMailer < ActionMailer::Base - default from: (ENV['SMTP_FROM_ADDRESS'] || 'notifications@localhost') + default from: ENV.fetch('SMTP_FROM_ADDRESS') { 'notifications@localhost' } layout 'mailer' end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb new file mode 100644 index 000000000..5c086768d --- /dev/null +++ b/app/mailers/user_mailer.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class UserMailer < Devise::Mailer + default from: ENV.fetch('SMTP_FROM_ADDRESS') { 'notifications@localhost' } + layout 'mailer' + + def confirmation_instructions(user, token) + @resource = user + @token = token + + I18n.with_locale(@resource.locale || I18n.default_locale) do + mail to: @resource.email + end + end + + def reset_password_instructions(user, token) + @resource = user + @token = token + + I18n.with_locale(@resource.locale || I18n.default_locale) do + mail to: @resource.email + end + end + + def password_change(user) + @resource = user + + I18n.with_locale(@resource.locale || I18n.default_locale) do + mail to: @resource.email + end + end +end diff --git a/app/views/auth/mailer/confirmation_instructions.en.html.erb b/app/views/auth/mailer/confirmation_instructions.en.html.erb deleted file mode 100644 index 69e9ff80f..000000000 --- a/app/views/auth/mailer/confirmation_instructions.en.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

Welcome <%= @resource.email %>!

- -

You can confirm your Mastodon account email through the link below:

- -

<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>

diff --git a/app/views/auth/mailer/confirmation_instructions.en.text.erb b/app/views/auth/mailer/confirmation_instructions.en.text.erb deleted file mode 100644 index bb21cf8e2..000000000 --- a/app/views/auth/mailer/confirmation_instructions.en.text.erb +++ /dev/null @@ -1,5 +0,0 @@ -Welcome <%= @resource.email %>! - -You can confirm your Mastodon account email through the link below: - -<%= confirmation_url(@resource, confirmation_token: @token) %> diff --git a/app/views/auth/mailer/password_change.en.html.erb b/app/views/auth/mailer/password_change.en.html.erb deleted file mode 100644 index a1bc77463..000000000 --- a/app/views/auth/mailer/password_change.en.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -

Hello <%= @resource.email %>!

- -

We're contacting you to notify you that your password on Mastodon has been changed.

diff --git a/app/views/auth/mailer/password_change.en.text.erb b/app/views/auth/mailer/password_change.en.text.erb deleted file mode 100644 index 27581e604..000000000 --- a/app/views/auth/mailer/password_change.en.text.erb +++ /dev/null @@ -1,3 +0,0 @@ -Hello <%= @resource.email %>! - -We're contacting you to notify you that your password on Mastodon has been changed. diff --git a/app/views/auth/mailer/reset_password_instructions.en.html.erb b/app/views/auth/mailer/reset_password_instructions.en.html.erb deleted file mode 100644 index 643b43319..000000000 --- a/app/views/auth/mailer/reset_password_instructions.en.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -

Hello <%= @resource.email %>!

- -

Someone has requested a link to change your password on Mastodon. You can do this through the link below.

- -

<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

- -

If you didn't request this, please ignore this email.

-

Your password won't change until you access the link above and create a new one.

diff --git a/app/views/auth/mailer/reset_password_instructions.en.text.erb b/app/views/auth/mailer/reset_password_instructions.en.text.erb deleted file mode 100644 index fe73b0165..000000000 --- a/app/views/auth/mailer/reset_password_instructions.en.text.erb +++ /dev/null @@ -1,8 +0,0 @@ -Hello <%= @resource.email %>! - -Someone has requested a link to change your password on Mastodon. You can do this through the link below. - -<%= edit_password_url(@resource, reset_password_token: @token) %> - -If you didn't request this, please ignore this email. -Your password won't change until you access the link above and create a new one. diff --git a/app/views/user_mailer/confirmation_instructions.en.html.erb b/app/views/user_mailer/confirmation_instructions.en.html.erb new file mode 100644 index 000000000..69e9ff80f --- /dev/null +++ b/app/views/user_mailer/confirmation_instructions.en.html.erb @@ -0,0 +1,5 @@ +

Welcome <%= @resource.email %>!

+ +

You can confirm your Mastodon account email through the link below:

+ +

<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>

diff --git a/app/views/user_mailer/confirmation_instructions.en.text.erb b/app/views/user_mailer/confirmation_instructions.en.text.erb new file mode 100644 index 000000000..bb21cf8e2 --- /dev/null +++ b/app/views/user_mailer/confirmation_instructions.en.text.erb @@ -0,0 +1,5 @@ +Welcome <%= @resource.email %>! + +You can confirm your Mastodon account email through the link below: + +<%= confirmation_url(@resource, confirmation_token: @token) %> diff --git a/app/views/user_mailer/password_change.en.html.erb b/app/views/user_mailer/password_change.en.html.erb new file mode 100644 index 000000000..a1bc77463 --- /dev/null +++ b/app/views/user_mailer/password_change.en.html.erb @@ -0,0 +1,3 @@ +

Hello <%= @resource.email %>!

+ +

We're contacting you to notify you that your password on Mastodon has been changed.

diff --git a/app/views/user_mailer/password_change.en.text.erb b/app/views/user_mailer/password_change.en.text.erb new file mode 100644 index 000000000..27581e604 --- /dev/null +++ b/app/views/user_mailer/password_change.en.text.erb @@ -0,0 +1,3 @@ +Hello <%= @resource.email %>! + +We're contacting you to notify you that your password on Mastodon has been changed. diff --git a/app/views/user_mailer/reset_password_instructions.en.html.erb b/app/views/user_mailer/reset_password_instructions.en.html.erb new file mode 100644 index 000000000..643b43319 --- /dev/null +++ b/app/views/user_mailer/reset_password_instructions.en.html.erb @@ -0,0 +1,8 @@ +

Hello <%= @resource.email %>!

+ +

Someone has requested a link to change your password on Mastodon. You can do this through the link below.

+ +

<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

+ +

If you didn't request this, please ignore this email.

+

Your password won't change until you access the link above and create a new one.

diff --git a/app/views/user_mailer/reset_password_instructions.en.text.erb b/app/views/user_mailer/reset_password_instructions.en.text.erb new file mode 100644 index 000000000..fe73b0165 --- /dev/null +++ b/app/views/user_mailer/reset_password_instructions.en.text.erb @@ -0,0 +1,8 @@ +Hello <%= @resource.email %>! + +Someone has requested a link to change your password on Mastodon. You can do this through the link below. + +<%= edit_password_url(@resource, reset_password_token: @token) %> + +If you didn't request this, please ignore this email. +Your password won't change until you access the link above and create a new one. -- cgit