diff --git a/app/mailers/email_subscription_mailer.rb b/app/mailers/email_subscription_mailer.rb index 35bd6da2f9..318aec10d8 100644 --- a/app/mailers/email_subscription_mailer.rb +++ b/app/mailers/email_subscription_mailer.rb @@ -30,7 +30,7 @@ class EmailSubscriptionMailer < ApplicationMailer @statuses = statuses I18n.with_locale(locale) do - mail subject: default_i18n_subject(count: @statuses.size, name: @subscription.account.display_name, excerpt: @statuses.first.text.truncate(17)) + mail subject: I18n.t(@statuses.size == 1 ? 'singular' : 'plural', scope: 'email_subscription_mailer.notification.subject', name: @subscription.account.display_name, excerpt: @statuses.first.text.truncate(17)) end end diff --git a/app/views/email_subscription_mailer/notification.text.erb b/app/views/email_subscription_mailer/notification.text.erb index 7da5261b64..9e657b93f9 100644 --- a/app/views/email_subscription_mailer/notification.text.erb +++ b/app/views/email_subscription_mailer/notification.text.erb @@ -1,4 +1,4 @@ -<%= t '.title', count: @statuses.size, name: display_name(@subscription.account), excerpt: truncate(@statuses.first.text, length: 17) %> +<%= t @statuses.size == 1 ? 'singular' : 'plural', scope: 'email_subscription_mailer.notification.title', name: display_name(@subscription.account), excerpt: truncate(@statuses.first.text, length: 17) %> === diff --git a/config/locales/en.yml b/config/locales/en.yml index 76b25667df..883bf18e7a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1440,11 +1440,11 @@ en: one: Interact with this post and discover more like it. other: Interact with these posts and discover more. subject: - one: 'New post: "%{excerpt}"' - other: New posts from %{name} + plural: New posts from %{name} + singular: 'New post: "%{excerpt}"' title: - one: 'New post: "%{excerpt}"' - other: New posts from %{name} + plural: New posts from %{name} + singular: 'New post: "%{excerpt}"' email_subscriptions: active: Active confirmations: diff --git a/spec/mailers/email_subscription_mailer_spec.rb b/spec/mailers/email_subscription_mailer_spec.rb index 0d8ec6e66b..4782291145 100644 --- a/spec/mailers/email_subscription_mailer_spec.rb +++ b/spec/mailers/email_subscription_mailer_spec.rb @@ -30,7 +30,7 @@ RSpec.describe EmailSubscriptionMailer do .to send_email( to: email_subscription.email, from: 'notifications@localhost', - subject: I18n.t('email_subscription_mailer.notification.subject', count: statuses.size, name: email_subscription.account.display_name, excerpt: statuses.first.text.truncate(17)) + subject: I18n.t('email_subscription_mailer.notification.subject.singular', name: email_subscription.account.display_name, excerpt: statuses.first.text.truncate(17)) ) end end @@ -43,7 +43,7 @@ RSpec.describe EmailSubscriptionMailer do .to send_email( to: email_subscription.email, from: 'notifications@localhost', - subject: I18n.t('email_subscription_mailer.notification.subject', count: statuses.size, name: email_subscription.account.display_name, excerpt: ActionController::Base.helpers.truncate(statuses.first.text, length: 17)) + subject: I18n.t('email_subscription_mailer.notification.subject.plural', name: email_subscription.account.display_name, excerpt: ActionController::Base.helpers.truncate(statuses.first.text, length: 17)) ) end end