Add translations for inbox ajax controller

This commit is contained in:
Andreas Nedbal 2022-07-06 10:29:05 +02:00 committed by Karina Kwiatek
parent 15946740eb
commit 1c31ff41db
3 changed files with 20 additions and 17 deletions

View File

@ -2,7 +2,7 @@ class Ajax::InboxController < AjaxController
def create
unless user_signed_in?
@response[:status] = :noauth
@response[:message] = I18n.t('messages.noauth')
@response[:message] = t(".noauth")
return
end
@ -14,7 +14,7 @@ class Ajax::InboxController < AjaxController
inbox = Inbox.create!(user: current_user, question_id: question.id, new: true)
@response[:status] = :okay
@response[:message] = I18n.t('messages.inbox.create.okay')
@response[:message] = t(".success")
@response[:success] = true
@response[:render] = render_to_string(partial: 'inbox/entry', locals: { i: inbox })
inbox.update(new: false)
@ -27,7 +27,7 @@ class Ajax::InboxController < AjaxController
unless current_user == inbox.user
@response[:status] = :fail
@response[:message] = I18n.t('messages.inbox.remove.fail')
@response[:message] = t(".error")
return
end
@ -36,12 +36,12 @@ class Ajax::InboxController < AjaxController
rescue => e
Sentry.capture_exception(e)
@response[:status] = :err
@response[:message] = I18n.t('messages.error')
@response[:message] = t("errors.base")
return
end
@response[:status] = :okay
@response[:message] = I18n.t('messages.inbox.remove.okay')
@response[:message] = t(".success")
@response[:success] = true
end
@ -53,12 +53,12 @@ class Ajax::InboxController < AjaxController
rescue => e
Sentry.capture_exception(e)
@response[:status] = :err
@response[:message] = I18n.t('messages.error')
@response[:message] = t("errors.base")
return
end
@response[:status] = :okay
@response[:message] = I18n.t('messages.inbox.remove_all.okay')
@response[:message] = t(".success")
@response[:success] = true
end
@ -71,12 +71,12 @@ class Ajax::InboxController < AjaxController
rescue => e
Sentry.capture_exception(e)
@response[:status] = :err
@response[:message] = I18n.t('messages.error')
@response[:message] = t("errors.base")
return
end
@response[:status] = :okay
@response[:message] = I18n.t('messages.inbox.remove_all.okay')
@response[:message] = t(".success")
@response[:success] = true
end
end

View File

@ -13,6 +13,17 @@ en:
destroy:
nopriv: "Can't delete other people's comments."
success: "Successfully deleted comment."
inbox:
create:
noauth: :messages.noauth
success: "Successfully added new question."
remove:
success: "Successfully deleted question."
error: "Question is not in your inbox."
remove_all:
success: "Successfully deleted questions."
remove_all_author:
success: :ajax.inbox.remove_all.success
mute_rule:
nopriv: "Can't edit other people's rules"
create:

View File

@ -79,14 +79,6 @@ en:
notfound: "List not found."
add: "Successfully added user to list."
remove: "Successfully removed user from list."
inbox:
create:
okay: "Successfully added new question."
remove:
fail: "question not in your inbox"
okay: "Successfully deleted question."
remove_all:
okay: "Successfully deleted questions."
moderation:
vote:
fail: "You have already voted on this report."