Add translations for mute rule controller actions

This commit is contained in:
Andreas Nedbal 2022-02-17 00:55:44 +01:00 committed by Andreas Nedbal
parent cc50219d05
commit 79dbf7d1c8
2 changed files with 22 additions and 8 deletions

View File

@ -4,14 +4,14 @@ class Ajax::MuteRuleController < AjaxController
unless user_signed_in? unless user_signed_in?
@response[:status] = :noauth @response[:status] = :noauth
@response[:message] = I18n.t('messages.noauth') @response[:message] = t(".noauth")
return return
end end
rule = MuteRule.create!(user: current_user, muted_phrase: params[:muted_phrase]) rule = MuteRule.create!(user: current_user, muted_phrase: params[:muted_phrase])
@response[:status] = :okay @response[:status] = :okay
@response[:success] = true @response[:success] = true
@response[:message] = "Rule added successfully." @response[:message] = t(".success")
@response[:id] = rule.id @response[:id] = rule.id
end end
@ -21,7 +21,7 @@ class Ajax::MuteRuleController < AjaxController
unless user_signed_in? unless user_signed_in?
@response[:status] = :noauth @response[:status] = :noauth
@response[:message] = I18n.t('messages.noauth') @response[:message] = t(".noauth")
return return
end end
@ -29,7 +29,7 @@ class Ajax::MuteRuleController < AjaxController
if rule.user_id != current_user.id if rule.user_id != current_user.id
@response[:status] = :nopriv @response[:status] = :nopriv
@response[:message] = "Can't edit other people's rules" @response[:message] = t(".nopriv")
return return
end end
@ -37,7 +37,7 @@ class Ajax::MuteRuleController < AjaxController
rule.save! rule.save!
@response[:status] = :okay @response[:status] = :okay
@response[:message] = "Rule updated successfully." @response[:message] = t(".success")
@response[:success] = true @response[:success] = true
end end
@ -46,7 +46,7 @@ class Ajax::MuteRuleController < AjaxController
unless user_signed_in? unless user_signed_in?
@response[:status] = :noauth @response[:status] = :noauth
@response[:message] = I18n.t('messages.noauth') @response[:message] = t(".noauth")
return return
end end
@ -54,14 +54,14 @@ class Ajax::MuteRuleController < AjaxController
if rule.user_id != current_user.id if rule.user_id != current_user.id
@response[:status] = :nopriv @response[:status] = :nopriv
@response[:message] = "Can't edit other people's rules" @response[:message] = t(".nopriv")
return return
end end
rule.destroy! rule.destroy!
@response[:status] = :okay @response[:status] = :okay
@response[:message] = "Rule deleted successfully." @response[:message] = t(".success")
@response[:success] = true @response[:success] = true
end end
end end

View File

@ -1,4 +1,18 @@
en: en:
ajax:
mute_rule:
nopriv: "Can't edit other people's rules"
create:
noauth: :messages.noauth
success: "Rule added successfully."
update:
noauth: :messages.noauth
nopriv: :ajax.mute_rule.nopriv
success: "Rule updated successfully."
destroy:
noauth: :messages.noauth
nopriv: :ajax.mute_rule.nopriv
success: "Rule deleted successfully."
announcement: announcement:
create: create:
success: "Announcement created successfully." success: "Announcement created successfully."