Skip to content

Commit

Permalink
Translate reacted with sentence
Browse files Browse the repository at this point in the history
  • Loading branch information
gdpelican committed May 18, 2019
1 parent 50ff360 commit cba7b77
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ export default Ember.Object.create({
},

sentence() {
let usernames = this.state.usernames
switch(usernames.length) {
case 1: return `${usernames[0]} reacted with :${this.state.emoji}:`
case 2: return `${usernames[0]} and ${usernames[1]} reacted with :${this.state.emoji}:`
default: return `${usernames[0]}, ${usernames[1]}, and ${usernames.length - 2} others reacted with :${this.state.emoji}:`
return I18n.t(this.sentenceKey(), {
first: this.state.usernames[0],
second: this.state.usernames[1],
count: this.state.usernames.length - 2,
emoji: this.state.emoji
})
},

sentenceKey() {
switch(this.state.usernames.length) {
case 1: return 'retort.reactions.one_person'
case 2: return 'retort.reactions.two_people'
default: return 'retort.reactions.many_people'
}
}

Expand Down
4 changes: 4 additions & 0 deletions config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ en:
js:
retort:
title: 'add an emoji reaction to this post'
reactions:
one_person: "%{first} reacted with :%{emoji}:"
two_people: "%{first} and %{second} reacted with :%{emoji}:"
many_people: "%{first}, %{second}, and %{count} others reacted with :%{emoji}:"

0 comments on commit cba7b77

Please sign in to comment.