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

View File

@ -1,5 +1,6 @@
en:
ajax:
noauth: "You need to be logged in to perform this action."
anonymous_block:
create:
success: :ajax.relationship.create.block.success
@ -23,7 +24,7 @@ en:
success: "Successfully deleted comment."
inbox:
create:
noauth: :messages.noauth
noauth: :ajax.noauth
success: "Successfully added new question."
remove:
success: "Successfully deleted question."
@ -34,18 +35,18 @@ en:
success: :ajax.inbox.remove_all.success
list:
create:
noauth: :messages.noauth
noauth: :ajax.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
noauth: :ajax.noauth
notfound: "Could not find list."
success: "Successfully deleted list."
membership:
noauth: :messages.noauth
noauth: :ajax.noauth
notfound: "List not found."
success:
add: "Successfully added user to list."
@ -80,14 +81,14 @@ en:
mute_rule:
nopriv: "Can't edit other people's rules"
create:
noauth: :messages.noauth
noauth: :ajax.noauth
success: "Rule added successfully."
update:
noauth: :messages.noauth
noauth: :ajax.noauth
nopriv: :ajax.mute_rule.nopriv
success: "Rule updated successfully."
destroy:
noauth: :messages.noauth
noauth: :ajax.noauth
nopriv: :ajax.mute_rule.nopriv
success: "Rule deleted successfully."
question:
@ -116,7 +117,7 @@ en:
error: "You are not following that user."
report:
create:
noauth: :messages.noauth
noauth: :ajax.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}."

View File

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

View File

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