Add translations for report ajax controller

This commit is contained in:
Andreas Nedbal 2022-07-06 12:41:48 +02:00 committed by Karina Kwiatek
parent 9460bcfdd7
commit e670a50adf
3 changed files with 12 additions and 11 deletions

View File

@ -5,13 +5,14 @@ class Ajax::ReportController < AjaxController
@response[:status] = :err
if current_user.nil?
@response[:message] = I18n.t('messages.report.create.login')
unless user_signed_in?
@response[:status] = :noauth
@response[:message] = t(".noauth")
return
end
unless %w(answer comment question user).include? params[:type]
@response[:message] = I18n.t('messages.report.create.unknown')
@response[:message] = t(".unknown")
return
end
@ -31,14 +32,14 @@ class Ajax::ReportController < AjaxController
end
if object.nil?
@response[:message] = I18n.t('messages.report.create.not_found', parameter: params[:type])
@response[:message] = t(".notfound", parameter: params[:type])
return
end
current_user.report object, params[:reason]
@response[:status] = :okay
@response[:message] = I18n.t('messages.report.create.okay', parameter: params[:type])
@response[:message] = t(".success", parameter: params[:type])
@response[:success] = true
end
end

View File

@ -114,6 +114,12 @@ en:
follow:
success: "Successfully unfollowed user."
error: "You are not following that user."
report:
create:
noauth: :messages.noauth
unknown: "You can't report this entity."
notfound: "Could not find %{parameter}"
success: "%{parameter} reported. A moderator will decide what happens with the %{parameter}."
smile:
create:
success: "Successfully smiled answer."

View File

@ -56,12 +56,6 @@ en:
error: "An error occurred."
parameter_error: "%{parameter} is required."
noauth: "requires authentication"
report:
create:
login: "login required"
unknown: "unknown type"
not_found: "Could not find %{parameter}"
okay: "%{parameter} reported. A moderator will decide what happens with the %{parameter}."
subscription:
torpedo: "418 I'm a torpedo"
views: