send email in user's language

This commit is contained in:
Alexander Machehin 2012-01-25 14:28:00 +06:00
parent b7c2b4d35b
commit 82339dcb34
1 changed files with 17 additions and 0 deletions

View File

@ -13,24 +13,41 @@ class UserMailer < ActionMailer::Base
def new_comment_notification(comment, user)
@user = user
@comment = comment
set_locale
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commentable.class == Grit::Commit ? 'commit_' : ''}comment_notification")) do |format|
format.html
end
ensure reset_locale
end
def new_issue_notification(issue, user)
@user = user
@issue = issue
set_locale
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_issue_notification")) do |format|
format.html
end
ensure reset_locale
end
def issue_assign_notification(issue, user)
@user = user
@issue = issue
set_locale
mail(:to => user.email, :subject => I18n.t("notifications.subjects.issue_assign_notification")) do |format|
format.html
end
ensure reset_locale
end
protected
def set_locale
@initial_locale, I18n.locale = I18n.locale, @user.language
end
def reset_locale
I18n.locale = @initial_locale
end
end