Skip to content

Commit

Permalink
fix(replies): add translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasha Zakablukov authored and Sasha Zakablukov committed Apr 15, 2022
1 parent e65e88f commit 53d228c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
24 changes: 18 additions & 6 deletions components/views/chat/message/reply/Reply.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ export default Vue.extend({
*/
makeReplyText() {
const LIMIT = 2
const SEPARATOR = ' and '
const SEPARATOR = this.$t('conversation.replies_separator')
const replies = this.$props.message.replies
const baseReply = replies.length > 1 ? 'Replies from ' : 'Reply from '
const uniqueRepliers = [
...new Set(replies.map((reply: any) => reply.from)),
Expand All @@ -70,11 +69,24 @@ export default Vue.extend({
.map((replier) =>
getUsernameFromState(replier as string, this.$store.state),
)
.join(SEPARATOR)
.join(SEPARATOR as string)
return uniqueRepliers.length > LIMIT
? `${baseReply} ${names} and ${uniqueRepliers.length - LIMIT} more ...`
: `${baseReply} ${names}`
if (replies.length === 1) {
return this.$t('conversation.reply_single', {
name: names,
})
}
if (uniqueRepliers.length <= LIMIT) {
return this.$t('conversation.repliers_less_than_limit', {
names,
})
}
return this.$t('conversation.repliers_more_than_limit', {
names,
leftCount: uniqueRepliers.length - LIMIT,
})
},
},
mounted() {
Expand Down
4 changes: 4 additions & 0 deletions locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ export default {
reply_to: 'Reply to',
multimedia: 'Multimedia content',
collapse: 'Collapse',
replies_separator: ' and ',
reply_single: 'Reply from {name}',
repliers_less_than_limit: 'Replies from {names}',
repliers_more_than_limit: 'Replies from {names} and {leftCount} more ...',
},
errors: {
accounts: {
Expand Down

0 comments on commit 53d228c

Please sign in to comment.