From e6e7780142082c9db124efb1f1a70d1450187791 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Wed, 6 Jul 2022 10:41:34 +0200 Subject: [PATCH] Add translations for list ajax controller --- app/controllers/ajax/list_controller.rb | 26 ++++++++++++------------- config/locales/controllers.en.yml | 18 +++++++++++++++++ config/locales/en.yml | 14 ------------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/app/controllers/ajax/list_controller.rb b/app/controllers/ajax/list_controller.rb index c952cb59..42a6bf07 100644 --- a/app/controllers/ajax/list_controller.rb +++ b/app/controllers/ajax/list_controller.rb @@ -4,7 +4,7 @@ class Ajax::ListController < AjaxController unless user_signed_in? @response[:status] = :noauth - @response[:message] = I18n.t('messages.noauth') + @response[:message] = t(".noauth") return end @@ -13,7 +13,7 @@ class Ajax::ListController < AjaxController rescue ActionController::ParameterMissing => e Sentry.capture_exception(e) @response[:status] = :toolong - @response[:message] = I18n.t('messages.list.create.noname') + @response[:message] = t(".noname") return end params.require :user @@ -24,23 +24,23 @@ class Ajax::ListController < AjaxController rescue ActiveRecord::RecordInvalid => e Sentry.capture_exception(e) @response[:status] = :toolong - @response[:message] = I18n.t('messages.list.create.toolong') + @response[:message] = t(".toolong") return rescue ActiveRecord::RecordNotFound => e Sentry.capture_exception(e) @response[:status] = :notfound - @response[:message] = I18n.t('messages.list.create.notfound') + @response[:message] = t(".notfound") return rescue ActiveRecord::RecordNotUnique => e Sentry.capture_exception(e) @response[:status] = :exists - @response[:message] = I18n.t('messages.list.create.exists') + @response[:message] = t(".exists") return end @response[:status] = :okay @response[:success] = true - @response[:message] = I18n.t('messages.list.create.okay') + @response[:message] = t(".success") @response[:render] = render_to_string(partial: 'modal/list/item', locals: { list: list, user: target_user }) end @@ -49,7 +49,7 @@ class Ajax::ListController < AjaxController unless user_signed_in? @response[:status] = :noauth - @response[:message] = I18n.t('messages.noauth') + @response[:message] = t(".noauth") return end @@ -60,13 +60,13 @@ class Ajax::ListController < AjaxController rescue ActiveRecord::RecordNotFound => e Sentry.capture_exception(e) @response[:status] = :notfound - @response[:message] = I18n.t('messages.list.destroy.notfound') + @response[:message] = t(".notfound") return end @response[:status] = :okay @response[:success] = true - @response[:message] = I18n.t('messages.list.destroy.okay') + @response[:message] = t(".success") end def membership @@ -74,7 +74,7 @@ class Ajax::ListController < AjaxController unless user_signed_in? @response[:status] = :noauth - @response[:message] = I18n.t('messages.noauth') + @response[:message] = t(".noauth") return end @@ -89,7 +89,7 @@ class Ajax::ListController < AjaxController rescue ActiveRecord::RecordNotFound => e Sentry.capture_exception(e) @response[:status] = :notfound - @response[:message] = I18n.t('messages.list.membership.notfound') + @response[:message] = t(".notfound") return end @@ -101,11 +101,11 @@ class Ajax::ListController < AjaxController if add list.add_member target_user if list.members.find_by_user_id(target_user.id).nil? @response[:checked] = true - @response[:message] = I18n.t('messages.list.membership.add') + @response[:message] = t(".success.add") else list.remove_member target_user unless list.members.find_by_user_id(target_user.id).nil? @response[:checked] = false - @response[:message] = I18n.t('messages.list.membership.remove') + @response[:message] = t(".success.remove") end @response[:status] = :okay diff --git a/config/locales/controllers.en.yml b/config/locales/controllers.en.yml index 9b6c6c43..d977d917 100644 --- a/config/locales/controllers.en.yml +++ b/config/locales/controllers.en.yml @@ -24,6 +24,24 @@ en: success: "Successfully deleted questions." remove_all_author: success: :ajax.inbox.remove_all.success + list: + create: + noauth: :messages.noauth + noname: "Please give that list a name." + toolong: "List name too long (30 characters max.)" + notfound: "Could not find user." + exists: "List already exists." + success: "Successfully created list." + destroy: + noauth: :messages.noauth + notfound: "Could not find list." + success: "Successfully deleted list." + membership: + noauth: :messages.noauth + notfound: "List not found." + success: + add: "Successfully added user to list." + remove: "Successfully removed user from list." mute_rule: nopriv: "Can't edit other people's rules" create: diff --git a/config/locales/en.yml b/config/locales/en.yml index bd691f59..0a2206da 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -65,20 +65,6 @@ en: destroy: nopriv: "can't delete other people's answers" okay: "Successfully deleted answer." - list: - create: - noname: "Please give that list a name." - toolong: "List name too long (30 characters max.)" - notfound: "Could not find user." - exists: "List already exists." - okay: "Successfully created list." - destroy: - notfound: "Could not find list." - okay: "Successfully deleted list." - membership: - notfound: "List not found." - add: "Successfully added user to list." - remove: "Successfully removed user from list." moderation: vote: fail: "You have already voted on this report."