mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-19 04:26:03 +01:00
Add translations for moderation ajax controller
This commit is contained in:
parent
e6e7780142
commit
2237ff8f04
3 changed files with 45 additions and 44 deletions
|
@ -14,13 +14,13 @@ class Ajax::ModerationController < AjaxController
|
||||||
rescue => e
|
rescue => e
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
@response[:status] = :fail
|
@response[:status] = :fail
|
||||||
@response[:message] = I18n.t('messages.moderation.vote.fail')
|
@response[:message] = t(".error")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@response[:count] = report.votes
|
@response[:count] = report.votes
|
||||||
@response[:status] = :okay
|
@response[:status] = :okay
|
||||||
@response[:message] = I18n.t('messages.moderation.vote.okay')
|
@response[:message] = t(".success")
|
||||||
@response[:success] = true
|
@response[:success] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,13 +34,13 @@ class Ajax::ModerationController < AjaxController
|
||||||
rescue => e
|
rescue => e
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
@response[:status] = :fail
|
@response[:status] = :fail
|
||||||
@response[:message] = I18n.t('messages.moderation.destroy_vote.fail')
|
@response[:message] = t(".error")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@response[:count] = report.votes
|
@response[:count] = report.votes
|
||||||
@response[:status] = :okay
|
@response[:status] = :okay
|
||||||
@response[:message] = I18n.t('messages.moderation.destroy_vote.okay')
|
@response[:message] = t(".success")
|
||||||
@response[:success] = true
|
@response[:success] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,12 +55,12 @@ class Ajax::ModerationController < AjaxController
|
||||||
rescue => e
|
rescue => e
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
@response[:status] = :fail
|
@response[:status] = :fail
|
||||||
@response[:message] = I18n.t('messages.moderation.destroy_report.fail')
|
@response[:message] = t(".error")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@response[:status] = :okay
|
@response[:status] = :okay
|
||||||
@response[:message] = I18n.t('messages.moderation.destroy_report.okay')
|
@response[:message] = t(".success")
|
||||||
@response[:success] = true
|
@response[:success] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -76,12 +76,12 @@ class Ajax::ModerationController < AjaxController
|
||||||
rescue ActiveRecord::RecordInvalid => e
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
@response[:status] = :rec_inv
|
@response[:status] = :rec_inv
|
||||||
@response[:message] = I18n.t('messages.moderation.create_comment.rec_inv')
|
@response[:message] = t(".invalid")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@response[:status] = :okay
|
@response[:status] = :okay
|
||||||
@response[:message] = I18n.t('messages.moderation.create_comment.okay')
|
@response[:message] = t(".success")
|
||||||
@response[:success] = true
|
@response[:success] = true
|
||||||
@response[:render] = render_to_string(partial: 'moderation/discussion', locals: { report: report })
|
@response[:render] = render_to_string(partial: 'moderation/discussion', locals: { report: report })
|
||||||
@response[:count] = report.moderation_comments.all.count
|
@response[:count] = report.moderation_comments.all.count
|
||||||
|
@ -95,20 +95,20 @@ class Ajax::ModerationController < AjaxController
|
||||||
|
|
||||||
unless current_user == comment.user
|
unless current_user == comment.user
|
||||||
@response[:status] = :nopriv
|
@response[:status] = :nopriv
|
||||||
@response[:message] = I18n.t('messages.moderation.destroy_comment.nopriv')
|
@response[:message] = t(".nopriv")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
comment.destroy
|
comment.destroy
|
||||||
|
|
||||||
@response[:status] = :okay
|
@response[:status] = :okay
|
||||||
@response[:message] = I18n.t('messages.moderation.destroy_comment.okay')
|
@response[:message] = t(".success")
|
||||||
@response[:success] = true
|
@response[:success] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def ban
|
def ban
|
||||||
@response[:status] = :err
|
@response[:status] = :err
|
||||||
@response[:message] = I18n.t('messages.moderation.ban.error')
|
@response[:message] = t(".error")
|
||||||
|
|
||||||
params.require :user
|
params.require :user
|
||||||
params.require :ban
|
params.require :ban
|
||||||
|
@ -122,18 +122,18 @@ class Ajax::ModerationController < AjaxController
|
||||||
|
|
||||||
if !unban && target_user.has_role?(:administrator)
|
if !unban && target_user.has_role?(:administrator)
|
||||||
@response[:status] = :nopriv
|
@response[:status] = :nopriv
|
||||||
@response[:message] = I18n.t('messages.moderation.ban.nopriv')
|
@response[:message] = t(".nopriv")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if unban
|
if unban
|
||||||
UseCase::User::Unban.call(target_user.id)
|
UseCase::User::Unban.call(target_user.id)
|
||||||
@response[:message] = I18n.t('messages.moderation.ban.unban')
|
@response[:message] = t(".success.unban")
|
||||||
@response[:success] = true
|
@response[:success] = true
|
||||||
@response[:status] = :okay
|
@response[:status] = :okay
|
||||||
return
|
return
|
||||||
elsif perma
|
elsif perma
|
||||||
@response[:message] = I18n.t('messages.moderation.ban.perma')
|
@response[:message] = t(".success.permanent")
|
||||||
expiry = nil
|
expiry = nil
|
||||||
else
|
else
|
||||||
params.require :duration
|
params.require :duration
|
||||||
|
@ -142,7 +142,7 @@ class Ajax::ModerationController < AjaxController
|
||||||
raise Errors::InvalidBanDuration unless %w[hours days weeks months].include? duration_unit
|
raise Errors::InvalidBanDuration unless %w[hours days weeks months].include? duration_unit
|
||||||
|
|
||||||
expiry = DateTime.now + duration.public_send(duration_unit)
|
expiry = DateTime.now + duration.public_send(duration_unit)
|
||||||
@response[:message] = I18n.t('messages.moderation.ban.temp', date: expiry.to_s)
|
@response[:message] = I18n.t(".success.temporary", date: expiry.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
UseCase::User::Ban.call(
|
UseCase::User::Ban.call(
|
||||||
|
@ -168,12 +168,12 @@ class Ajax::ModerationController < AjaxController
|
||||||
|
|
||||||
target_user = User.find_by_screen_name!(params[:user])
|
target_user = User.find_by_screen_name!(params[:user])
|
||||||
|
|
||||||
@response[:message] = I18n.t('messages.moderation.privilege.nope')
|
@response[:message] = t(".error")
|
||||||
return unless %w(moderator admin).include? params[:type].downcase
|
return unless %w(moderator admin).include? params[:type].downcase
|
||||||
|
|
||||||
unless current_user.has_role?(:administrator)
|
unless current_user.has_role?(:administrator)
|
||||||
@response[:status] = :nopriv
|
@response[:status] = :nopriv
|
||||||
@response[:message] = I18n.t('messages.moderation.privilege.nopriv')
|
@response[:message] = t(".nopriv")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ class Ajax::ModerationController < AjaxController
|
||||||
end
|
end
|
||||||
target_user.save!
|
target_user.save!
|
||||||
|
|
||||||
@response[:message] = I18n.t('messages.moderation.privilege.checked', privilege: params[:type])
|
@response[:message] = t(".success", privilege: params[:type])
|
||||||
|
|
||||||
@response[:status] = :okay
|
@response[:status] = :okay
|
||||||
@response[:success] = true
|
@response[:success] = true
|
||||||
|
|
|
@ -42,6 +42,33 @@ en:
|
||||||
success:
|
success:
|
||||||
add: "Successfully added user to list."
|
add: "Successfully added user to list."
|
||||||
remove: "Successfully removed user from list."
|
remove: "Successfully removed user from list."
|
||||||
|
moderation:
|
||||||
|
vote:
|
||||||
|
success: "Successfully voted on report."
|
||||||
|
error: "You have already voted on this report."
|
||||||
|
destroy_vote:
|
||||||
|
success: "Successfully removed vote from report."
|
||||||
|
error: "You have not voted on that report."
|
||||||
|
destroy_report:
|
||||||
|
success: "Successfully removed report."
|
||||||
|
error: :errors.base
|
||||||
|
create_comment:
|
||||||
|
invalid: "Your comment is too long."
|
||||||
|
success: "Comment posted successfully."
|
||||||
|
destroy_comment:
|
||||||
|
nopriv: "Can't delete other people's comments."
|
||||||
|
success: "Successfully deleted comment."
|
||||||
|
ban:
|
||||||
|
nopriv: "You cannot ban an administrator!"
|
||||||
|
success:
|
||||||
|
unban: "Unbanned user."
|
||||||
|
permanent: "Permanently banned user."
|
||||||
|
temporary: "Banned user until %{date}"
|
||||||
|
error: "Something went wrong while banning this user."
|
||||||
|
privilege:
|
||||||
|
nopriv: "You can't change the role of this user."
|
||||||
|
success: "Successfully adjusted this users %{privilege} role."
|
||||||
|
error: "Something went wrong while adjusting this role."
|
||||||
mute_rule:
|
mute_rule:
|
||||||
nopriv: "Can't edit other people's rules"
|
nopriv: "Can't edit other people's rules"
|
||||||
create:
|
create:
|
||||||
|
|
|
@ -65,32 +65,6 @@ en:
|
||||||
destroy:
|
destroy:
|
||||||
nopriv: "can't delete other people's answers"
|
nopriv: "can't delete other people's answers"
|
||||||
okay: "Successfully deleted answer."
|
okay: "Successfully deleted answer."
|
||||||
moderation:
|
|
||||||
vote:
|
|
||||||
fail: "You have already voted on this report."
|
|
||||||
okay: "Successfully voted on report."
|
|
||||||
destroy_vote:
|
|
||||||
fail: "You have not voted on that report."
|
|
||||||
okay: "Successfully removed vote from report."
|
|
||||||
destroy_report:
|
|
||||||
fail: "Something bad happened!"
|
|
||||||
okay: "WHERE DID IT GO??? OH NO!!!"
|
|
||||||
create_comment:
|
|
||||||
rec_inv: "Your comment is too long."
|
|
||||||
okay: "Comment posted successfully."
|
|
||||||
destroy_comment:
|
|
||||||
nopriv: "can't delete other people's comments"
|
|
||||||
okay: "Successfully deleted comment."
|
|
||||||
ban:
|
|
||||||
error: "Weird..."
|
|
||||||
nopriv: "You cannot ban an administrator!"
|
|
||||||
unban: "Unbanned user."
|
|
||||||
perma: "Permanently banned user."
|
|
||||||
temp: "Banned user until %{date}"
|
|
||||||
privilege:
|
|
||||||
nope: "nope!"
|
|
||||||
nopriv: "You'd better check YOUR privileges first!"
|
|
||||||
checked: "Successfully checked this user's %{privilege} privilege."
|
|
||||||
question:
|
question:
|
||||||
destroy:
|
destroy:
|
||||||
not_found: "Question does not exist"
|
not_found: "Question does not exist"
|
||||||
|
|
Loading…
Reference in a new issue