From 80172d085247fbe9bd401812d134f7f90ab809ff Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Wed, 6 Jul 2022 11:23:54 +0200 Subject: [PATCH] Add translations for question ajax controller --- app/controllers/ajax/question_controller.rb | 12 ++++++------ config/locales/controllers.en.yml | 9 +++++++++ config/locales/en.yml | 9 --------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/ajax/question_controller.rb b/app/controllers/ajax/question_controller.rb index f91ca17a..484480de 100644 --- a/app/controllers/ajax/question_controller.rb +++ b/app/controllers/ajax/question_controller.rb @@ -10,20 +10,20 @@ class Ajax::QuestionController < AjaxController question = Question.find params[:question] if question.nil? @response[:status] = :not_found - @response[:message] = I18n.t('messages.question.destroy.not_found') + @response[:message] = t(".notfound") return end if not (current_user.mod? or question.user == current_user) @response[:status] = :not_authorized - @response[:message] = I18n.t('messages.question.destroy.not_authorized') + @response[:message] = t(".noauth") return end question.destroy! @response[:status] = :okay - @response[:message] = I18n.t('messages.question.destroy.okay') + @response[:message] = t(".success") @response[:success] = true end @@ -44,7 +44,7 @@ class Ajax::QuestionController < AjaxController rescue ActiveRecord::RecordInvalid => e Sentry.capture_exception(e) @response[:status] = :rec_inv - @response[:message] = I18n.t('messages.question.create.rec_inv') + @response[:message] = t(".invalid") return end @@ -64,7 +64,7 @@ class Ajax::QuestionController < AjaxController if target_user.nil? @response[:status] = :not_found - @response[:message] = I18n.t('messages.question.create.not_found') + @response[:message] = t(".notfound") question.delete return end @@ -90,7 +90,7 @@ class Ajax::QuestionController < AjaxController end @response[:status] = :okay - @response[:message] = I18n.t('messages.question.create.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 f824d96c..e42b46c1 100644 --- a/config/locales/controllers.en.yml +++ b/config/locales/controllers.en.yml @@ -82,6 +82,15 @@ en: noauth: :messages.noauth nopriv: :ajax.mute_rule.nopriv success: "Rule deleted successfully." + question: + create: + invalid: "Your question is too long." + notfound: "User not found." + success: "Question asked successfully." + destroy: + notfound: "Question does not exist." + noauth: "You are not allowed to delete this question." + success: "Successfully deleted question." relationship: create: block: diff --git a/config/locales/en.yml b/config/locales/en.yml index fc473dc1..b4dcf3c7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -65,15 +65,6 @@ en: destroy: nopriv: "can't delete other people's answers" okay: "Successfully deleted answer." - question: - destroy: - not_found: "Question does not exist" - not_authorized: "You are not allowed to delete this question" - okay: "Successfully deleted question." - create: - rec_inv: "Your question is too long." - not_found: "List not found" - okay: "Question asked successfully." report: create: login: "login required"