Commit 85bbea8e authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'ee-mw-i18n-app-helpers-services' into 'master'

(EE port) Externalize strings in app/services and app/helpers

See merge request gitlab-org/gitlab-ee!10764
parents 3cf0b534 20216f15
......@@ -45,7 +45,7 @@ module MilestonesHelper
when :closed
issues.closed
else
raise ArgumentError, "invalid milestone state `#{state}`"
raise ArgumentError, _("invalid milestone state `%{state}`") % { state: state }
end
issues.size
......@@ -145,8 +145,13 @@ module MilestonesHelper
content = []
content << n_("1 open issue", "%d open issues", issues["opened"]) % issues["opened"] if issues["opened"]
content << n_("1 closed issue", "%d closed issues", issues["closed"]) % issues["closed"] if issues["closed"]
if issues["opened"]
content << n_("1 open issue", "%{issues} open issues", issues["opened"]) % { issues: issues["opened"] }
end
if issues["closed"]
content << n_("1 closed issue", "%{issues} closed issues", issues["closed"]) % { issues: issues["closed"] }
end
content.join('<br />').html_safe
end
......@@ -158,9 +163,9 @@ module MilestonesHelper
content = []
content << n_("1 open merge request", "%d open merge requests", merge_requests.opened.count) % merge_requests.opened.count if merge_requests.opened.any?
content << n_("1 closed merge request", "%d closed merge requests", merge_requests.closed.count) % merge_requests.closed.count if merge_requests.closed.any?
content << n_("1 merged merge request", "%d merged merge requests", merge_requests.merged.count) % merge_requests.merged.count if merge_requests.merged.any?
content << n_("1 open merge request", "%{merge_requests} open merge requests", merge_requests.opened.count) % { merge_requests: merge_requests.opened.count } if merge_requests.opened.any?
content << n_("1 closed merge request", "%{merge_requests} closed merge requests", merge_requests.closed.count) % { merge_requests: merge_requests.closed.count } if merge_requests.closed.any?
content << n_("1 merged merge request", "%{merge_requests} merged merge requests", merge_requests.merged.count) % { merge_requests: merge_requests.merged.count } if merge_requests.merged.any?
content.join('<br />').html_safe
end
......@@ -178,15 +183,15 @@ module MilestonesHelper
"#{milestone.start_date.to_s(:medium)}#{milestone.due_date.to_s(:medium)}"
elsif milestone.due_date
if milestone.due_date.past?
"expired on #{milestone.due_date.to_s(:medium)}"
_("expired on %{milestone_due_date}") % { milestone_due_date: milestone.due_date.strftime('%b %-d, %Y') }
else
"expires on #{milestone.due_date.to_s(:medium)}"
_("expires on %{milestone_due_date}") % { milestone_due_date: milestone.due_date.strftime('%b %-d, %Y') }
end
elsif milestone.start_date
if milestone.start_date.past?
"started on #{milestone.start_date.to_s(:medium)}"
_("started on %{milestone_start_date}") % { milestone_start_date: milestone.start_date.strftime('%b %-d, %Y') }
else
"starts on #{milestone.start_date.to_s(:medium)}"
_("starts on %{milestone_start_date}") % { milestone_start_date: milestone.start_date.strftime('%b %-d, %Y') }
end
end
end
......
......@@ -20,7 +20,7 @@ module Files
super
if file_has_changed?(@file_path, @last_commit_sha)
raise FileChangedError, "You are attempting to delete a file that has been previously updated."
raise FileChangedError, _("You are attempting to delete a file that has been previously updated.")
end
end
end
......
......@@ -46,13 +46,13 @@ module Groups
if @group.subgroup?
unless can?(current_user, :create_subgroup, @group.parent)
@group.parent = nil
@group.errors.add(:parent_id, 'You don’t have permission to create a subgroup in this group.')
@group.errors.add(:parent_id, s_('CreateGroup|You don’t have permission to create a subgroup in this group.'))
return false
end
else
unless can?(current_user, :create_group)
@group.errors.add(:base, 'You don’t have permission to create groups.')
@group.errors.add(:base, s_('CreateGroup|You don’t have permission to create groups.'))
return false
end
......
......@@ -3,11 +3,11 @@
module Groups
class TransferService < Groups::BaseService
ERROR_MESSAGES = {
database_not_supported: 'Database is not supported.',
namespace_with_same_path: 'The parent group already has a subgroup with the same path.',
group_is_already_root: 'Group is already a root group.',
same_parent_as_current: 'Group is already associated to the parent group.',
invalid_policies: "You don't have enough permissions."
database_not_supported: s_('TransferGroup|Database is not supported.'),
namespace_with_same_path: s_('TransferGroup|The parent group already has a subgroup with the same path.'),
group_is_already_root: s_('TransferGroup|Group is already a root group.'),
same_parent_as_current: s_('TransferGroup|Group is already associated to the parent group.'),
invalid_policies: s_("TransferGroup|You don't have enough permissions.")
}.freeze
TransferError = Class.new(StandardError)
......@@ -26,7 +26,7 @@ module Groups
rescue TransferError, ActiveRecord::RecordInvalid, Gitlab::UpdatePathError => e
@group.errors.clear
@error = "Transfer failed: " + e.message
@error = s_("TransferGroup|Transfer failed: %{error_message}") % { error_message: e.message }
false
end
......
......@@ -7,7 +7,7 @@ module Import
def execute(access_params, provider)
unless authorized?
return error('This namespace has already been taken! Please choose another one.', :unprocessable_entity)
return error(_('This namespace has already been taken! Please choose another one.'), :unprocessable_entity)
end
project = Gitlab::LegacyGithubImport::ProjectCreator
......
......@@ -8,11 +8,11 @@ module Issues
@target_project = target_project
unless issue.can_move?(current_user, @target_project)
raise MoveError, 'Cannot move issue due to insufficient permissions!'
raise MoveError, s_('MoveIssue|Cannot move issue due to insufficient permissions!')
end
if @project == @target_project
raise MoveError, 'Cannot move issue to project it originates from!'
raise MoveError, s_('MoveIssue|Cannot move issue to project it originates from!')
end
super
......
......@@ -5,11 +5,11 @@ module Members
DEFAULT_LIMIT = 100
def execute(source)
return error('No users specified.') if params[:user_ids].blank?
return error(s_('AddMember|No users specified.')) if params[:user_ids].blank?
user_ids = params[:user_ids].split(',').uniq
return error("Too many users specified (limit is #{user_limit})") if
return error(s_("AddMember|Too many users specified (limit is %{user_limit})") % { user_limit: user_limit }) if
user_limit && user_ids.size > user_limit
members = source.add_users(
......
......@@ -10,10 +10,10 @@ module MergeRequests
end
if merge_request.squash_in_progress?
return error('Squash task canceled: another squash is already in progress.')
return error(s_('MergeRequests|Squash task canceled: another squash is already in progress.'))
end
squash! || error('Failed to squash. Should be done manually.')
squash! || error(s_('MergeRequests|Failed to squash. Should be done manually.'))
end
private
......
......@@ -43,7 +43,7 @@ module Milestones
end
def check_project_milestone!(milestone)
raise_error('Only project milestones can be promoted.') unless milestone.project_milestone?
raise_error(s_('PromoteMilestone|Only project milestones can be promoted.')) unless milestone.project_milestone?
end
def clone_project_milestone(milestone)
......@@ -71,7 +71,7 @@ module Milestones
# rubocop: enable CodeReuse/ActiveRecord
def group
@group ||= parent.group || raise_error('Project does not belong to a group.')
@group ||= parent.group || raise_error(s_('PromoteMilestone|Project does not belong to a group.'))
end
# rubocop: disable CodeReuse/ActiveRecord
......@@ -85,7 +85,7 @@ module Milestones
end
def raise_error(message)
raise PromoteMilestoneError, "Promotion failed - #{message}"
raise PromoteMilestoneError, s_("PromoteMilestone|Promotion failed - %{message}") % { message: message }
end
end
end
......
......@@ -61,11 +61,11 @@ module Projects
flush_caches(@project)
unless rollback_repository(removal_path(repo_path), repo_path)
raise_error('Failed to restore project repository. Please contact the administrator.')
raise_error(s_('DeleteProject|Failed to restore project repository. Please contact the administrator.'))
end
unless rollback_repository(removal_path(wiki_path), wiki_path)
raise_error('Failed to restore wiki repository. Please contact the administrator.')
raise_error(s_('DeleteProject|Failed to restore wiki repository. Please contact the administrator.'))
end
end
......@@ -81,11 +81,11 @@ module Projects
def trash_repositories!
unless remove_repository(repo_path)
raise_error('Failed to remove project repository. Please try again or contact administrator.')
raise_error(s_('DeleteProject|Failed to remove project repository. Please try again or contact administrator.'))
end
unless remove_repository(wiki_path)
raise_error('Failed to remove wiki repository. Please try again or contact administrator.')
raise_error(s_('DeleteProject|Failed to remove wiki repository. Please try again or contact administrator.'))
end
end
......@@ -148,7 +148,7 @@ module Projects
def attempt_destroy_transaction(project)
unless remove_registry_tags
raise_error('Failed to remove some tags in project container registry. Please try again or contact administrator.')
raise_error(s_('DeleteProject|Failed to remove some tags in project container registry. Please try again or contact administrator.'))
end
project.leave_pool_repository
......
......@@ -27,13 +27,13 @@ module Projects
rescue Gitlab::UrlBlocker::BlockedUrlError => e
Gitlab::Sentry.track_acceptable_exception(e, extra: { project_path: project.full_path, importer: project.import_type })
error("Error importing repository #{project.safe_import_url} into #{project.full_path} - #{e.message}")
error(s_("ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}") % { project_safe_import_url: project.safe_import_url, project_full_path: project.full_path, message: e.message })
rescue => e
message = Projects::ImportErrorFilter.filter_message(e.message)
Gitlab::Sentry.track_acceptable_exception(e, extra: { project_path: project.full_path, importer: project.import_type })
error("Error importing repository #{project.safe_import_url} into #{project.full_path} - #{message}")
error(s_("ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}") % { project_safe_import_url: project.safe_import_url, project_full_path: project.full_path, message: message })
end
private
......@@ -43,7 +43,7 @@ module Projects
begin
Gitlab::UrlBlocker.validate!(project.import_url, ports: Project::VALID_IMPORT_PORTS)
rescue Gitlab::UrlBlocker::BlockedUrlError => e
raise e, "Blocked import URL: #{e.message}"
raise e, s_("ImportProjects|Blocked import URL: %{message}") % { message: e.message }
end
end
......@@ -61,7 +61,7 @@ module Projects
def create_repository
unless project.create_repository
raise Error, 'The repository could not be created.'
raise Error, s_('ImportProjects|The repository could not be created.')
end
end
......@@ -112,7 +112,7 @@ module Projects
project.repository.expire_content_cache unless project.gitlab_project_import?
unless importer.execute
raise Error, 'The remote data could not be imported.'
raise Error, s_('ImportProjects|The remote data could not be imported.')
end
end
......
......@@ -17,11 +17,11 @@ module Projects
@new_namespace = new_namespace
if @new_namespace.blank?
raise TransferError, 'Please select a new namespace for your project.'
raise TransferError, s_('TransferProject|Please select a new namespace for your project.')
end
unless allowed_transfer?(current_user, project)
raise TransferError, 'Transfer failed, please contact an admin.'
raise TransferError, s_('TransferProject|Transfer failed, please contact an admin.')
end
transfer(project)
......@@ -45,12 +45,12 @@ module Projects
@old_namespace = project.namespace
if Project.where(namespace_id: @new_namespace.try(:id)).where('path = ? or name = ?', project.path, project.name).exists?
raise TransferError.new("Project with same name or path in target namespace already exists")
raise TransferError.new(s_("TransferProject|Project with same name or path in target namespace already exists"))
end
if project.has_container_registry_tags?
# We currently don't support renaming repository if it contains tags in container registry
raise TransferError.new('Project cannot be transferred, because tags are present in its container registry')
raise TransferError.new(s_('TransferProject|Project cannot be transferred, because tags are present in its container registry'))
end
attempt_transfer_transaction
......@@ -145,7 +145,7 @@ module Projects
# Move main repository
unless move_repo_folder(@old_path, @new_path)
raise TransferError.new("Cannot move project")
raise TransferError.new(s_("TransferProject|Cannot move project"))
end
# Disk path is changed; we need to ensure we reload it
......
......@@ -42,15 +42,15 @@ module Projects
def validate!
unless valid_visibility_level_change?(project, params[:visibility_level])
raise ValidationError.new('New visibility level not allowed!')
raise ValidationError.new(s_('UpdateProject|New visibility level not allowed!'))
end
if renaming_project_with_container_registry_tags?
raise ValidationError.new('Cannot rename project because it contains container registry tags!')
raise ValidationError.new(s_('UpdateProject|Cannot rename project because it contains container registry tags!'))
end
if changing_default_branch?
raise ValidationError.new("Could not set the default branch") unless project.change_head(params[:default_branch])
raise ValidationError.new(s_("UpdateProject|Could not set the default branch")) unless project.change_head(params[:default_branch])
end
end
......@@ -91,7 +91,7 @@ module Projects
def update_failed!
model_errors = project.errors.full_messages.to_sentence
error_message = model_errors.presence || 'Project could not be updated!'
error_message = model_errors.presence || s_('UpdateProject|Project could not be updated!')
error(error_message)
end
......
......@@ -11,7 +11,7 @@ module TestHooks
private
def push_events_data
throw(:validation_error, 'Ensure the project has at least one commit.') if project.empty_repo?
throw(:validation_error, s_('TestHooks|Ensure the project has at least one commit.')) if project.empty_repo?
Gitlab::DataBuilder::Push.build_sample(project, current_user)
end
......@@ -20,14 +20,14 @@ module TestHooks
def note_events_data
note = project.notes.first
throw(:validation_error, 'Ensure the project has notes.') unless note.present?
throw(:validation_error, s_('TestHooks|Ensure the project has notes.')) unless note.present?
Gitlab::DataBuilder::Note.build(note, current_user)
end
def issues_events_data
issue = project.issues.first
throw(:validation_error, 'Ensure the project has issues.') unless issue.present?
throw(:validation_error, s_('TestHooks|Ensure the project has issues.')) unless issue.present?
issue.to_hook_data(current_user)
end
......@@ -36,21 +36,21 @@ module TestHooks
def merge_requests_events_data
merge_request = project.merge_requests.first
throw(:validation_error, 'Ensure the project has merge requests.') unless merge_request.present?
throw(:validation_error, s_('TestHooks|Ensure the project has merge requests.')) unless merge_request.present?
merge_request.to_hook_data(current_user)
end
def job_events_data
build = project.builds.first
throw(:validation_error, 'Ensure the project has CI jobs.') unless build.present?
throw(:validation_error, s_('TestHooks|Ensure the project has CI jobs.')) unless build.present?
Gitlab::DataBuilder::Build.build(build)
end
def pipeline_events_data
pipeline = project.ci_pipelines.first
throw(:validation_error, 'Ensure the project has CI pipelines.') unless pipeline.present?
throw(:validation_error, s_('TestHooks|Ensure the project has CI pipelines.')) unless pipeline.present?
Gitlab::DataBuilder::Pipeline.build(pipeline)
end
......@@ -58,7 +58,7 @@ module TestHooks
def wiki_page_events_data
page = project.wiki.pages.first
if !project.wiki_enabled? || page.blank?
throw(:validation_error, 'Ensure the wiki is enabled and has pages.')
throw(:validation_error, s_('TestHooks|Ensure the wiki is enabled and has pages.'))
end
Gitlab::DataBuilder::WikiPage.build(page, current_user, 'create')
......
......@@ -18,7 +18,7 @@ module TestHooks
def merge_requests_events_data
merge_request = MergeRequest.of_projects(current_user.projects.select(:id)).first
throw(:validation_error, 'Ensure one of your projects has merge requests.') unless merge_request.present?
throw(:validation_error, s_('TestHooks|Ensure one of your projects has merge requests.')) unless merge_request.present?
merge_request.to_hook_data(current_user)
end
......
......@@ -318,12 +318,12 @@ msgstr[0] ""
msgstr[1] ""
msgid "1 closed issue"
msgid_plural "%d closed issues"
msgid_plural "%{issues} closed issues"
msgstr[0] ""
msgstr[1] ""
msgid "1 closed merge request"
msgid_plural "%d closed merge requests"
msgid_plural "%{merge_requests} closed merge requests"
msgstr[0] ""
msgstr[1] ""
......@@ -336,17 +336,17 @@ msgstr[0] ""
msgstr[1] ""
msgid "1 merged merge request"
msgid_plural "%d merged merge requests"
msgid_plural "%{merge_requests} merged merge requests"
msgstr[0] ""
msgstr[1] ""
msgid "1 open issue"
msgid_plural "%d open issues"
msgid_plural "%{issues} open issues"
msgstr[0] ""
msgstr[1] ""
msgid "1 open merge request"
msgid_plural "%d open merge requests"
msgid_plural "%{merge_requests} open merge requests"
msgstr[0] ""
msgstr[1] ""
......@@ -659,6 +659,12 @@ msgstr ""
msgid "Add users to group"
msgstr ""
msgid "AddMember|No users specified."
msgstr ""
msgid "AddMember|Too many users specified (limit is %{user_limit})"
msgstr ""
msgid "Added at"
msgstr ""
......@@ -3344,6 +3350,12 @@ msgstr ""
msgid "Create your first page"
msgstr ""
msgid "CreateGroup|You don’t have permission to create a subgroup in this group."
msgstr ""
msgid "CreateGroup|You don’t have permission to create groups."
msgstr ""
msgid "CreateTag|Tag"
msgstr ""
......@@ -3557,6 +3569,21 @@ msgstr ""
msgid "Delete this attachment"
msgstr ""
msgid "DeleteProject|Failed to remove project repository. Please try again or contact administrator."
msgstr ""
msgid "DeleteProject|Failed to remove some tags in project container registry. Please try again or contact administrator."
msgstr ""
msgid "DeleteProject|Failed to remove wiki repository. Please try again or contact administrator."
msgstr ""
msgid "DeleteProject|Failed to restore project repository. Please contact the administrator."
msgstr ""
msgid "DeleteProject|Failed to restore wiki repository. Please contact the administrator."
msgstr ""
msgid "Deleted"
msgstr ""
......@@ -6146,6 +6173,12 @@ msgstr ""
msgid "ImportButtons|Connect repositories from"
msgstr ""
msgid "ImportProjects|Blocked import URL: %{message}"
msgstr ""
msgid "ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}"
msgstr ""
msgid "ImportProjects|Importing the project failed"
msgstr ""
......@@ -6155,6 +6188,12 @@ msgstr ""
msgid "ImportProjects|Select the projects you want to import"
msgstr ""
msgid "ImportProjects|The remote data could not be imported."
msgstr ""
msgid "ImportProjects|The repository could not be created."
msgstr ""
msgid "ImportProjects|Updating the imported projects failed"
msgstr ""
......@@ -7160,6 +7199,9 @@ msgstr ""
msgid "MergeRequests|Discussion will be unresolved"
msgstr ""
msgid "MergeRequests|Failed to squash. Should be done manually."
msgstr ""
msgid "MergeRequests|Jump to next unresolved discussion"
msgstr ""
......@@ -7172,6 +7214,9 @@ msgstr ""
msgid "MergeRequests|Saving the comment failed"
msgstr ""
msgid "MergeRequests|Squash task canceled: another squash is already in progress."
msgstr ""
msgid "MergeRequests|Toggle comments for this file"
msgstr ""
......@@ -7472,6 +7517,12 @@ msgstr ""
msgid "Move issue"
msgstr ""
msgid "MoveIssue|Cannot move issue due to insufficient permissions!"
msgstr ""
msgid "MoveIssue|Cannot move issue to project it originates from!"
msgstr ""
msgid "Multiple issue boards"
msgstr ""
......@@ -9141,6 +9192,15 @@ msgstr ""
msgid "Promote to group label"
msgstr ""
msgid "PromoteMilestone|Only project milestones can be promoted."
msgstr ""
msgid "PromoteMilestone|Project does not belong to a group."
msgstr ""
msgid "PromoteMilestone|Promotion failed - %{message}"
msgstr ""
msgid "Promotions|Don't show me this again"
msgstr ""
......@@ -11176,6 +11236,30 @@ msgstr ""
msgid "Test failed."
msgstr ""
msgid "TestHooks|Ensure one of your projects has merge requests."
msgstr ""
msgid "TestHooks|Ensure the project has CI jobs."
msgstr ""
msgid "TestHooks|Ensure the project has CI pipelines."
msgstr ""
msgid "TestHooks|Ensure the project has at least one commit."
msgstr ""
msgid "TestHooks|Ensure the project has issues."
msgstr ""
msgid "TestHooks|Ensure the project has merge requests."
msgstr ""
msgid "TestHooks|Ensure the project has notes."
msgstr ""
msgid "TestHooks|Ensure the wiki is enabled and has pages."
msgstr ""
msgid "Thank you for your report. A GitLab administrator will look into it shortly."
msgstr ""
......@@ -12133,6 +12217,39 @@ msgstr ""
msgid "Transfer project"
msgstr ""
msgid "TransferGroup|Database is not supported."
msgstr ""
msgid "TransferGroup|Group is already a root group."
msgstr ""
msgid "TransferGroup|Group is already associated to the parent group."
msgstr ""
msgid "TransferGroup|The parent group already has a subgroup with the same path."
msgstr ""
msgid "TransferGroup|Transfer failed: %{error_message}"
msgstr ""
msgid "TransferGroup|You don't have enough permissions."
msgstr ""
msgid "TransferProject|Cannot move project"
msgstr ""
msgid "TransferProject|Please select a new namespace for your project."
msgstr ""
msgid "TransferProject|Project cannot be transferred, because tags are present in its container registry"
msgstr ""
msgid "TransferProject|Project with same name or path in target namespace already exists"
msgstr ""
msgid "TransferProject|Transfer failed, please contact an admin."
msgstr ""
msgid "Tree view"
msgstr ""
......@@ -12325,6 +12442,18 @@ msgstr ""
msgid "Update your project name, topics, description and avatar."
msgstr ""
msgid "UpdateProject|Cannot rename project because it contains container registry tags!"
msgstr ""
msgid "UpdateProject|Could not set the default branch"
msgstr ""
msgid "UpdateProject|New visibility level not allowed!"
msgstr ""
msgid "UpdateProject|Project could not be updated!"
msgstr ""
msgid "Updated"
msgstr ""
......@@ -13023,6 +13152,9 @@ msgstr ""
msgid "You are an admin, which means granting access to <strong>%{client_name}</strong> will allow them to interact with GitLab as an admin as well. Proceed with caution."
msgstr ""
msgid "You are attempting to delete a file that has been previously updated."
msgstr ""
msgid "You are going to remove %{group_name}. Removed groups CANNOT be restored! Are you ABSOLUTELY sure?"
msgstr ""
......@@ -13773,6 +13905,12 @@ msgstr ""
msgid "estimateCommand|%{slash_command} will update the estimated time with the latest command."
msgstr ""
msgid "expired on %{milestone_due_date}"
msgstr ""
msgid "expires on %{milestone_due_date}"
msgstr ""
msgid "failed"
msgstr ""
......@@ -13829,6 +13967,9 @@ msgid_plural "instances completed"
msgstr[0] ""
msgstr[1] ""
msgid "invalid milestone state `%{state}`"
msgstr ""
msgid "is invalid because there is downstream lock"
msgstr ""
......@@ -14292,6 +14433,12 @@ msgstr ""
msgid "started"
msgstr ""
msgid "started on %{milestone_start_date}"
msgstr ""
msgid "starts on %{milestone_start_date}"
msgstr ""
msgid "stuck"
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