From 4250245fe4dedb3da2fec4a183e658c19348c2f9 Mon Sep 17 00:00:00 2001 From: Ezekiel Kigbo Date: Thu, 18 Jul 2019 19:12:49 +1000 Subject: Minor refactor pluralizations Use the '%d' variable within content pluralized using n__ instead of relying on template literals --- app/assets/javascripts/commits.js | 3 ++- .../diffs/components/diff_gutter_avatars.vue | 6 +----- .../javascripts/lib/utils/datetime_utility.js | 16 ++++---------- locale/gitlab.pot | 25 +++++++++------------- 4 files changed, 17 insertions(+), 33 deletions(-) diff --git a/app/assets/javascripts/commits.js b/app/assets/javascripts/commits.js index 014dd685038..7dd75d03ab9 100644 --- a/app/assets/javascripts/commits.js +++ b/app/assets/javascripts/commits.js @@ -90,9 +90,10 @@ export default class CommitsList { .first() .find('li.commit').length, ); + $commitsHeadersLast .find('span.commits-count') - .text(`${commitsCount} ${n__('commit', 'commits', commitsCount)}`); + .text(n__('%d commit', '%d commits', commitsCount)); } localTimeAgo($processedData.find('.js-timeago')); diff --git a/app/assets/javascripts/diffs/components/diff_gutter_avatars.vue b/app/assets/javascripts/diffs/components/diff_gutter_avatars.vue index b0b6cecf8fc..7ede7a4f430 100644 --- a/app/assets/javascripts/diffs/components/diff_gutter_avatars.vue +++ b/app/assets/javascripts/diffs/components/diff_gutter_avatars.vue @@ -43,11 +43,7 @@ export default { return ''; } - return n__( - `${this.moreCount} more comment`, - `${this.moreCount} more comments`, - this.moreCount, - ); + return n__('%d more comment', '%d more comments', this.moreCount); }, }, methods: { diff --git a/app/assets/javascripts/lib/utils/datetime_utility.js b/app/assets/javascripts/lib/utils/datetime_utility.js index 779b7d9fc14..a4715789337 100644 --- a/app/assets/javascripts/lib/utils/datetime_utility.js +++ b/app/assets/javascripts/lib/utils/datetime_utility.js @@ -230,18 +230,10 @@ export const timeIntervalInWords = intervalInSeconds => { const secondsInteger = parseInt(intervalInSeconds, 10); const minutes = Math.floor(secondsInteger / 60); const seconds = secondsInteger - minutes * 60; - let text = ''; - - if (minutes >= 1) { - text = `${minutes} ${n__('minute', 'minutes', minutes)} ${seconds} ${n__( - 'second', - 'seconds', - seconds, - )}`; - } else { - text = `${seconds} ${n__('second', 'seconds', seconds)}`; - } - return text; + const secondsText = n__('%d second', '%d seconds', seconds); + return minutes >= 1 + ? [n__('%d minute', '%d minutes', minutes), secondsText].join(' ') + : secondsText; }; export const dateInWords = (date, abbreviated = false, hideYear = false) => { diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 8039a027661..c9937a39dd7 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -95,11 +95,21 @@ msgid_plural "%d metrics" msgstr[0] "" msgstr[1] "" +msgid "%d minute" +msgid_plural "%d minutes" +msgstr[0] "" +msgstr[1] "" + msgid "%d more comment" msgid_plural "%d more comments" msgstr[0] "" msgstr[1] "" +msgid "%d second" +msgid_plural "%d seconds" +msgstr[0] "" +msgstr[1] "" + msgid "%d staged change" msgid_plural "%d staged changes" msgstr[0] "" @@ -12753,11 +12763,6 @@ msgstr "" msgid "commented on %{link_to_project}" msgstr "" -msgid "commit" -msgid_plural "commits" -msgstr[0] "" -msgstr[1] "" - msgid "commit %{commit_id}" msgstr "" @@ -12933,11 +12938,6 @@ msgstr[1] "" msgid "milestone should belong either to a project or a group." msgstr "" -msgid "minute" -msgid_plural "minutes" -msgstr[0] "" -msgstr[1] "" - msgid "missing" msgstr "" @@ -13262,11 +13262,6 @@ msgstr[1] "" msgid "score" msgstr "" -msgid "second" -msgid_plural "seconds" -msgstr[0] "" -msgstr[1] "" - msgid "should be greater than or equal to %{access} inherited membership from group %{group_name}" msgstr "" -- cgit v1.2.3