diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-06-08 09:30:26 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-06-08 09:30:26 +0100 |
commit | 86614aff8b65519b7513c1f7d99ec868411ab02e (patch) | |
tree | f9f674306478783a2e9c3034b2a1ff48bf838743 /app/helpers | |
parent | c6d27eb8c18f50b13a740dfb7e1cb7f57fae22de (diff) | |
parent | acdd1bf7c92b7e9cdbd579df8faca5ea7783489f (diff) | |
download | gitlab-ce-33361-make-scroll-faster.tar.gz |
Merge branch 'master' into 33361-make-scroll-faster33361-make-scroll-faster
* master: (92 commits)
Responsive table fixes
remove the rouge copypasta and add notes to refactor
nil-check Repository::is_ancestor?
update rouge to 2.1.0
Added more negative checks for public project
Fix End Syntax Error
Enhancing Spec's with negative cases
Improve form spec
Update CHANGELOG.md for 9.0.10
Update CHANGELOG.md for 9.2.5
Fixed spec test syntax errors
Update CHANGELOG.md for 9.1.7
Translate project & repository pages
Converting Tests to Spec Tests
Added more actions and report as abuse to all notes
Add sticky confidential issue bar
Fix for Login Test Problem
Document not using STI
Added Cop to blacklist polymorphic associations
Document not using polymorphic associations
...
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/button_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/ci_status_helper.rb | 39 | ||||
-rw-r--r-- | app/helpers/notes_helper.rb | 8 | ||||
-rw-r--r-- | app/helpers/notifications_helper.rb | 39 | ||||
-rw-r--r-- | app/helpers/projects_helper.rb | 35 | ||||
-rw-r--r-- | app/helpers/visibility_level_helper.rb | 10 |
6 files changed, 87 insertions, 48 deletions
diff --git a/app/helpers/button_helper.rb b/app/helpers/button_helper.rb index 0081bbd92b3..00464810054 100644 --- a/app/helpers/button_helper.rb +++ b/app/helpers/button_helper.rb @@ -61,7 +61,7 @@ module ButtonHelper html: true, placement: placement, container: 'body', - title: "Set a password on your account<br>to pull or push via #{protocol}" + title: _("Set a password on your account to pull or push via %{protocol}") % { protocol: protocol } } end @@ -76,7 +76,7 @@ module ButtonHelper html: true, placement: placement, container: 'body', - title: 'Add an SSH key to your profile<br>to pull or push via SSH.' + title: _('Add an SSH key to your profile to pull or push via SSH.') } end end diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb index 32b1e7822af..21c0eb8b54c 100644 --- a/app/helpers/ci_status_helper.rb +++ b/app/helpers/ci_status_helper.rb @@ -16,16 +16,18 @@ module CiStatusHelper return status.label end - case status - when 'success' - 'passed' - when 'success_with_warnings' - 'passed with warnings' - when 'manual' - 'waiting for manual action' - else - status - end + label = case status + when 'success' + 'passed' + when 'success_with_warnings' + 'passed with warnings' + when 'manual' + 'waiting for manual action' + else + status + end + translation = "CiStatusLabel|#{label}" + s_(translation) end def ci_text_for_status(status) @@ -35,13 +37,22 @@ module CiStatusHelper case status when 'success' - 'passed' + s_('CiStatusText|passed') when 'success_with_warnings' - 'passed' + s_('CiStatusText|passed') when 'manual' - 'blocked' + s_('CiStatusText|blocked') else - status + # All states are already being translated inside the detailed statuses: + # :running => Gitlab::Ci::Status::Running + # :skipped => Gitlab::Ci::Status::Skipped + # :failed => Gitlab::Ci::Status::Failed + # :success => Gitlab::Ci::Status::Success + # :canceled => Gitlab::Ci::Status::Canceled + # The following states are customized above: + # :manual => Gitlab::Ci::Status::Manual + status_translation = "CiStatusText|#{status}" + s_(status_translation) end end diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 3d4802290b5..c59d8dafc83 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -90,14 +90,18 @@ module NotesHelper end end - def note_url(note) + def note_url(note, project = @project) if note.noteable.is_a?(PersonalSnippet) snippet_note_path(note.noteable, note) else - namespace_project_note_path(@project.namespace, @project, note) + namespace_project_note_path(project.namespace, project, note) end end + def noteable_note_url(note) + Gitlab::UrlBuilder.build(note) + end + def form_resources if @snippet.is_a?(PersonalSnippet) [@note] diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 03cc8f2b6bd..fde961e2da4 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -21,30 +21,36 @@ module NotificationsHelper end def notification_title(level) + # Can be anything in `NotificationSetting.level: case level.to_sym when :participating - 'Participate' + s_('NotificationLevel|Participate') when :mention - 'On mention' + s_('NotificationLevel|On mention') else - level.to_s.titlecase + N_('NotificationLevel|Global') + N_('NotificationLevel|Watch') + N_('NotificationLevel|Disabled') + N_('NotificationLevel|Custom') + level = "NotificationLevel|#{level.to_s.humanize}" + s_(level) end end def notification_description(level) case level.to_sym when :participating - 'You will only receive notifications for threads you have participated in' + _('You will only receive notifications for threads you have participated in') when :mention - 'You will receive notifications only for comments in which you were @mentioned' + _('You will receive notifications only for comments in which you were @mentioned') when :watch - 'You will receive notifications for any activity' + _('You will receive notifications for any activity') when :disabled - 'You will not get any notifications via email' + _('You will not get any notifications via email') when :global - 'Use your global notification setting' + _('Use your global notification setting') when :custom - 'You will only receive notifications for the events you choose' + _('You will only receive notifications for the events you choose') end end @@ -76,11 +82,22 @@ module NotificationsHelper end def notification_event_name(event) + # All values from NotificationSetting::EMAIL_EVENTS case event when :success_pipeline - 'Successful pipeline' + s_('NotificationEvent|Successful pipeline') else - event.to_s.humanize + N_('NotificationEvent|New note') + N_('NotificationEvent|New issue') + N_('NotificationEvent|Reopen issue') + N_('NotificationEvent|Close issue') + N_('NotificationEvent|Reassign issue') + N_('NotificationEvent|New merge request') + N_('NotificationEvent|Close merge request') + N_('NotificationEvent|Reassign merge request') + N_('NotificationEvent|Merge merge request') + N_('NotificationEvent|Failed pipeline') + s_(event.to_s.humanize) end end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index f74e61c9481..7441b58fddb 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -70,15 +70,18 @@ module ProjectsHelper end def remove_project_message(project) - "You are going to remove #{project.name_with_namespace}.\n Removed project CANNOT be restored!\n Are you ABSOLUTELY sure?" + _("You are going to remove %{project_name_with_namespace}.\nRemoved project CANNOT be restored!\nAre you ABSOLUTELY sure?") % + { project_name_with_namespace: project.name_with_namespace } end def transfer_project_message(project) - "You are going to transfer #{project.name_with_namespace} to another owner. Are you ABSOLUTELY sure?" + _("You are going to transfer %{project_name_with_namespace} to another owner. Are you ABSOLUTELY sure?") % + { project_name_with_namespace: project.name_with_namespace } end def remove_fork_project_message(project) - "You are going to remove the fork relationship to source project #{@project.forked_from_project.name_with_namespace}. Are you ABSOLUTELY sure?" + _("You are going to remove the fork relationship to source project %{forked_from_project}. Are you ABSOLUTELY sure?") % + { forked_from_project: @project.forked_from_project.name_with_namespace } end def project_nav_tabs @@ -143,7 +146,7 @@ module ProjectsHelper end options = options_for_select( - options, + options.invert, selected: highest_available_option || @project.project_feature.public_send(field), disabled: disabled_option ) @@ -159,12 +162,13 @@ module ProjectsHelper end def link_to_autodeploy_doc - link_to 'About auto deploy', help_page_path('ci/autodeploy/index'), target: '_blank' + link_to _('About auto deploy'), help_page_path('ci/autodeploy/index'), target: '_blank' end def autodeploy_flash_notice(branch_name) - "Branch <strong>#{truncate(sanitize(branch_name))}</strong> was created. To set up auto deploy, \ - choose a GitLab CI Yaml template and commit your changes. #{link_to_autodeploy_doc}".html_safe + translation = _("Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, choose a GitLab CI Yaml template and commit your changes. %{link_to_autodeploy_doc}") % + { branch_name: truncate(sanitize(branch_name)), link_to_autodeploy_doc: link_to_autodeploy_doc } + translation.html_safe end def project_list_cache_key(project) @@ -250,11 +254,11 @@ module ProjectsHelper def project_lfs_status(project) if project.lfs_enabled? content_tag(:span, class: 'lfs-enabled') do - 'Enabled' + s_('LFSStatus|Enabled') end else content_tag(:span, class: 'lfs-disabled') do - 'Disabled' + s_('LFSStatus|Disabled') end end end @@ -263,7 +267,7 @@ module ProjectsHelper if current_user current_user.name else - "Your name" + _("Your name") end end @@ -300,17 +304,18 @@ module ProjectsHelper if project.last_activity_at time_ago_with_tooltip(project.last_activity_at, placement: 'bottom', html_class: 'last_activity_time_ago') else - "Never" + s_("ProjectLastActivity|Never") end end def add_special_file_path(project, file_name:, commit_message: nil, branch_name: nil, context: nil) + commit_message ||= s_("CommitMessage|Add %{file_name}") % { file_name: file_name.downcase } namespace_project_new_blob_path( project.namespace, project, project.default_branch || 'master', file_name: file_name, - commit_message: commit_message || "Add #{file_name.downcase}", + commit_message: commit_message, branch_name: branch_name, context: context ) @@ -447,9 +452,9 @@ module ProjectsHelper def project_feature_options { - 'Disabled' => ProjectFeature::DISABLED, - 'Only team members' => ProjectFeature::PRIVATE, - 'Everyone with access' => ProjectFeature::ENABLED + ProjectFeature::DISABLED => s_('ProjectFeature|Disabled'), + ProjectFeature::PRIVATE => s_('ProjectFeature|Only team members'), + ProjectFeature::ENABLED => s_('ProjectFeature|Everyone with access') } end diff --git a/app/helpers/visibility_level_helper.rb b/app/helpers/visibility_level_helper.rb index 50757b01538..35755bc149b 100644 --- a/app/helpers/visibility_level_helper.rb +++ b/app/helpers/visibility_level_helper.rb @@ -29,11 +29,11 @@ module VisibilityLevelHelper def project_visibility_level_description(level) case level when Gitlab::VisibilityLevel::PRIVATE - "Project access must be granted explicitly to each user." + _("Project access must be granted explicitly to each user.") when Gitlab::VisibilityLevel::INTERNAL - "The project can be accessed by any logged in user." + _("The project can be accessed by any logged in user.") when Gitlab::VisibilityLevel::PUBLIC - "The project can be accessed without any authentication." + _("The project can be accessed without any authentication.") end end @@ -81,7 +81,9 @@ module VisibilityLevelHelper end def visibility_level_label(level) - Project.visibility_levels.key(level) + # The visibility level can be: + # 'VisibilityLevel|Private', 'VisibilityLevel|Internal', 'VisibilityLevel|Public' + s_(Project.visibility_levels.key(level)) end def restricted_visibility_levels(show_all = false) |