Add translations for ajax controller error handling

This commit is contained in:
Andreas Nedbal 2022-07-06 13:13:17 +02:00 committed by Karina Kwiatek
parent 6d4478b7c4
commit 73ac742332
4 changed files with 20 additions and 16 deletions

View File

@ -12,7 +12,7 @@ class AjaxController < ApplicationController
@response = { @response = {
success: false, success: false,
message: "Something went wrong", message: t("errors.base"),
status: :err status: :err
} }
@ -25,7 +25,7 @@ class AjaxController < ApplicationController
@response = { @response = {
success: false, success: false,
message: "Missing parameter: #{e.key}", message: t("errors.parameter_error", parameter: e.key),
status: :err status: :err
} }
@ -37,7 +37,7 @@ class AjaxController < ApplicationController
@response = { @response = {
success: false, success: false,
message: "Invalid parameter", message: t("errors.invalid_parameter"),
status: :err status: :err
} }
@ -49,7 +49,7 @@ class AjaxController < ApplicationController
@response = { @response = {
success: false, success: false,
message: "Record not found", message: t("errors.record_not_found"),
status: :not_found status: :not_found
} }
@ -61,7 +61,7 @@ class AjaxController < ApplicationController
@response = { @response = {
success: false, success: false,
message: I18n.t("messages.parameter_error", parameter: e.param.capitalize), message: t("errors.parameter_error", parameter: e.param.capitalize),
status: :parameter_error status: :parameter_error
} }

View File

@ -1,5 +1,6 @@
en: en:
ajax: ajax:
noauth: "You need to be logged in to perform this action."
anonymous_block: anonymous_block:
create: create:
success: :ajax.relationship.create.block.success success: :ajax.relationship.create.block.success
@ -23,7 +24,7 @@ en:
success: "Successfully deleted comment." success: "Successfully deleted comment."
inbox: inbox:
create: create:
noauth: :messages.noauth noauth: :ajax.noauth
success: "Successfully added new question." success: "Successfully added new question."
remove: remove:
success: "Successfully deleted question." success: "Successfully deleted question."
@ -34,18 +35,18 @@ en:
success: :ajax.inbox.remove_all.success success: :ajax.inbox.remove_all.success
list: list:
create: create:
noauth: :messages.noauth noauth: :ajax.noauth
noname: "Please give that list a name." noname: "Please give that list a name."
toolong: "List name too long (30 characters max.)" toolong: "List name too long (30 characters max.)"
notfound: "Could not find user." notfound: "Could not find user."
exists: "List already exists." exists: "List already exists."
success: "Successfully created list." success: "Successfully created list."
destroy: destroy:
noauth: :messages.noauth noauth: :ajax.noauth
notfound: "Could not find list." notfound: "Could not find list."
success: "Successfully deleted list." success: "Successfully deleted list."
membership: membership:
noauth: :messages.noauth noauth: :ajax.noauth
notfound: "List not found." notfound: "List not found."
success: success:
add: "Successfully added user to list." add: "Successfully added user to list."
@ -80,14 +81,14 @@ en:
mute_rule: mute_rule:
nopriv: "Can't edit other people's rules" nopriv: "Can't edit other people's rules"
create: create:
noauth: :messages.noauth noauth: :ajax.noauth
success: "Rule added successfully." success: "Rule added successfully."
update: update:
noauth: :messages.noauth noauth: :ajax.noauth
nopriv: :ajax.mute_rule.nopriv nopriv: :ajax.mute_rule.nopriv
success: "Rule updated successfully." success: "Rule updated successfully."
destroy: destroy:
noauth: :messages.noauth noauth: :ajax.noauth
nopriv: :ajax.mute_rule.nopriv nopriv: :ajax.mute_rule.nopriv
success: "Rule deleted successfully." success: "Rule deleted successfully."
question: question:
@ -116,7 +117,7 @@ en:
error: "You are not following that user." error: "You are not following that user."
report: report:
create: create:
noauth: :messages.noauth noauth: :ajax.noauth
unknown: "You can't report this entity." unknown: "You can't report this entity."
notfound: "Could not find %{parameter}" notfound: "Could not find %{parameter}"
success: "%{parameter} reported. A moderator will decide what happens with the %{parameter}." success: "%{parameter} reported. A moderator will decide what happens with the %{parameter}."

View File

@ -53,9 +53,6 @@ en:
until: "Banned until: %{time}" until: "Banned until: %{time}"
messages: messages:
noscript: "Please activate JavaScript." noscript: "Please activate JavaScript."
error: "An error occurred."
parameter_error: "%{parameter} is required."
noauth: "requires authentication"
views: views:
locale: locale:
languages: "Languages" languages: "Languages"

View File

@ -27,3 +27,9 @@ en:
conflict: "This already exists" conflict: "This already exists"
invalid_otp: "The code you entered was invalid." invalid_otp: "The code you entered was invalid."
parameter_error: "%{parameter} is required."
invalid_parameter: "Invalid parameter"
record_not_found: "Record not found"