From 1c31ff41db34a8af638c0057c586f3e8e1c1713f Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Wed, 6 Jul 2022 10:29:05 +0200 Subject: [PATCH] Add translations for inbox ajax controller --- app/controllers/ajax/inbox_controller.rb | 18 +++++++++--------- config/locales/controllers.en.yml | 11 +++++++++++ config/locales/en.yml | 8 -------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/controllers/ajax/inbox_controller.rb b/app/controllers/ajax/inbox_controller.rb index 6d83d189..64bee3e1 100644 --- a/app/controllers/ajax/inbox_controller.rb +++ b/app/controllers/ajax/inbox_controller.rb @@ -2,7 +2,7 @@ class Ajax::InboxController < AjaxController def create unless user_signed_in? @response[:status] = :noauth - @response[:message] = I18n.t('messages.noauth') + @response[:message] = t(".noauth") return end @@ -14,7 +14,7 @@ class Ajax::InboxController < AjaxController inbox = Inbox.create!(user: current_user, question_id: question.id, new: true) @response[:status] = :okay - @response[:message] = I18n.t('messages.inbox.create.okay') + @response[:message] = t(".success") @response[:success] = true @response[:render] = render_to_string(partial: 'inbox/entry', locals: { i: inbox }) inbox.update(new: false) @@ -27,7 +27,7 @@ class Ajax::InboxController < AjaxController unless current_user == inbox.user @response[:status] = :fail - @response[:message] = I18n.t('messages.inbox.remove.fail') + @response[:message] = t(".error") return end @@ -36,12 +36,12 @@ class Ajax::InboxController < AjaxController rescue => e Sentry.capture_exception(e) @response[:status] = :err - @response[:message] = I18n.t('messages.error') + @response[:message] = t("errors.base") return end @response[:status] = :okay - @response[:message] = I18n.t('messages.inbox.remove.okay') + @response[:message] = t(".success") @response[:success] = true end @@ -53,12 +53,12 @@ class Ajax::InboxController < AjaxController rescue => e Sentry.capture_exception(e) @response[:status] = :err - @response[:message] = I18n.t('messages.error') + @response[:message] = t("errors.base") return end @response[:status] = :okay - @response[:message] = I18n.t('messages.inbox.remove_all.okay') + @response[:message] = t(".success") @response[:success] = true end @@ -71,12 +71,12 @@ class Ajax::InboxController < AjaxController rescue => e Sentry.capture_exception(e) @response[:status] = :err - @response[:message] = I18n.t('messages.error') + @response[:message] = t("errors.base") return end @response[:status] = :okay - @response[:message] = I18n.t('messages.inbox.remove_all.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 5c1fd5cc..9b6c6c43 100644 --- a/config/locales/controllers.en.yml +++ b/config/locales/controllers.en.yml @@ -13,6 +13,17 @@ en: destroy: nopriv: "Can't delete other people's comments." success: "Successfully deleted comment." + inbox: + create: + noauth: :messages.noauth + success: "Successfully added new question." + remove: + success: "Successfully deleted question." + error: "Question is not in your inbox." + remove_all: + success: "Successfully deleted questions." + remove_all_author: + success: :ajax.inbox.remove_all.success mute_rule: nopriv: "Can't edit other people's rules" create: diff --git a/config/locales/en.yml b/config/locales/en.yml index 75b034cb..bd691f59 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -79,14 +79,6 @@ en: notfound: "List not found." add: "Successfully added user to list." remove: "Successfully removed user from list." - inbox: - create: - okay: "Successfully added new question." - remove: - fail: "question not in your inbox" - okay: "Successfully deleted question." - remove_all: - okay: "Successfully deleted questions." moderation: vote: fail: "You have already voted on this report."