UX: pluralize "likes/read this"

When expending the number of likes/reads, the text wasn't handling
proper pluralization that might be useful in locales that requires it.
This commit is contained in:
Régis Hanol 2019-12-13 22:18:28 +01:00
parent bc97d39688
commit 1309262569
3 changed files with 26 additions and 14 deletions

View File

@ -578,29 +578,36 @@ export default createWidget("post-menu", {
if (state.readers.length) {
const remaining = state.totalReaders - state.readers.length;
const description = remaining > 0
? "post.actions.people.read_capped"
: "post.actions.people.read";
const count = remaining > 0 ? remaining : state.totalReaders;
contents.push(
this.attach("small-user-list", {
users: state.readers,
addSelf: false,
listClassName: "who-read",
description: "post.actions.people.read",
count: remaining
description,
count
})
);
}
if (state.likedUsers.length) {
const remaining = state.total - state.likedUsers.length;
const description = remaining > 0
? "post.actions.people.like_capped"
: "post.actions.people.like";
const count = remaining > 0 ? remaining : state.total;
contents.push(
this.attach("small-user-list", {
users: state.likedUsers,
addSelf: attrs.liked && remaining === 0,
listClassName: "who-liked",
description:
remaining > 0
? "post.actions.people.like_capped"
: "post.actions.people.like",
count: remaining
description,
count
})
);
}

View File

@ -18,13 +18,11 @@ class PostActionUsersController < ApplicationController
post_actions = post.post_actions.where(post_action_type_id: post_action_type_id)
.includes(:user)
.offset(page * page_size)
.order('post_actions.created_at asc')
.order('post_actions.created_at ASC')
.limit(page_size)
if !guardian.can_see_post_actors?(post.topic, post_action_type_id)
if !current_user
raise Discourse::InvalidAccess
end
raise Discourse::InvalidAccess unless current_user
post_actions = post_actions.where(user_id: current_user.id)
end

View File

@ -2563,11 +2563,18 @@ en:
notify_moderators: "notified moderators"
notify_user: "sent a message"
bookmark: "bookmarked this"
like: "liked this"
read: "read this"
like:
one: "liked this"
other: "liked this"
read:
one: "read this"
other: "read this"
like_capped:
one: "and {{count}} other liked this"
other: "and {{count}} others liked this"
read_capped:
one: "and {{count}} other read this"
other: "and {{count}} others read this"
by_you:
off_topic: "You flagged this as off-topic"
spam: "You flagged this as spam"
@ -2621,7 +2628,7 @@ en:
html_part:
title: "Show the html part of the email"
button: "HTML"
bookmarks:
create: "Create bookmark"
name: "Name"