Fix subject of email subscription notification e-mail being difficult to localize (#38507)

This commit is contained in:
Eugen Rochko
2026-04-01 10:32:47 +02:00
committed by GitHub
parent 6736b50c14
commit 14544dc4dd
4 changed files with 8 additions and 8 deletions

View File

@@ -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

View File

@@ -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) %>
===

View File

@@ -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:

View File

@@ -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