diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/file_size_validator.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/access.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/auth/ldap/adapter.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/auth/user_access_denied_reason.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/bitbucket_import/importer.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/bitbucket_server_import/importer.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/config/entry/attributable.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/git/push.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/git_access.rb | 32 | ||||
-rw-r--r-- | lib/gitlab/legacy_github_import/client.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/legacy_github_import/importer.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/manifest_import/manifest.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/omniauth_initializer.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/quick_actions/merge_request_actions.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/untrusted_regexp/ruby_syntax.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/utils.rb | 4 | ||||
-rw-r--r-- | lib/mattermost/session.rb | 2 |
17 files changed, 53 insertions, 53 deletions
diff --git a/lib/file_size_validator.rb b/lib/file_size_validator.rb index 70a145cd5bd..cc7d4a127c7 100644 --- a/lib/file_size_validator.rb +++ b/lib/file_size_validator.rb @@ -9,7 +9,7 @@ class FileSizeValidator < ActiveModel::EachValidator def initialize(options) if range = (options.delete(:in) || options.delete(:within)) - raise ArgumentError, ":in and :within must be a Range" unless range.is_a?(Range) + raise ArgumentError, _(":in and :within must be a Range") unless range.is_a?(Range) options[:minimum], options[:maximum] = range.begin, range.end options[:maximum] -= 1 if range.exclude_end? @@ -22,21 +22,21 @@ class FileSizeValidator < ActiveModel::EachValidator keys = CHECKS.keys & options.keys if keys.empty? - raise ArgumentError, 'Range unspecified. Specify the :within, :maximum, :minimum, or :is option.' + raise ArgumentError, _('Range unspecified. Specify the :within, :maximum, :minimum, or :is option.') end keys.each do |key| value = options[key] unless (value.is_a?(Integer) && value >= 0) || value.is_a?(Symbol) - raise ArgumentError, ":#{key} must be a nonnegative Integer or symbol" + raise ArgumentError, _(":%{key} must be a nonnegative Integer or symbol") % { key: key } end end end # rubocop: disable CodeReuse/ActiveRecord def validate_each(record, attribute, value) - raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.is_a? CarrierWave::Uploader::Base + raise(ArgumentError, _("A CarrierWave::Uploader::Base object was expected")) unless value.is_a? CarrierWave::Uploader::Base value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.is_a?(String) diff --git a/lib/gitlab/access.rb b/lib/gitlab/access.rb index 6eb08f674c2..264bd2225f4 100644 --- a/lib/gitlab/access.rb +++ b/lib/gitlab/access.rb @@ -72,10 +72,10 @@ module Gitlab def protection_options { - "Not protected: Both developers and maintainers can push new commits, force push, or delete the branch." => PROTECTION_NONE, - "Protected against pushes: Developers cannot push new commits, but are allowed to accept merge requests to the branch. Maintainers can push to the branch." => PROTECTION_DEV_CAN_MERGE, - "Partially protected: Both developers and maintainers can push new commits, but cannot force push or delete the branch." => PROTECTION_DEV_CAN_PUSH, - "Fully protected: Developers cannot push new commits, but maintainers can. No-one can force push or delete the branch." => PROTECTION_FULL + _("ProjectProtectionLevel|Not protected: Both developers and maintainers can push new commits, force push, or delete the branch.") => PROTECTION_NONE, + _("ProjectProtectionLevel|Protected against pushes: Developers cannot push new commits, but are allowed to accept merge requests to the branch. Maintainers can push to the branch.") => PROTECTION_DEV_CAN_MERGE, + _("ProjectProtectionLevel|Partially protected: Both developers and maintainers can push new commits, but cannot force push or delete the branch.") => PROTECTION_DEV_CAN_PUSH, + _("ProjectProtectionLevel|Fully protected: Developers cannot push new commits, but maintainers can. No-one can force push or delete the branch.") => PROTECTION_FULL } end diff --git a/lib/gitlab/auth/ldap/adapter.rb b/lib/gitlab/auth/ldap/adapter.rb index 15b9d5ad6e9..ba0019cb023 100644 --- a/lib/gitlab/auth/ldap/adapter.rb +++ b/lib/gitlab/auth/ldap/adapter.rb @@ -102,7 +102,7 @@ module Gitlab options[:size] = limit if limit if fields.include?('dn') - raise ArgumentError, 'It is not currently possible to search the DN and other fields at the same time.' if fields.size > 1 + raise ArgumentError, _('It is not currently possible to search the DN and other fields at the same time.') if fields.size > 1 options[:base] = value options[:scope] = Net::LDAP::SearchScope_BaseObject @@ -127,9 +127,9 @@ module Gitlab def connection_error_message(exception) if exception.is_a?(Timeout::Error) - "LDAP search timed out after #{config.timeout} seconds" + _("LDAP search timed out after %{config_timeout} seconds") % { config_timeout: config.timeout } else - "LDAP search raised exception #{exception.class}: #{exception.message}" + _("LDAP search raised exception %{exception_class}: %{exception_message}") % { exception_class: exception.class, exception_message: exception.message } end end diff --git a/lib/gitlab/auth/user_access_denied_reason.rb b/lib/gitlab/auth/user_access_denied_reason.rb index fd09fe76c02..4f37bad0604 100644 --- a/lib/gitlab/auth/user_access_denied_reason.rb +++ b/lib/gitlab/auth/user_access_denied_reason.rb @@ -10,12 +10,12 @@ module Gitlab def rejection_message case rejection_type when :internal - "This action cannot be performed by internal users" + _("This action cannot be performed by internal users") when :terms_not_accepted - "You (#{@user.to_reference}) must accept the Terms of Service in order to perform this action. "\ - "Please access GitLab from a web browser to accept these terms." + _("You (%{user_to_reference}) must accept the Terms of Service in order to perform this action. "\ + "Please access GitLab from a web browser to accept these terms.") % { user_to_reference: @user.to_reference } else - "Your account has been blocked." + _("Your account has been blocked.") end end diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb index 769d3279f91..11d837888f4 100644 --- a/lib/gitlab/bitbucket_import/importer.rb +++ b/lib/gitlab/bitbucket_import/importer.rb @@ -36,7 +36,7 @@ module Gitlab return unless errors.any? project.import_state.update_column(:last_error, { - message: 'The remote data could not be fully imported.', + message: _('The remote data could not be fully imported.'), errors: errors }.to_json) end @@ -139,7 +139,7 @@ module Gitlab if label.valid? @labels[label_params[:title]] = label else - raise "Failed to create label \"#{label_params[:title]}\" for project \"#{project.full_name}\"" + raise _("Failed to create label \"%{label}\" for project \"%{project_full_name}\"") % { label: label_params[:title], project_full_name: project.full_name } end end end diff --git a/lib/gitlab/bitbucket_server_import/importer.rb b/lib/gitlab/bitbucket_server_import/importer.rb index 1d3ddeeb0f1..ef27fb23e16 100644 --- a/lib/gitlab/bitbucket_server_import/importer.rb +++ b/lib/gitlab/bitbucket_server_import/importer.rb @@ -55,7 +55,7 @@ module Gitlab return unless errors.any? project.import_state.update_column(:last_error, { - message: 'The remote data could not be fully imported.', + message: _('The remote data could not be fully imported.'), errors: errors }.to_json) end diff --git a/lib/gitlab/config/entry/attributable.rb b/lib/gitlab/config/entry/attributable.rb index 560fe63df0e..b651819a56c 100644 --- a/lib/gitlab/config/entry/attributable.rb +++ b/lib/gitlab/config/entry/attributable.rb @@ -10,7 +10,7 @@ module Gitlab def attributes(*attributes) attributes.flatten.each do |attribute| if method_defined?(attribute) - raise ArgumentError, 'Method already defined!' + raise ArgumentError, _('Method already defined!') end define_method(attribute) do diff --git a/lib/gitlab/git/push.rb b/lib/gitlab/git/push.rb index b6577ba17f1..11073a12ba3 100644 --- a/lib/gitlab/git/push.rb +++ b/lib/gitlab/git/push.rb @@ -44,7 +44,7 @@ module Gitlab def modified_paths unless branch_updated? - raise ArgumentError, 'Unable to calculate modified paths!' + raise ArgumentError, _('Unable to calculate modified paths!') end strong_memoize(:modified_paths) do diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index cb80ed64eff..0f014d1d6b0 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -17,19 +17,19 @@ module Gitlab ANY = '_any' ERROR_MESSAGES = { - upload: 'You are not allowed to upload code for this project.', - download: 'You are not allowed to download code from this project.', - auth_upload: 'You are not allowed to upload code.', - auth_download: 'You are not allowed to download code.', - deploy_key_upload: 'This deploy key does not have write access to this project.', - no_repo: 'A repository for this project does not exist yet.', - project_not_found: 'The project you were looking for could not be found.', - command_not_allowed: "The command you're trying to execute is not allowed.", - upload_pack_disabled_over_http: 'Pulling over HTTP is not allowed.', - receive_pack_disabled_over_http: 'Pushing over HTTP is not allowed.', - read_only: 'The repository is temporarily read-only. Please try again later.', - cannot_push_to_read_only: "You can't push code to a read-only GitLab instance.", - push_code: 'You are not allowed to push code to this project.' + upload: _('You are not allowed to upload code for this project.'), + download: _('You are not allowed to download code from this project.'), + auth_upload: _('You are not allowed to upload code.'), + auth_download: _('You are not allowed to download code.'), + deploy_key_upload: _('This deploy key does not have write access to this project.'), + no_repo: _('A repository for this project does not exist yet.'), + project_not_found: _('The project you were looking for could not be found.'), + command_not_allowed: _('The command you\'re trying to execute is not allowed.'), + upload_pack_disabled_over_http: _('Pulling over HTTP is not allowed.'), + receive_pack_disabled_over_http: _('Pushing over HTTP is not allowed.'), + read_only: _('The repository is temporarily read-only. Please try again later.'), + cannot_push_to_read_only: _('You can\'t push code to a read-only GitLab instance.'), + push_code: _('You are not allowed to push code to this project.') }.freeze INTERNAL_TIMEOUT = 50.seconds.freeze @@ -124,7 +124,7 @@ module Gitlab return unless actor.is_a?(Key) unless actor.valid? - raise UnauthorizedError, "Your SSH key #{actor.errors[:key].first}." + raise UnauthorizedError, _("Your SSH key %{first_actor_error}.") % { first_actor_error: actor.errors[:key].first } end end @@ -132,7 +132,7 @@ module Gitlab return if request_from_ci_build? unless protocol_allowed? - raise UnauthorizedError, "Git access over #{protocol.upcase} is not allowed" + raise UnauthorizedError, _("Git access over %{protocol} is not allowed") % { protocol: protocol.upcase } end end @@ -223,7 +223,7 @@ module Gitlab project = Projects::CreateService.new(user, project_params).execute unless project.saved? - raise ProjectCreationError, "Could not create project: #{project.errors.full_messages.join(', ')}" + raise ProjectCreationError, _("Could not create project: %{project_errors_full_messages}") % { project_errors_full_messages: project.errors.full_messages.join(', ') } end @project = project diff --git a/lib/gitlab/legacy_github_import/client.rb b/lib/gitlab/legacy_github_import/client.rb index bbdd094e33b..53a8f0b46d8 100644 --- a/lib/gitlab/legacy_github_import/client.rb +++ b/lib/gitlab/legacy_github_import/client.rb @@ -34,7 +34,7 @@ module Gitlab def client unless config raise Projects::ImportService::Error, - 'OAuth configuration for GitHub missing.' + _('OAuth configuration for GitHub missing.') end @client ||= ::OAuth2::Client.new( diff --git a/lib/gitlab/legacy_github_import/importer.rb b/lib/gitlab/legacy_github_import/importer.rb index 70b18221a66..a7aee4759e9 100644 --- a/lib/gitlab/legacy_github_import/importer.rb +++ b/lib/gitlab/legacy_github_import/importer.rb @@ -24,7 +24,7 @@ module Gitlab unless credentials raise Projects::ImportService::Error, - "Unable to find project import data credentials for project ID: #{@project.id}" + _("Unable to find project import data credentials for project ID: %{project_id}") % { project_id: @project.id } end opts = {} @@ -81,7 +81,7 @@ module Gitlab return unless errors.any? project.import_state.update_column(:last_error, { - message: 'The remote data could not be fully imported.', + message: _('The remote data could not be fully imported.'), errors: errors }.to_json) end diff --git a/lib/gitlab/manifest_import/manifest.rb b/lib/gitlab/manifest_import/manifest.rb index 7208fe5bbc5..f1252e450cf 100644 --- a/lib/gitlab/manifest_import/manifest.rb +++ b/lib/gitlab/manifest_import/manifest.rb @@ -22,7 +22,7 @@ module Gitlab @parsed_xml = Nokogiri::XML(file) { |config| config.strict } @errors = [] rescue Nokogiri::XML::SyntaxError - @errors = ['The uploaded file is not a valid XML file.'] + @errors = [_('The uploaded file is not a valid XML file.')] end def projects @@ -40,11 +40,11 @@ module Gitlab return false if @errors.any? unless validate_remote - @errors << 'Make sure a <remote> tag is present and is valid.' + @errors << _('Make sure a <remote> tag is present and is valid.') end unless validate_projects - @errors << 'Make sure every <project> tag has name and path attributes.' + @errors << _('Make sure every <project> tag has name and path attributes.') end @errors.empty? diff --git a/lib/gitlab/omniauth_initializer.rb b/lib/gitlab/omniauth_initializer.rb index e0ac9eec1f2..15985446ed9 100644 --- a/lib/gitlab/omniauth_initializer.rb +++ b/lib/gitlab/omniauth_initializer.rb @@ -58,7 +58,7 @@ module Gitlab def cas3_signout_handler lambda do |request| ticket = request.params[:session_index] - raise "Service Ticket not found." unless Gitlab::Auth::OAuth::Session.valid?(:cas3, ticket) + raise _("Service Ticket not found.") unless Gitlab::Auth::OAuth::Session.valid?(:cas3, ticket) Gitlab::Auth::OAuth::Session.destroy(:cas3, ticket) true diff --git a/lib/gitlab/quick_actions/merge_request_actions.rb b/lib/gitlab/quick_actions/merge_request_actions.rb index bade59182a1..4ef2231a7cc 100644 --- a/lib/gitlab/quick_actions/merge_request_actions.rb +++ b/lib/gitlab/quick_actions/merge_request_actions.rb @@ -8,8 +8,8 @@ module Gitlab included do # MergeRequest only quick actions definitions - desc 'Merge (when the pipeline succeeds)' - explanation 'Merges this merge request when the pipeline succeeds.' + desc _('Merge (when the pipeline succeeds)') + explanation _('Merges this merge request when the pipeline succeeds.') types MergeRequest condition do last_diff_sha = params && params[:merge_request_diff_head_sha] @@ -20,7 +20,7 @@ module Gitlab @updates[:merge] = params[:merge_request_diff_head_sha] end - desc 'Toggle the Work In Progress status' + desc _('Toggle the Work In Progress status') explanation do verb = quick_action_target.work_in_progress? ? 'Unmarks' : 'Marks' noun = quick_action_target.to_ability_name.humanize(capitalize: false) @@ -36,9 +36,9 @@ module Gitlab @updates[:wip_event] = quick_action_target.work_in_progress? ? 'unwip' : 'wip' end - desc 'Set target branch' + desc _('Set target branch') explanation do |branch_name| - "Sets target branch to #{branch_name}." + _("Sets target branch to %{branch_name}.") % { branch_name: branch_name } end params '<Local branch name>' types MergeRequest diff --git a/lib/gitlab/untrusted_regexp/ruby_syntax.rb b/lib/gitlab/untrusted_regexp/ruby_syntax.rb index 6adf119aa75..fc247c15d1e 100644 --- a/lib/gitlab/untrusted_regexp/ruby_syntax.rb +++ b/lib/gitlab/untrusted_regexp/ruby_syntax.rb @@ -27,10 +27,10 @@ module Gitlab end def self.fabricate!(pattern, fallback: false) - raise RegexpError, 'Pattern is not string!' unless pattern.is_a?(String) + raise RegexpError, _('Pattern is not string!') unless pattern.is_a?(String) matches = pattern.match(PATTERN) - raise RegexpError, 'Invalid regular expression!' if matches.nil? + raise RegexpError, _('Invalid regular expression!') if matches.nil? begin create_untrusted_regexp(matches[:regexp], matches[:flags]) diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb index 16ec8a8bb28..e10a6a704d2 100644 --- a/lib/gitlab/utils.rb +++ b/lib/gitlab/utils.rb @@ -26,8 +26,8 @@ module Gitlab end def ensure_utf8_size(str, bytes:) - raise ArgumentError, 'Empty string provided!' if str.empty? - raise ArgumentError, 'Negative string size provided!' if bytes.negative? + raise ArgumentError, _('Empty string provided!') if str.empty? + raise ArgumentError, _('Negative string size provided!') if bytes.negative? truncated = str.each_char.each_with_object(+'') do |char, object| if object.bytesize + char.bytesize > bytes diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb index e2083848a8d..c83a1cec213 100644 --- a/lib/mattermost/session.rb +++ b/lib/mattermost/session.rb @@ -3,7 +3,7 @@ module Mattermost class NoSessionError < Mattermost::Error def message - 'No session could be set up, is Mattermost configured with Single Sign On?' + _('No session could be set up, is Mattermost configured with Single Sign On?') end end |