Sha256: ded2e33429ecbe2f16376d7951e9724cd8c5f38c1af699ab703490900598fb6c
Contents?: true
Size: 765 Bytes
Versions: 79
Compression:
Stored size: 765 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. # # Returns nothing. def with_user(user) I18n.with_locale(user.locale || I18n.locale) do yield 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
79 entries across 79 versions & 2 rubygems