From 9460bcfdd71248473e2e13584fbdc166e804daf8 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Wed, 6 Jul 2022 12:09:58 +0200 Subject: [PATCH] Add translations for answer ajax controller --- app/controllers/ajax/answer_controller.rb | 17 +++++------------ config/locales/controllers.en.yml | 8 ++++++++ config/locales/en.yml | 9 --------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/app/controllers/ajax/answer_controller.rb b/app/controllers/ajax/answer_controller.rb index 7a283e7b..de9c611f 100644 --- a/app/controllers/ajax/answer_controller.rb +++ b/app/controllers/ajax/answer_controller.rb @@ -12,7 +12,7 @@ class Ajax::AnswerController < AjaxController unless current_user == inbox_entry.user @response[:status] = :fail - @response[:message] = I18n.t('messages.answer.create.fail') + @response[:message] = t(".error") return end else @@ -20,18 +20,11 @@ class Ajax::AnswerController < AjaxController unless question.user.privacy_allow_stranger_answers @response[:status] = :privacy_stronk - @response[:message] = I18n.t('messages.answer.create.privacy_stronk') + @response[:message] = t(".privacy") return end end - # this should never trigger because empty params throw ParameterMissing - unless params[:answer].length > 0 - @response[:status] = :peter_dinklage - @response[:message] = I18n.t('messages.answer.create.peter_dinklage') - return - end - answer = if inbox inbox_entry.answer params[:answer], current_user else @@ -45,7 +38,7 @@ class Ajax::AnswerController < AjaxController @response[:status] = :okay - @response[:message] = I18n.t('messages.answer.create.okay') + @response[:message] = t(".success") @response[:success] = true unless inbox # this assign is needed because shared/_answerbox relies on it, I think @@ -61,7 +54,7 @@ class Ajax::AnswerController < AjaxController unless (current_user == answer.user) or (privileged? answer.user) @response[:status] = :nopriv - @response[:message] = I18n.t('messages.answer.destroy.nopriv') + @response[:message] = t(".nopriv") return end @@ -71,7 +64,7 @@ class Ajax::AnswerController < AjaxController answer.destroy @response[:status] = :okay - @response[:message] = I18n.t('messages.answer.destroy.okay') + @response[:message] = t(".success") @response[:success] = true end end diff --git a/config/locales/controllers.en.yml b/config/locales/controllers.en.yml index e42b46c1..8c4da416 100644 --- a/config/locales/controllers.en.yml +++ b/config/locales/controllers.en.yml @@ -6,6 +6,14 @@ en: destroy: nopriv: "Cannot remove a block belonging to someone else." success: :ajax.relationship.destroy.block.success + answer: + create: + privacy: "This user does not want other users to answer their question." + success: "Successfully answered question." + error: "Question is not in your inbox." + destroy: + nopriv: "Can't delete other people's answers." + success: "Successfully deleted answer." comment: create: invalid: "Your comment is too long." diff --git a/config/locales/en.yml b/config/locales/en.yml index b4dcf3c7..05357e3b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -56,15 +56,6 @@ en: error: "An error occurred." parameter_error: "%{parameter} is required." noauth: "requires authentication" - answer: - create: - fail: "Question is not in your inbox." - privacy_stronk: "This user does not want other users to answer their question." - peter_dinklage: "Answer is too short." - okay: "Successfully answered question." - destroy: - nopriv: "can't delete other people's answers" - okay: "Successfully deleted answer." report: create: login: "login required"