From 3716ab287abbc8a31fa428e2aa406c0b8a52f421 Mon Sep 17 00:00:00 2001 From: Alan Paruszewski <mparuszewski@gitlab.com> Date: Wed, 21 Apr 2021 10:04:04 +0200 Subject: [PATCH] Translate strings in DAST related services This change adds translations to strings introduced in DAST related services. --- .../dast_scanner_profiles/destroy_service.rb | 6 ++--- .../dast_scanner_profiles/update_service.rb | 4 ++-- .../dast_site_profiles/create_service.rb | 2 +- .../dast_site_profiles/destroy_service.rb | 6 ++--- .../dast_site_profiles/update_service.rb | 6 ++--- locale/gitlab.pot | 24 +++++++++++++++++++ 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/ee/app/services/dast_scanner_profiles/destroy_service.rb b/ee/app/services/dast_scanner_profiles/destroy_service.rb index 9395b8bdd31f85..77ce8aa2d5f46c 100644 --- a/ee/app/services/dast_scanner_profiles/destroy_service.rb +++ b/ee/app/services/dast_scanner_profiles/destroy_service.rb @@ -8,13 +8,13 @@ def execute(id:) return unauthorized unless can_delete_scanner_profile? dast_scanner_profile = find_dast_scanner_profile(id) - return ServiceResponse.error(message: "Scanner profile not found for given parameters") unless dast_scanner_profile - return ServiceResponse.error(message: "Cannot delete #{dast_scanner_profile.name} referenced in security policy") if referenced_in_security_policy?(dast_scanner_profile) + return ServiceResponse.error(message: _('Scanner profile not found for given parameters')) unless dast_scanner_profile + return ServiceResponse.error(message: _('Cannot delete %{profile_name} referenced in security policy') % { profile_name: dast_scanner_profile.name }) if referenced_in_security_policy?(dast_scanner_profile) if dast_scanner_profile.destroy ServiceResponse.success(payload: dast_scanner_profile) else - ServiceResponse.error(message: 'Scanner profile failed to delete') + ServiceResponse.error(message: _('Scanner profile failed to delete')) end end diff --git a/ee/app/services/dast_scanner_profiles/update_service.rb b/ee/app/services/dast_scanner_profiles/update_service.rb index ea18cde01dd2f8..e3d4b5cb665d93 100644 --- a/ee/app/services/dast_scanner_profiles/update_service.rb +++ b/ee/app/services/dast_scanner_profiles/update_service.rb @@ -8,8 +8,8 @@ def execute(id:, profile_name:, target_timeout:, spider_timeout:, scan_type: nil return unauthorized unless can_update_scanner_profile? dast_scanner_profile = find_dast_scanner_profile(id) - return ServiceResponse.error(message: "Scanner profile not found for given parameters") unless dast_scanner_profile - return ServiceResponse.error(message: "Cannot modify #{dast_scanner_profile.name} referenced in security policy") if referenced_in_security_policy?(dast_scanner_profile) + return ServiceResponse.error(message: _('Scanner profile not found for given parameters')) unless dast_scanner_profile + return ServiceResponse.error(message: _('Cannot modify %{profile_name} referenced in security policy') % { profile_name: dast_scanner_profile.name }) if referenced_in_security_policy?(dast_scanner_profile) update_args = { name: profile_name, diff --git a/ee/app/services/dast_site_profiles/create_service.rb b/ee/app/services/dast_site_profiles/create_service.rb index 55a1e20d60604c..755759b60a1745 100644 --- a/ee/app/services/dast_site_profiles/create_service.rb +++ b/ee/app/services/dast_site_profiles/create_service.rb @@ -13,7 +13,7 @@ def initialize(errors) attr_reader :dast_site_profile def execute(name:, target_url:, **params) - return ServiceResponse.error(message: 'Insufficient permissions') unless allowed? + return ServiceResponse.error(message: _('Insufficient permissions')) unless allowed? ActiveRecord::Base.transaction do dast_site = DastSites::FindOrCreateService.new(project, current_user).execute!(url: target_url) diff --git a/ee/app/services/dast_site_profiles/destroy_service.rb b/ee/app/services/dast_site_profiles/destroy_service.rb index 6310769c4e058d..44e9b40f0a3a1d 100644 --- a/ee/app/services/dast_site_profiles/destroy_service.rb +++ b/ee/app/services/dast_site_profiles/destroy_service.rb @@ -8,13 +8,13 @@ def execute(id:) return unauthorized unless can_delete_site_profile? dast_site_profile = find_dast_site_profile(id) - return ServiceResponse.error(message: "Site profile not found for given parameters") unless dast_site_profile - return ServiceResponse.error(message: "Cannot delete #{dast_site_profile.name} referenced in security policy") if referenced_in_security_policy?(dast_site_profile) + return ServiceResponse.error(message: _('Site profile not found for given parameters')) unless dast_site_profile + return ServiceResponse.error(message: _('Cannot delete %{profile_name} referenced in security policy') % { profile_name: dast_site_profile.name }) if referenced_in_security_policy?(dast_site_profile) if dast_site_profile.destroy ServiceResponse.success(payload: dast_site_profile) else - ServiceResponse.error(message: 'Site profile failed to delete') + ServiceResponse.error(message: _('Site profile failed to delete')) end end diff --git a/ee/app/services/dast_site_profiles/update_service.rb b/ee/app/services/dast_site_profiles/update_service.rb index 3532839d38ce82..e0fe1c71901162 100644 --- a/ee/app/services/dast_site_profiles/update_service.rb +++ b/ee/app/services/dast_site_profiles/update_service.rb @@ -13,11 +13,11 @@ def initialize(errors) attr_reader :dast_site_profile def execute(id:, **params) - return ServiceResponse.error(message: 'Insufficient permissions') unless allowed? + return ServiceResponse.error(message: _('Insufficient permissions')) unless allowed? find_dast_site_profile!(id) - return ServiceResponse.error(message: "Cannot modify #{dast_site_profile.name} referenced in security policy") if referenced_in_security_policy? + return ServiceResponse.error(message: _('Cannot modify %{profile_name} referenced in security policy') % { profile_name: dast_site_profile.name }) if referenced_in_security_policy? ActiveRecord::Base.transaction do if target_url = params.delete(:target_url) @@ -36,7 +36,7 @@ def execute(id:, **params) rescue Rollback => e ServiceResponse.error(message: e.errors) rescue ActiveRecord::RecordNotFound => e - ServiceResponse.error(message: "#{e.model} not found") + ServiceResponse.error(message: _('%{model_name} not found') % { model_name: e.model }) rescue ActiveRecord::RecordInvalid => e ServiceResponse.error(message: e.record.errors.full_messages) end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index c7b3c85e5d2ca6..0f0e399118438c 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -694,6 +694,9 @@ msgstr "" msgid "%{milliseconds}ms" msgstr "" +msgid "%{model_name} not found" +msgstr "" + msgid "%{mrText}, this issue will be closed automatically." msgstr "" @@ -5783,6 +5786,9 @@ msgstr "" msgid "Cannot create the abuse report. This user has been blocked." msgstr "" +msgid "Cannot delete %{profile_name} referenced in security policy" +msgstr "" + msgid "Cannot enable shared runners because parent group does not allow it" msgstr "" @@ -5804,6 +5810,9 @@ msgstr "" msgid "Cannot merge" msgstr "" +msgid "Cannot modify %{profile_name} referenced in security policy" +msgstr "" + msgid "Cannot modify managed Kubernetes cluster" msgstr "" @@ -17104,6 +17113,9 @@ msgstr "" msgid "Instance overview" msgstr "" +msgid "Insufficient permissions" +msgstr "" + msgid "Integration" msgstr "" @@ -27544,6 +27556,12 @@ msgstr "" msgid "Scanner" msgstr "" +msgid "Scanner profile failed to delete" +msgstr "" + +msgid "Scanner profile not found for given parameters" +msgstr "" + msgid "Schedule a new pipeline" msgstr "" @@ -29190,6 +29208,12 @@ msgstr "" msgid "Single or combined queries" msgstr "" +msgid "Site profile failed to delete" +msgstr "" + +msgid "Site profile not found for given parameters" +msgstr "" + msgid "Size" msgstr "" -- GitLab