Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4b2a6a0

Browse filesBrowse files
committed
Merge pull request vuejs#8 from jaden/feature/plural
Adjusting pluralization of comments and time.
2 parents aab40f5 + e3d6f7e commit 4b2a6a0
Copy full SHA for 4b2a6a0

File tree

Expand file treeCollapse file tree

2 files changed

+12
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-4
lines changed

‎src/components/Item.vue

Copy file name to clipboardExpand all lines: src/components/Item.vue
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</span>
1515
{{item.time | fromNow}} ago
1616
<span class="comments-link" v-show="showInfo">
17-
| <a :href="'#/item/' + item.id">{{item.descendants}} comments</a>
17+
| <a :href="'#/item/' + item.id">{{item.descendants}} {{item.descendants | pluralize 'comment'}}</a>
1818
</span>
1919
</p>
2020
</div>

‎src/filters/index.js

Copy file name to clipboardExpand all lines: src/filters/index.js
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ export function domain (url) {
88
export function fromNow (time) {
99
const between = Date.now() / 1000 - Number(time)
1010
if (between < 3600) {
11-
return ~~(between / 60) + ' minutes'
11+
return pluralize(~~(between / 60), ' minute')
1212
} else if (between < 86400) {
13-
return ~~(between / 3600) + ' hours'
13+
return pluralize(~~(between / 3600), ' hour')
1414
} else {
15-
return ~~(between / 86400) + ' days'
15+
return pluralize(~~(between / 86400), ' day')
1616
}
1717
}
18+
19+
function pluralize(time, label) {
20+
if (time === 1) {
21+
return time + label
22+
}
23+
24+
return time + label + 's';
25+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.