Commit f8fac3f5 authored by Terri Chu's avatar Terri Chu

Merge branch 'mc_rocha-annotate-dast-model-strings-for-localization-301225' into 'master'

Annotate DAST models strings for localization

See merge request gitlab-org/gitlab!72799
parents 3f1ba241 f85a7cbb
......@@ -48,24 +48,24 @@ module Dast
return unless branch_name
unless project.repository.exists?
errors.add(:project, 'must have a repository')
errors.add(:project, _('must have a repository'))
return
end
unless project.repository.branch_exists?(branch_name)
errors.add(:branch_name, 'can\'t reference a branch that does not exist')
errors.add(:branch_name, _('can\'t reference a branch that does not exist'))
end
end
def description_not_nil
errors.add(:description, 'can\'t be nil') if description.nil?
errors.add(:description, _('can\'t be nil')) if description.nil?
end
def association_project_id_matches(association)
return if association.nil?
unless project_id == association.project_id
errors.add(:project_id, "must match #{association.class.underscore}.project_id")
errors.add(:project_id, _('must match %{association}.project_id') % { association: association.class.underscore })
end
end
end
......
......@@ -27,7 +27,7 @@ module Dast
validates :masked, inclusion: { in: [true] }
validates :variable_type, inclusion: { in: ['env_var'] }
validates :key, uniqueness: { scope: :dast_site_profile_id, message: "(%{value}) has already been taken" }
validates :key, uniqueness: { scope: :dast_site_profile_id, message: _('(%{value}) has already been taken') }
# Since user input is base64 encoded before being encrypted, we must validate against the encoded length
MAX_VALUE_LENGTH = 10_000
......@@ -35,7 +35,7 @@ module Dast
validates :value, length: {
maximum: MAX_ENCODED_VALUE_LENGTH, # encoded user input length
too_long: -> (object, data) { "exceeds the #{MAX_VALUE_LENGTH} character limit" } # user input length
too_long: -> (object, data) { _('exceeds the %{max_value_length} character limit') % { max_value_length: MAX_VALUE_LENGTH } } # user input length
}
# User input is base64 encoded before being encrypted in order to allow it to be masked by default
......
......@@ -23,7 +23,7 @@ class DastSite < ApplicationRecord
return unless dast_site_validation_id
if project_id != dast_site_validation.project.id
errors.add(:project_id, 'does not match dast_site_validation.project')
errors.add(:project_id, _('does not match dast_site_validation.project'))
end
end
end
......@@ -87,18 +87,18 @@ class DastSiteProfile < ApplicationRecord
def dast_site_project_id_fk
unless project_id == dast_site&.project_id
errors.add(:project_id, 'does not match dast_site.project')
errors.add(:project_id, _('does not match dast_site.project'))
end
end
def excluded_urls_contains_valid_urls
validate_excluded_urls_with("contains invalid URLs (%{urls})") do |excluded_url|
validate_excluded_urls_with(_("contains invalid URLs (%{urls})")) do |excluded_url|
!Gitlab::UrlSanitizer.valid?(excluded_url)
end
end
def excluded_urls_contains_valid_strings
validate_excluded_urls_with("contains URLs that exceed the 1024 character limit (%{urls})") do |excluded_url|
validate_excluded_urls_with(_("contains URLs that exceed the 1024 character limit (%{urls})")) do |excluded_url|
excluded_url.length > 1024
end
end
......
......@@ -39888,12 +39888,18 @@ msgstr ""
msgid "can only have one escalation policy"
msgstr ""
msgid "can't be nil"
msgstr ""
msgid "can't be the same as the source project"
msgstr ""
msgid "can't include: %{invalid_storages}"
msgstr ""
msgid "can't reference a branch that does not exist"
msgstr ""
msgid "cannot be a date in the past"
msgstr ""
......@@ -40269,6 +40275,12 @@ msgstr ""
msgid "container_name cannot be larger than %{max_length} chars"
msgstr ""
msgid "contains URLs that exceed the 1024 character limit (%{urls})"
msgstr ""
msgid "contains invalid URLs (%{urls})"
msgstr ""
msgid "contribute to this project."
msgstr ""
......@@ -40337,6 +40349,12 @@ msgstr ""
msgid "does not have a supported extension. Only %{extension_list} are supported"
msgstr ""
msgid "does not match dast_site.project"
msgstr ""
msgid "does not match dast_site_validation.project"
msgstr ""
msgid "download it"
msgstr ""
......@@ -40390,6 +40408,9 @@ msgstr ""
msgid "example.com"
msgstr ""
msgid "exceeds the %{max_value_length} character limit"
msgstr ""
msgid "exceeds the limit of %{bytes} bytes"
msgstr ""
......@@ -41068,6 +41089,12 @@ msgstr ""
msgid "must be unique by status and elapsed time within a policy"
msgstr ""
msgid "must have a repository"
msgstr ""
msgid "must match %{association}.project_id"
msgstr ""
msgid "my-awesome-group"
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment