From 46bce5fdcbda80cbd8c028a8e966de4152f848b5 Mon Sep 17 00:00:00 2001
From: Anton Kalmykov <anton.kalmykov@proton.me>
Date: Tue, 27 Feb 2024 20:47:09 +0000
Subject: [PATCH] Use pluralized string for Job/Jobs count label on
 jobs/pipelines page

Update gitlab.pot file

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/433295

Changelog: changed
---
 .../header/pipeline_details_header.vue                 |  8 +++++---
 locale/gitlab.pot                                      |  6 ++++--
 spec/features/projects/pipelines/pipeline_spec.rb      | 10 +++++-----
 .../header/pipeline_details_header_spec.js             |  2 +-
 4 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/app/assets/javascripts/ci/pipeline_details/header/pipeline_details_header.vue b/app/assets/javascripts/ci/pipeline_details/header/pipeline_details_header.vue
index 1ecc4b2e1c14a..6d305567937df 100644
--- a/app/assets/javascripts/ci/pipeline_details/header/pipeline_details_header.vue
+++ b/app/assets/javascripts/ci/pipeline_details/header/pipeline_details_header.vue
@@ -14,7 +14,7 @@ import {
 import { BUTTON_TOOLTIP_RETRY, BUTTON_TOOLTIP_CANCEL } from '~/ci/constants';
 import { timeIntervalInWords } from '~/lib/utils/datetime_utility';
 import { setUrlFragment, redirectTo } from '~/lib/utils/url_utility'; // eslint-disable-line import/no-deprecated
-import { __, s__, sprintf, formatNumber } from '~/locale';
+import { __, n__, s__, sprintf, formatNumber } from '~/locale';
 import { getIdFromGraphQLId } from '~/graphql_shared/utils';
 import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
 import CiIcon from '~/vue_shared/components/ci_icon/ci_icon.vue';
@@ -249,8 +249,10 @@ export default {
       return this.pipeline?.commit?.title || '';
     },
     totalJobsText() {
-      return sprintf(__('%{jobs} Jobs'), {
-        jobs: this.pipeline?.totalJobs || 0,
+      const totalJobs = this.pipeline?.totalJobs || 0;
+
+      return sprintf(n__('%{jobs} job', '%{jobs} jobs', totalJobs), {
+        jobs: totalJobs,
       });
     },
     triggeredText() {
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 9140de1a97bc9..6f5d113c385b0 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -812,8 +812,10 @@ msgstr ""
 msgid "%{jobName} job is being retried"
 msgstr ""
 
-msgid "%{jobs} Jobs"
-msgstr ""
+msgid "%{jobs} job"
+msgid_plural "%{jobs} jobs"
+msgstr[0] ""
+msgstr[1] ""
 
 msgid "%{key} is not a valid URL."
 msgstr ""
diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb
index 4e41fff733d34..ec7777e958f84 100644
--- a/spec/features/projects/pipelines/pipeline_spec.rb
+++ b/spec/features/projects/pipelines/pipeline_spec.rb
@@ -91,7 +91,7 @@
 
       within_testid 'pipeline-details-header' do
         expect(page).to have_content("For #{pipeline.ref}")
-        expect(page).to have_content("#{pipeline.statuses.count} Jobs")
+        expect(page).to have_content("#{pipeline.statuses.count} jobs")
         expect(page).to have_link(pipeline.ref,
           href: project_commits_path(pipeline.project, pipeline.ref))
       end
@@ -666,7 +666,7 @@
         visit_pipeline
 
         within_testid 'pipeline-details-header' do
-          expect(page).to have_content("#{pipeline.statuses.count} Jobs")
+          expect(page).to have_content("#{pipeline.statuses.count} jobs")
           expect(page).to have_content("Related merge request !#{merge_request.iid} " \
                                        "to merge #{merge_request.source_branch}")
           expect(page).to have_link("!#{merge_request.iid}",
@@ -700,7 +700,7 @@
 
         it 'shows the pipeline information', :sidekiq_might_not_need_inline do
           within_testid 'pipeline-details-header' do
-            expect(page).to have_content("#{pipeline.statuses.count} Jobs")
+            expect(page).to have_content("#{pipeline.statuses.count} jobs")
             expect(page).to have_content("Related merge request !#{merge_request.iid} " \
                                          "to merge #{merge_request.source_branch}")
             expect(page).to have_link("!#{merge_request.iid}",
@@ -737,7 +737,7 @@
         visit_pipeline
 
         within_testid 'pipeline-details-header' do
-          expect(page).to have_content("#{pipeline.statuses.count} Jobs")
+          expect(page).to have_content("#{pipeline.statuses.count} jobs")
           expect(page).to have_content("Related merge request !#{merge_request.iid} " \
                                        "to merge #{merge_request.source_branch} " \
                                        "into #{merge_request.target_branch}")
@@ -774,7 +774,7 @@
 
         it 'shows the pipeline information', :sidekiq_might_not_need_inline do
           within_testid 'pipeline-details-header' do
-            expect(page).to have_content("#{pipeline.statuses.count} Jobs")
+            expect(page).to have_content("#{pipeline.statuses.count} jobs")
             expect(page).to have_content("Related merge request !#{merge_request.iid} " \
                                        "to merge #{merge_request.source_branch} " \
                                        "into #{merge_request.target_branch}")
diff --git a/spec/frontend/ci/pipeline_details/header/pipeline_details_header_spec.js b/spec/frontend/ci/pipeline_details/header/pipeline_details_header_spec.js
index 86b8c416a07b7..eeace44dd0174 100644
--- a/spec/frontend/ci/pipeline_details/header/pipeline_details_header_spec.js
+++ b/spec/frontend/ci/pipeline_details/header/pipeline_details_header_spec.js
@@ -147,7 +147,7 @@ describe('Pipeline details header', () => {
     });
 
     it('displays total jobs', () => {
-      expect(findTotalJobs().text()).toBe('3 Jobs');
+      expect(findTotalJobs().text()).toBe('3 jobs');
     });
 
     it('has link to commit', () => {
-- 
GitLab