Skip to content
Snippets Groups Projects
Commit 56606907 authored by Martin Wortschack's avatar Martin Wortschack Committed by Rémy Coutable
Browse files

Externalize strings in projects controllers

- concerns
- dashboard
- groups
- import
parent 98824f3e
No related branches found
No related tags found
No related merge requests found
Showing
with 87 additions and 63 deletions
Loading
Loading
@@ -36,7 +36,7 @@ module AuthenticatesWithTwoFactor
end
 
def locked_user_redirect(user)
flash.now[:alert] = 'Invalid Login or password'
flash.now[:alert] = _('Invalid Login or password')
render 'devise/sessions/new'
end
 
Loading
Loading
@@ -66,7 +66,7 @@ module AuthenticatesWithTwoFactor
else
user.increment_failed_attempts!
Gitlab::AppLogger.info("Failed Login: user=#{user.username} ip=#{request.remote_ip} method=OTP")
flash.now[:alert] = 'Invalid two-factor code.'
flash.now[:alert] = _('Invalid two-factor code.')
prompt_for_two_factor(user)
end
end
Loading
Loading
@@ -83,7 +83,7 @@ module AuthenticatesWithTwoFactor
else
user.increment_failed_attempts!
Gitlab::AppLogger.info("Failed Login: user=#{user.username} ip=#{request.remote_ip} method=U2F")
flash.now[:alert] = 'Authentication via U2F device failed.'
flash.now[:alert] = _('Authentication via U2F device failed.')
prompt_for_two_factor(user)
end
end
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@ module CreatesCommit
 
respond_to do |format|
format.html { redirect_to success_path }
format.json { render json: { message: "success", filePath: success_path } }
format.json { render json: { message: _("success"), filePath: success_path } }
end
else
flash[:alert] = result[:message]
Loading
Loading
@@ -45,7 +45,7 @@ module CreatesCommit
redirect_to failure_path
end
end
format.json { render json: { message: "failed", filePath: failure_path } }
format.json { render json: { message: _("failed"), filePath: failure_path } }
end
end
end
Loading
Loading
@@ -60,15 +60,22 @@ module CreatesCommit
private
 
def update_flash_notice(success_notice)
flash[:notice] = success_notice || "Your changes have been successfully committed."
flash[:notice] = success_notice || _("Your changes have been successfully committed.")
 
if create_merge_request?
if merge_request_exists?
flash[:notice] = nil
else
target = different_project? ? "project" : "branch"
flash[:notice] = flash[:notice] + " You can now submit a merge request to get this change into the original #{target}."
end
flash[:notice] =
if merge_request_exists?
nil
else
mr_message =
if different_project?
_("You can now submit a merge request to get this change into the original project.")
else
_("You can now submit a merge request to get this change into the original branch.")
end
flash[:notice] += " " + mr_message
end
end
end
 
Loading
Loading
Loading
Loading
@@ -26,7 +26,7 @@ module LfsRequest
 
render(
json: {
message: 'Git LFS is not enabled on this GitLab server, contact your admin.',
message: _('Git LFS is not enabled on this GitLab server, contact your admin.'),
documentation_url: help_url
},
status: :not_implemented
Loading
Loading
@@ -51,7 +51,7 @@ module LfsRequest
def render_lfs_forbidden
render(
json: {
message: 'Access forbidden. Check your access level.',
message: _('Access forbidden. Check your access level.'),
documentation_url: help_url
},
content_type: CONTENT_TYPE,
Loading
Loading
@@ -62,7 +62,7 @@ module LfsRequest
def render_lfs_not_found
render(
json: {
message: 'Not found.',
message: _('Not found.'),
documentation_url: help_url
},
content_type: CONTENT_TYPE,
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@ module MembershipActions
result = Members::CreateService.new(current_user, create_params).execute(membershipable)
 
if result[:status] == :success
redirect_to members_page_url, notice: 'Users were successfully added.'
redirect_to members_page_url, notice: _('Users were successfully added.')
else
redirect_to members_page_url, alert: result[:message]
end
Loading
Loading
@@ -35,9 +35,16 @@ module MembershipActions
 
respond_to do |format|
format.html do
source = source_type == 'group' ? 'group and any subresources' : source_type
message =
begin
case membershipable
when Namespace
_("User was successfully removed from group and any subresources.")
else
_("User was successfully removed from project.")
end
end
 
message = "User was successfully removed from #{source}."
redirect_to members_page_url, notice: message
end
 
Loading
Loading
@@ -49,7 +56,7 @@ module MembershipActions
membershipable.request_access(current_user)
 
redirect_to polymorphic_path(membershipable),
notice: 'Your request for access has been queued for review.'
notice: _('Your request for access has been queued for review.')
end
 
def approve_access_request
Loading
Loading
@@ -68,9 +75,9 @@ module MembershipActions
 
notice =
if member.request?
"Your access request to the #{source_type} has been withdrawn."
_("Your access request to the %{source_type} has been withdrawn.") % { source_type: source_type }
else
"You left the \"#{membershipable.human_name}\" #{source_type}."
_("You left the \"%{membershipable_human_name}\" %{source_type}.") % { membershipable_human_name: membershipable.human_name, source_type: source_type }
end
 
respond_to do |format|
Loading
Loading
@@ -90,9 +97,9 @@ module MembershipActions
if member.invite?
member.resend_invite
 
redirect_to members_page_url, notice: 'The invitation was successfully resent.'
redirect_to members_page_url, notice: _('The invitation was successfully resent.')
else
redirect_to members_page_url, alert: 'The invitation has already been accepted.'
redirect_to members_page_url, alert: _('The invitation has already been accepted.')
end
end
 
Loading
Loading
@@ -125,6 +132,16 @@ module MembershipActions
end
 
def source_type
@source_type ||= membershipable.class.to_s.humanize(capitalize: false)
@source_type ||=
begin
case membershipable
when Namespace
_("group")
when Project
_("project")
else
raise "Unknown membershipable type: #{membershipable}!"
end
end
end
end
Loading
Loading
@@ -12,9 +12,9 @@ module SpammableActions
 
def mark_as_spam
if SpamService.new(spammable).mark_as_spam!
redirect_to spammable_path, notice: "#{spammable.spammable_entity_type.titlecase} was submitted to Akismet successfully."
redirect_to spammable_path, notice: _("%{spammable_titlecase} was submitted to Akismet successfully.") % { spammable_titlecase: spammable.spammable_entity_type.titlecase }
else
redirect_to spammable_path, alert: 'Error with Akismet. Please check the logs for more info.'
redirect_to spammable_path, alert: _('Error with Akismet. Please check the logs for more info.')
end
end
 
Loading
Loading
@@ -33,7 +33,7 @@ module SpammableActions
ensure_spam_config_loaded!
 
if params[:recaptcha_verification]
flash[:alert] = 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
flash[:alert] = _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
end
 
respond_to do |format|
Loading
Loading
Loading
Loading
@@ -16,7 +16,7 @@ module UploadsActions
end
else
format.json do
render json: 'Invalid file.', status: :unprocessable_entity
render json: _('Invalid file.'), status: :unprocessable_entity
end
end
end
Loading
Loading
@@ -57,7 +57,7 @@ module UploadsActions
 
render json: authorized
rescue SocketError
render json: "Error uploading file", status: :internal_server_error
render json: _("Error uploading file"), status: :internal_server_error
end
 
private
Loading
Loading
Loading
Loading
@@ -21,7 +21,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
format.html do
redirect_to dashboard_todos_path,
status: 302,
notice: 'Todo was successfully marked as done.'
notice: _('Todo was successfully marked as done.')
end
format.js { head :ok }
format.json { render json: todos_counts }
Loading
Loading
@@ -32,7 +32,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
updated_ids = TodoService.new.mark_todos_as_done(@todos, current_user)
 
respond_to do |format|
format.html { redirect_to dashboard_todos_path, status: 302, notice: 'All todos were marked as done.' }
format.html { redirect_to dashboard_todos_path, status: 302, notice: _('All todos were marked as done.') }
format.js { head :ok }
format.json { render json: todos_counts.merge(updated_ids: updated_ids) }
end
Loading
Loading
Loading
Loading
@@ -16,7 +16,7 @@ class Groups::RunnersController < Groups::ApplicationController
 
def update
if Ci::UpdateRunnerService.new(@runner).update(runner_params)
redirect_to group_runner_path(@group, @runner), notice: 'Runner was successfully updated.'
redirect_to group_runner_path(@group, @runner), notice: _('Runner was successfully updated.')
else
render 'edit'
end
Loading
Loading
@@ -30,17 +30,17 @@ class Groups::RunnersController < Groups::ApplicationController
 
def resume
if Ci::UpdateRunnerService.new(@runner).update(active: true)
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: 'Runner was successfully updated.'
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: _('Runner was successfully updated.')
else
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: 'Runner was not updated.'
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: _('Runner was not updated.')
end
end
 
def pause
if Ci::UpdateRunnerService.new(@runner).update(active: false)
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: 'Runner was successfully updated.'
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: _('Runner was successfully updated.')
else
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: 'Runner was not updated.'
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: _('Runner was not updated.')
end
end
 
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ module Groups
def reset_registration_token
@group.reset_runners_token!
 
flash[:notice] = 'New runners registration token has been generated!'
flash[:notice] = _('GroupSettings|New runners registration token has been generated!')
redirect_to group_settings_ci_cd_path
end
 
Loading
Loading
Loading
Loading
@@ -62,7 +62,7 @@ class Import::BitbucketController < Import::BaseController
render json: { errors: project_save_error(project) }, status: :unprocessable_entity
end
else
render json: { errors: 'This namespace has already been taken! Please choose another one.' }, status: :unprocessable_entity
render json: { errors: _('This namespace has already been taken! Please choose another one.') }, status: :unprocessable_entity
end
end
 
Loading
Loading
Loading
Loading
@@ -25,7 +25,7 @@ class Import::BitbucketServerController < Import::BaseController
repo = bitbucket_client.repo(@project_key, @repo_slug)
 
unless repo
return render json: { errors: "Project #{@project_key}/#{@repo_slug} could not be found" }, status: :unprocessable_entity
return render json: { errors: _("Project %{project_repo} could not be found") % { project_repo: "#{@project_key}/#{@repo_slug}" } }, status: :unprocessable_entity
end
 
project_name = params[:new_name].presence || repo.name
Loading
Loading
@@ -41,10 +41,10 @@ class Import::BitbucketServerController < Import::BaseController
render json: { errors: project_save_error(project) }, status: :unprocessable_entity
end
else
render json: { errors: 'This namespace has already been taken! Please choose another one.' }, status: :unprocessable_entity
render json: { errors: _('This namespace has already been taken! Please choose another one.') }, status: :unprocessable_entity
end
rescue BitbucketServer::Connection::ConnectionError => e
render json: { errors: "Unable to connect to server: #{e}" }, status: :unprocessable_entity
rescue BitbucketServer::Connection::ConnectionError => error
render json: { errors: _("Unable to connect to server: %{error}") % { error: error } }, status: :unprocessable_entity
end
 
def configure
Loading
Loading
@@ -65,8 +65,8 @@ class Import::BitbucketServerController < Import::BaseController
already_added_projects_names = @already_added_projects.pluck(:import_source)
 
@repos.reject! { |repo| already_added_projects_names.include?(repo.browse_url) }
rescue BitbucketServer::Connection::ConnectionError => e
flash[:alert] = "Unable to connect to server: #{e}"
rescue BitbucketServer::Connection::ConnectionError => error
flash[:alert] = _("Unable to connect to server: %{error}") % { error: error }
clear_session_data
redirect_to new_import_bitbucket_server_path
end
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ class Import::FogbugzController < Import::BaseController
res = Gitlab::FogbugzImport::Client.new(import_params.symbolize_keys)
rescue
# If the URI is invalid various errors can occur
return redirect_to new_import_fogbugz_path, alert: 'Could not connect to FogBugz, check your URL'
return redirect_to new_import_fogbugz_path, alert: _('Could not connect to FogBugz, check your URL')
end
session[:fogbugz_token] = res.get_token
session[:fogbugz_uri] = params[:uri]
Loading
Loading
@@ -29,14 +29,14 @@ class Import::FogbugzController < Import::BaseController
user_map = params[:users]
 
unless user_map.is_a?(Hash) && user_map.all? { |k, v| !v[:name].blank? }
flash.now[:alert] = 'All users must have a name.'
flash.now[:alert] = _('All users must have a name.')
 
return render 'new_user_map'
end
 
session[:fogbugz_user_map] = user_map
 
flash[:notice] = 'The user map has been saved. Continue by selecting the projects you want to import.'
flash[:notice] = _('The user map has been saved. Continue by selecting the projects you want to import.')
 
redirect_to status_import_fogbugz_path
end
Loading
Loading
Loading
Loading
@@ -46,7 +46,7 @@ class Import::GiteaController < Import::GithubController
def provider_auth
if session[access_token_key].blank? || provider_url.blank?
redirect_to new_import_gitea_url,
alert: 'You need to specify both an Access Token and a Host URL.'
alert: _('You need to specify both an Access Token and a Host URL.')
end
end
 
Loading
Loading
Loading
Loading
@@ -42,7 +42,7 @@ class Import::GitlabController < Import::BaseController
render json: { errors: project_save_error(project) }, status: :unprocessable_entity
end
else
render json: { errors: 'This namespace has already been taken! Please choose another one.' }, status: :unprocessable_entity
render json: { errors: _('This namespace has already been taken! Please choose another one.') }, status: :unprocessable_entity
end
end
 
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ class Import::GitlabProjectsController < Import::BaseController
 
def create
unless file_is_valid?
return redirect_back_or_default(options: { alert: "You need to upload a GitLab project export archive (ending in .gz)." })
return redirect_back_or_default(options: { alert: _("You need to upload a GitLab project export archive (ending in .gz).") })
end
 
@project = ::Projects::GitlabProjectsImportService.new(current_user, project_params).execute
Loading
Loading
@@ -21,7 +21,7 @@ class Import::GitlabProjectsController < Import::BaseController
if @project.saved?
redirect_to(
project_path(@project),
notice: "Project '#{@project.name}' is being imported."
notice: _("Project '%{project_name}' is being imported.") % { project_name: @project.name }
)
else
redirect_back_or_default(options: { alert: "Project could not be imported: #{@project.errors.full_messages.join(', ')}" })
Loading
Loading
Loading
Loading
@@ -11,18 +11,18 @@ class Import::GoogleCodeController < Import::BaseController
dump_file = params[:dump_file]
 
unless dump_file.respond_to?(:read)
return redirect_back_or_default(options: { alert: "You need to upload a Google Takeout archive." })
return redirect_back_or_default(options: { alert: _("You need to upload a Google Takeout archive.") })
end
 
begin
dump = JSON.parse(dump_file.read)
rescue
return redirect_back_or_default(options: { alert: "The uploaded file is not a valid Google Takeout archive." })
return redirect_back_or_default(options: { alert: _("The uploaded file is not a valid Google Takeout archive.") })
end
 
client = Gitlab::GoogleCodeImport::Client.new(dump)
unless client.valid?
return redirect_back_or_default(options: { alert: "The uploaded file is not a valid Google Takeout archive." })
return redirect_back_or_default(options: { alert: _("The uploaded file is not a valid Google Takeout archive.") })
end
 
session[:google_code_dump] = dump
Loading
Loading
@@ -44,13 +44,13 @@ class Import::GoogleCodeController < Import::BaseController
begin
user_map = JSON.parse(user_map_json)
rescue
flash.now[:alert] = "The entered user map is not a valid JSON user map."
flash.now[:alert] = _("The entered user map is not a valid JSON user map.")
 
return render "new_user_map"
end
 
unless user_map.is_a?(Hash) && user_map.all? { |k, v| k.is_a?(String) && v.is_a?(String) }
flash.now[:alert] = "The entered user map is not a valid JSON user map."
flash.now[:alert] = _("The entered user map is not a valid JSON user map.")
 
return render "new_user_map"
end
Loading
Loading
@@ -62,7 +62,7 @@ class Import::GoogleCodeController < Import::BaseController
 
session[:google_code_user_map] = user_map
 
flash[:notice] = "The user map has been saved. Continue by selecting the projects you want to import."
flash[:notice] = _("The user map has been saved. Continue by selecting the projects you want to import.")
 
redirect_to status_import_google_code_path
end
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@ class Projects::BlobController < Projects::ApplicationController
end
 
def create
create_commit(Files::CreateService, success_notice: "The file has been successfully created.",
create_commit(Files::CreateService, success_notice: _("The file has been successfully created."),
success_path: -> { project_blob_path(@project, File.join(@branch_name, @file_path)) },
failure_view: :new,
failure_path: project_new_blob_path(@project, @ref))
Loading
Loading
@@ -81,7 +81,7 @@ class Projects::BlobController < Projects::ApplicationController
end
 
def destroy
create_commit(Files::DeleteService, success_notice: "The file has been successfully deleted.",
create_commit(Files::DeleteService, success_notice: _("The file has been successfully deleted."),
success_path: -> { after_delete_path },
failure_view: :show,
failure_path: project_blob_path(@project, @id))
Loading
Loading
Loading
Loading
@@ -115,7 +115,7 @@ class Projects::BranchesController < Projects::ApplicationController
DeleteMergedBranchesService.new(@project, current_user).async_execute
 
redirect_to project_branches_path(@project),
notice: 'Merged branches are being deleted. This can take some time depending on the number of branches. Please refresh the page to see changes.'
notice: _('Merged branches are being deleted. This can take some time depending on the number of branches. Please refresh the page to see changes.')
end
 
private
Loading
Loading
@@ -143,7 +143,7 @@ class Projects::BranchesController < Projects::ApplicationController
def redirect_for_legacy_index_sort_or_search
# Normalize a legacy URL with redirect
if request.format != :json && !params[:state].presence && [:sort, :search, :page].any? { |key| params[key].presence }
redirect_to project_branches_filtered_path(@project, state: 'all'), notice: 'Update your bookmarked URLs as filtered/sorted branches URL has been changed.'
redirect_to project_branches_filtered_path(@project, state: 'all'), notice: _('Update your bookmarked URLs as filtered/sorted branches URL has been changed.')
end
end
 
Loading
Loading
Loading
Loading
@@ -38,7 +38,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
 
def update
if deploy_key.update(update_params)
flash[:notice] = 'Deploy key was successfully updated.'
flash[:notice] = _('Deploy key was successfully updated.')
redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings')
else
render 'edit'
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ class Projects::GroupLinksController < Projects::ApplicationController
 
flash[:alert] = result[:message] if result[:http_status] == 409
else
flash[:alert] = 'Please select a group.'
flash[:alert] = _('Please select a group.')
end
 
redirect_to project_project_members_path(project)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment