Skip to content

Commit ef20706

Browse files
author
Akshay
committed
Fixed plural words.
1 parent a92efe1 commit ef20706

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/github.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ var GitHub = (function () {
113113
PublicEvent: '<span> open sourced <%= repoLink%> </span>',
114114
PullRequestEvent: '<span> <%= payload.action%> pull request <%= mergeRequestUrl%> </span>'+
115115
'<p><%= payload.pull_request.title%></p>'+
116-
'<p class="pull-req-info"><%= payload.pull_request.commits%> commits with <%= payload.pull_request.changed_files%> files changed.</p>',
116+
'<p class="pull-req-info"><%= payload.pull_request.commits%><%if(payload.pull_request.commits > 1){%> commits <%}else{%> commit <%}%> '+
117+
'with <%= payload.pull_request.changed_files%> <%if(payload.pull_request.commits > 1){%> files <%}else{%> file <%}%> changed.</p>',
117118
PullRequestReviewCommentEvent: '<span> commented on pull request <%= pullCommentUrl%> </span>'+
118119
'<p><%= payload.comment.body%></p>',
119120
PushEvent: '<span> pushed to <%= branchLink%> at <%= repoLink%> </span>'+
@@ -250,7 +251,7 @@ var GitHub = (function () {
250251
if (length === 2) {
251252
compareLink = gitMethods.getGitHubLink(activity.repo.name + '/compare/' + shaDiff, 'View comparison for these 2 commits &raquo;','gt-compare-link');
252253
} else if (length > 2) {
253-
compareLink = gitMethods.getGitHubLink(activity.repo.name + '/compare/' + shaDiff, (length-2)+' more commits &raquo;','gt-compare-link');
254+
compareLink = gitMethods.getGitHubLink(activity.repo.name + '/compare/' + shaDiff, (length-2)+' more ' + gitMethods.getPluralWord(length-2,'commit') + ' &raquo;','gt-compare-link');
254255
}
255256

256257
html += '</ul>'
@@ -264,7 +265,7 @@ var GitHub = (function () {
264265
var content, data, request;
265266
request = new XMLHttpRequest();
266267
request.open('GET', url, false);
267-
268+
268269
request.onload = function(e) {
269270
if (request.status >= 200 && request.status < 400){
270271
data = JSON.parse(request.responseText);
@@ -299,6 +300,12 @@ var GitHub = (function () {
299300
return gitMethods.getLink('https://github.com/' + url, title, cssClass);
300301
},
301302

303+
getPluralWord: function (count, word) {
304+
// Only for plurals ending with 's'
305+
if (count !== 1) return word + 's';
306+
return word;
307+
},
308+
302309
millisecondsToStr: function(milliseconds) {
303310

304311
function numberEnding(number) {

0 commit comments

Comments
 (0)