From 79dbf7d1c8555114048b8fe013de9b8339f0b908 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 17 Feb 2022 00:55:44 +0100 Subject: [PATCH] Add translations for mute rule controller actions --- app/controllers/ajax/mute_rule_controller.rb | 16 ++++++++-------- config/locales/controllers.en.yml | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/controllers/ajax/mute_rule_controller.rb b/app/controllers/ajax/mute_rule_controller.rb index e0db82f4..0f52695d 100644 --- a/app/controllers/ajax/mute_rule_controller.rb +++ b/app/controllers/ajax/mute_rule_controller.rb @@ -4,14 +4,14 @@ class Ajax::MuteRuleController < AjaxController unless user_signed_in? @response[:status] = :noauth - @response[:message] = I18n.t('messages.noauth') + @response[:message] = t(".noauth") return end rule = MuteRule.create!(user: current_user, muted_phrase: params[:muted_phrase]) @response[:status] = :okay @response[:success] = true - @response[:message] = "Rule added successfully." + @response[:message] = t(".success") @response[:id] = rule.id end @@ -21,7 +21,7 @@ class Ajax::MuteRuleController < AjaxController unless user_signed_in? @response[:status] = :noauth - @response[:message] = I18n.t('messages.noauth') + @response[:message] = t(".noauth") return end @@ -29,7 +29,7 @@ class Ajax::MuteRuleController < AjaxController if rule.user_id != current_user.id @response[:status] = :nopriv - @response[:message] = "Can't edit other people's rules" + @response[:message] = t(".nopriv") return end @@ -37,7 +37,7 @@ class Ajax::MuteRuleController < AjaxController rule.save! @response[:status] = :okay - @response[:message] = "Rule updated successfully." + @response[:message] = t(".success") @response[:success] = true end @@ -46,7 +46,7 @@ class Ajax::MuteRuleController < AjaxController unless user_signed_in? @response[:status] = :noauth - @response[:message] = I18n.t('messages.noauth') + @response[:message] = t(".noauth") return end @@ -54,14 +54,14 @@ class Ajax::MuteRuleController < AjaxController if rule.user_id != current_user.id @response[:status] = :nopriv - @response[:message] = "Can't edit other people's rules" + @response[:message] = t(".nopriv") return end rule.destroy! @response[:status] = :okay - @response[:message] = "Rule deleted successfully." + @response[:message] = t(".success") @response[:success] = true end end diff --git a/config/locales/controllers.en.yml b/config/locales/controllers.en.yml index 53c7ece0..bfc9cdf0 100644 --- a/config/locales/controllers.en.yml +++ b/config/locales/controllers.en.yml @@ -1,4 +1,18 @@ en: + ajax: + mute_rule: + nopriv: "Can't edit other people's rules" + create: + noauth: :messages.noauth + success: "Rule added successfully." + update: + noauth: :messages.noauth + nopriv: :ajax.mute_rule.nopriv + success: "Rule updated successfully." + destroy: + noauth: :messages.noauth + nopriv: :ajax.mute_rule.nopriv + success: "Rule deleted successfully." announcement: create: success: "Announcement created successfully."