Skip to content

Remove usage of `Gitlab::I18n.with_locale` in mailers using `mail_with_locale` or `email_with_layout`

Background

Here is an example of an email that was added with Gitlab::I18n.with_locale:

Gitlab::I18n.with_locale(@user.preferred_language) do
  email_with_layout(
    to: @user.notification_email_or_default,
    subject: subject(_("Attempted sign in to %{host} using a wrong two-factor authentication code") % { host: Gitlab.config.gitlab.host }))
end

But if you look at the email_with_layout method, it calls mail_with_locale, which picks up the user's preferred language. So, wrapping email_with_layout with a call to Gitlab::I18n.with_locale is unnecesssary.

Implementation plan

For the following files, remove the use of Gitlab::I18n.with_locale in any methods that already use the mail_with_locale or email_with_layout methods:

Edited by Jessie Young