send email in user's language
This commit is contained in:
parent
b7c2b4d35b
commit
82339dcb34
|
@ -13,24 +13,41 @@ class UserMailer < ActionMailer::Base
|
||||||
def new_comment_notification(comment, user)
|
def new_comment_notification(comment, user)
|
||||||
@user = user
|
@user = user
|
||||||
@comment = comment
|
@comment = comment
|
||||||
|
set_locale
|
||||||
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commentable.class == Grit::Commit ? 'commit_' : ''}comment_notification")) do |format|
|
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commentable.class == Grit::Commit ? 'commit_' : ''}comment_notification")) do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
|
ensure reset_locale
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_issue_notification(issue, user)
|
def new_issue_notification(issue, user)
|
||||||
@user = user
|
@user = user
|
||||||
@issue = issue
|
@issue = issue
|
||||||
|
set_locale
|
||||||
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_issue_notification")) do |format|
|
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_issue_notification")) do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
|
ensure reset_locale
|
||||||
end
|
end
|
||||||
|
|
||||||
def issue_assign_notification(issue, user)
|
def issue_assign_notification(issue, user)
|
||||||
@user = user
|
@user = user
|
||||||
@issue = issue
|
@issue = issue
|
||||||
|
set_locale
|
||||||
mail(:to => user.email, :subject => I18n.t("notifications.subjects.issue_assign_notification")) do |format|
|
mail(:to => user.email, :subject => I18n.t("notifications.subjects.issue_assign_notification")) do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
|
ensure reset_locale
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def set_locale
|
||||||
|
@initial_locale, I18n.locale = I18n.locale, @user.language
|
||||||
|
end
|
||||||
|
|
||||||
|
def reset_locale
|
||||||
|
I18n.locale = @initial_locale
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue