From 34de119bb1c55e6859700a9159b1c6223c7b8b51 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Wed, 6 Jul 2022 09:21:15 +0200 Subject: [PATCH] Add translations for block/relationship ajax controllers --- .../ajax/anonymous_block_controller.rb | 6 +++--- .../ajax/relationship_controller.rb | 4 ++-- config/locales/controllers.en.yml | 21 +++++++++++++++++++ config/locales/en.yml | 15 ------------- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/app/controllers/ajax/anonymous_block_controller.rb b/app/controllers/ajax/anonymous_block_controller.rb index d2fd3028..4e7a86f4 100644 --- a/app/controllers/ajax/anonymous_block_controller.rb +++ b/app/controllers/ajax/anonymous_block_controller.rb @@ -15,7 +15,7 @@ class Ajax::AnonymousBlockController < AjaxController question.inboxes.first.destroy @response[:status] = :okay - @response[:message] = I18n.t("messages.block.create.okay") + @response[:message] = t(".success") @response[:success] = true end @@ -25,13 +25,13 @@ class Ajax::AnonymousBlockController < AjaxController block = AnonymousBlock.find(params[:id]) if current_user != block.user @response[:status] = :nopriv - @response[:message] = I18n.t("messages.block.destroy.nopriv") + @response[:message] = t(".nopriv") end block.destroy! @response[:status] = :okay - @response[:message] = I18n.t("messages.block.destroy.okay") + @response[:message] = t(".success") @response[:success] = true end end diff --git a/app/controllers/ajax/relationship_controller.rb b/app/controllers/ajax/relationship_controller.rb index 67891526..b91f72c9 100644 --- a/app/controllers/ajax/relationship_controller.rb +++ b/app/controllers/ajax/relationship_controller.rb @@ -16,7 +16,7 @@ class Ajax::RelationshipController < AjaxController type: params[:type] ) @response[:success] = true - @response[:message] = t("messages.#{params[:type]}.create.okay") + @response[:message] = t(".#{params[:type]}.success") rescue Errors::Base => e @response[:message] = t(e.locale_tag) ensure @@ -30,7 +30,7 @@ class Ajax::RelationshipController < AjaxController type: params[:type] ) @response[:success] = true - @response[:message] = t("messages.#{params[:type]}.destroy.okay") + @response[:message] = t(".#{params[:type]}.success") rescue Errors::Base => e @response[:message] = t(e.locale_tag) ensure diff --git a/config/locales/controllers.en.yml b/config/locales/controllers.en.yml index ebc88235..a62d40ef 100644 --- a/config/locales/controllers.en.yml +++ b/config/locales/controllers.en.yml @@ -1,5 +1,11 @@ en: ajax: + anonymous_block: + create: + success: :ajax.relationship.create.block.success + destroy: + nopriv: "Cannot remove a block belonging to someone else." + success: :ajax.relationship.destroy.block.success mute_rule: nopriv: "Can't edit other people's rules" create: @@ -13,6 +19,21 @@ en: noauth: :messages.noauth nopriv: :ajax.mute_rule.nopriv success: "Rule deleted successfully." + relationship: + create: + block: + success: "Successfully blocked user." + error: "You are already blocking that user." + follow: + success: "Successfully followed user." + error: "You are already following that user." + destroy: + block: + success: "Successfully unblocked user." + error: "You are not blocking that user." + follow: + success: "Successfully unfollowed user." + error: "You are not following that user." announcement: create: success: "Announcement created successfully." diff --git a/config/locales/en.yml b/config/locales/en.yml index 509d578c..2729b306 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -72,21 +72,6 @@ en: destroy: nopriv: "can't delete other people's comments" okay: "Successfully deleted comment." - follow: - create: - fail: "You are already following that user." - okay: "Successfully followed user." - destroy: - fail: "You are not following that user." - okay: "Successfully unfollowed user." - block: - create: - fail: "You are already blocking that user." - okay: "Successfully blocked user." - destroy: - fail: "You are not blocking that user." - okay: "Successfully unblocked user." - nopriv: "Cannot remove a block belonging to someone else." list: create: noname: "Please give that list a name."