Add translations for list ajax controller

This commit is contained in:
Andreas Nedbal 2022-07-06 10:41:34 +02:00 committed by Karina Kwiatek
parent 1c31ff41db
commit e6e7780142
3 changed files with 31 additions and 27 deletions

View File

@ -4,7 +4,7 @@ class Ajax::ListController < AjaxController
unless user_signed_in?
@response[:status] = :noauth
@response[:message] = I18n.t('messages.noauth')
@response[:message] = t(".noauth")
return
end
@ -13,7 +13,7 @@ class Ajax::ListController < AjaxController
rescue ActionController::ParameterMissing => e
Sentry.capture_exception(e)
@response[:status] = :toolong
@response[:message] = I18n.t('messages.list.create.noname')
@response[:message] = t(".noname")
return
end
params.require :user
@ -24,23 +24,23 @@ class Ajax::ListController < AjaxController
rescue ActiveRecord::RecordInvalid => e
Sentry.capture_exception(e)
@response[:status] = :toolong
@response[:message] = I18n.t('messages.list.create.toolong')
@response[:message] = t(".toolong")
return
rescue ActiveRecord::RecordNotFound => e
Sentry.capture_exception(e)
@response[:status] = :notfound
@response[:message] = I18n.t('messages.list.create.notfound')
@response[:message] = t(".notfound")
return
rescue ActiveRecord::RecordNotUnique => e
Sentry.capture_exception(e)
@response[:status] = :exists
@response[:message] = I18n.t('messages.list.create.exists')
@response[:message] = t(".exists")
return
end
@response[:status] = :okay
@response[:success] = true
@response[:message] = I18n.t('messages.list.create.okay')
@response[:message] = t(".success")
@response[:render] = render_to_string(partial: 'modal/list/item', locals: { list: list, user: target_user })
end
@ -49,7 +49,7 @@ class Ajax::ListController < AjaxController
unless user_signed_in?
@response[:status] = :noauth
@response[:message] = I18n.t('messages.noauth')
@response[:message] = t(".noauth")
return
end
@ -60,13 +60,13 @@ class Ajax::ListController < AjaxController
rescue ActiveRecord::RecordNotFound => e
Sentry.capture_exception(e)
@response[:status] = :notfound
@response[:message] = I18n.t('messages.list.destroy.notfound')
@response[:message] = t(".notfound")
return
end
@response[:status] = :okay
@response[:success] = true
@response[:message] = I18n.t('messages.list.destroy.okay')
@response[:message] = t(".success")
end
def membership
@ -74,7 +74,7 @@ class Ajax::ListController < AjaxController
unless user_signed_in?
@response[:status] = :noauth
@response[:message] = I18n.t('messages.noauth')
@response[:message] = t(".noauth")
return
end
@ -89,7 +89,7 @@ class Ajax::ListController < AjaxController
rescue ActiveRecord::RecordNotFound => e
Sentry.capture_exception(e)
@response[:status] = :notfound
@response[:message] = I18n.t('messages.list.membership.notfound')
@response[:message] = t(".notfound")
return
end
@ -101,11 +101,11 @@ class Ajax::ListController < AjaxController
if add
list.add_member target_user if list.members.find_by_user_id(target_user.id).nil?
@response[:checked] = true
@response[:message] = I18n.t('messages.list.membership.add')
@response[:message] = t(".success.add")
else
list.remove_member target_user unless list.members.find_by_user_id(target_user.id).nil?
@response[:checked] = false
@response[:message] = I18n.t('messages.list.membership.remove')
@response[:message] = t(".success.remove")
end
@response[:status] = :okay

View File

@ -24,6 +24,24 @@ en:
success: "Successfully deleted questions."
remove_all_author:
success: :ajax.inbox.remove_all.success
list:
create:
noauth: :messages.noauth
noname: "Please give that list a name."
toolong: "List name too long (30 characters max.)"
notfound: "Could not find user."
exists: "List already exists."
success: "Successfully created list."
destroy:
noauth: :messages.noauth
notfound: "Could not find list."
success: "Successfully deleted list."
membership:
noauth: :messages.noauth
notfound: "List not found."
success:
add: "Successfully added user to list."
remove: "Successfully removed user from list."
mute_rule:
nopriv: "Can't edit other people's rules"
create:

View File

@ -65,20 +65,6 @@ en:
destroy:
nopriv: "can't delete other people's answers"
okay: "Successfully deleted answer."
list:
create:
noname: "Please give that list a name."
toolong: "List name too long (30 characters max.)"
notfound: "Could not find user."
exists: "List already exists."
okay: "Successfully created list."
destroy:
notfound: "Could not find list."
okay: "Successfully deleted list."
membership:
notfound: "List not found."
add: "Successfully added user to list."
remove: "Successfully removed user from list."
moderation:
vote:
fail: "You have already voted on this report."