From 489cd2f7e50da44f7a42f923f71466680be69522 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 5 Feb 2021 15:59:34 +0500 Subject: [PATCH] Fix i18n --- .../registrar/bulk_change_controller.rb | 25 +++++++++++-------- .../registrar/tech_contacts_controller.rb | 2 +- config/locales/registrar/bulk_change.en.yml | 3 +++ config/locales/registrar/tech_contacts.en.yml | 4 +++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/controllers/registrar/bulk_change_controller.rb b/app/controllers/registrar/bulk_change_controller.rb index 63d7b6cb1..b11883d6a 100644 --- a/app/controllers/registrar/bulk_change_controller.rb +++ b/app/controllers/registrar/bulk_change_controller.rb @@ -26,19 +26,11 @@ class Registrar private - def process_response(response:, start_notice: "", active_tab:) + def process_response(response:, start_notice: '', active_tab:) parsed_response = JSON.parse(response.body, symbolize_names: true) if response.code == '200' - notices = [start_notice] - - notices << "#{t('registrar.tech_contacts.process_request.affected_domains')}: " \ - "#{parsed_response[:data][:affected_domains].join(', ')}" - - if parsed_response[:data][:skipped_domains] - notices << "#{t('registrar.tech_contacts.process_request.skipped_domains')}: " \ - "#{parsed_response[:data][:skipped_domains].join(', ')}" - end + notices = success_notices(parsed_response, start_notice) flash[:notice] = notices.join(', ') redirect_to registrar_domains_url @@ -48,6 +40,19 @@ class Registrar end end + def success_notices(parsed_response, start_notice) + notices = [start_notice] + + notices << "#{t('.affected_domains')}: " \ + "#{parsed_response[:data][:affected_domains].join(', ')}" + + if parsed_response[:data][:skipped_domains] + notices << "#{t('.skipped_domains')}: " \ + "#{parsed_response[:data][:skipped_domains].join(', ')}" + end + notices + end + def do_request(request, uri) response = if Rails.env.test? do_test_request(request, uri) diff --git a/app/controllers/registrar/tech_contacts_controller.rb b/app/controllers/registrar/tech_contacts_controller.rb index 90dc333f6..3cddb5f36 100644 --- a/app/controllers/registrar/tech_contacts_controller.rb +++ b/app/controllers/registrar/tech_contacts_controller.rb @@ -15,7 +15,7 @@ class Registrar response = do_request(request, uri) - start_notice = t('registrar.tech_contacts.process_request.replaced') + start_notice = t('.replaced') process_response(response: response, start_notice: start_notice, diff --git a/config/locales/registrar/bulk_change.en.yml b/config/locales/registrar/bulk_change.en.yml index 75becfada..58d5fce97 100644 --- a/config/locales/registrar/bulk_change.en.yml +++ b/config/locales/registrar/bulk_change.en.yml @@ -4,6 +4,7 @@ en: new: header: Bulk change technical_contact: Technical contact + admin_contact: Admin contact nameserver: Nameserver bulk_transfer: Bulk transfer bulk_renew: Bulk renew @@ -38,3 +39,5 @@ en: domain_ids: Domains for bulk renewal current_balance: Current balance period: Period + affected_domains: Affected domains + skipped_domains: Skipped domains diff --git a/config/locales/registrar/tech_contacts.en.yml b/config/locales/registrar/tech_contacts.en.yml index bf57f0cc7..b6e5d041b 100644 --- a/config/locales/registrar/tech_contacts.en.yml +++ b/config/locales/registrar/tech_contacts.en.yml @@ -5,3 +5,7 @@ en: replaced: Technical contacts have been successfully replaced. affected_domains: Affected domains skipped_domains: Skipped domains + process_request: + affected_domains: Affected domains + skipped_domains: Skipped domains + replaced: Technical contacts have been successfully replaced.