Sha256: 271a388de204d146e42d980c29e86c0232ad25c5e38feeb86409de62fd3f2d46
Contents?: true
Size: 917 Bytes
Versions: 48
Compression:
Stored size: 917 Bytes
Contents
# frozen_string_literal: true require "active_support/concern" module Decidim # A module to be included in mailers that changes the default behaviour so # the emails are rendered in the user's locale instead of the default one. module LocalisedMailer extend ActiveSupport::Concern included do # Yields with the I18n locale changed to the user's one. It will only # yield if the user has an email, thus avoiding sending emails to deleted # users. # # Returns nothing. def with_user(user) I18n.with_locale(user.locale || user.organization.default_locale) do yield if user.email.present? end end # Overwrite default devise_mail method to always render the email with # the user's locale. def devise_mail(record, action, opts = {}) with_user(record) do super end end end end end
Version data entries
48 entries across 48 versions & 1 rubygems