git ssb

10+

Matt McKegg / patchwork



Commit fca7e884b005b72ad936e12d9186829ea5e7d0df

added i18n hover descriptions to meta summary actions

Matt McKegg committed on 7/6/2018, 8:03:50 AM
Parent: a289f670e3c164407deae3baa673d2f9d1ab03ee

Files changed

locales/en.jsonchanged
modules/feed/html/meta-summary.jschanged
modules/feed/html/rollup.jschanged
locales/en.jsonView
@@ -211,6 +211,34 @@
211211 "Only visible to you and other thread participants": "Only visible to you and other thread participants",
212212 "This message will be public and cannot be edited or deleted": "This message will be public and cannot be edited or deleted",
213213 "This message will be public and can be edited by anyone": "This message will be public and can be edited by anyone",
214214 "Show details": "Show details",
215- "Hide details": "Hide details"
215+ "Hide details": "Hide details",
216+ "followed %s people": {
217+ "one": "followed %s person",
218+ "other": "followed %s people"
219+ },
220+ "identified %s people": {
221+ "one": "identified %s person",
222+ "other": "identified %s people"
223+ },
224+ "subscribed to %s channels": {
225+ "one": "subscribed to %s channel",
226+ "other": "subscribed to %s channels"
227+ },
228+ "%s people followed": {
229+ "one": "%s person followed",
230+ "other": "%s people followed"
231+ },
232+ "%s people identified": {
233+ "one": "%s person identified",
234+ "other": "%s people identified"
235+ },
236+ "%s people subscribed to": {
237+ "one": "%s person subscribed to",
238+ "other": "%s people subscribed to"
239+ },
240+ "identified": "identified",
241+ "followed": "followed",
242+ "subscribed to": "subscribed to",
243+ "updated their profile": "updated their profile"
216244 }
modules/feed/html/meta-summary.jsView
@@ -1,19 +1,47 @@
11 var nest = require('depnest')
22 var ref = require('ssb-ref')
3-var { when, h, Value } = require('mutant')
3+var { when, h, Value, computed } = require('mutant')
44
55 exports.needs = nest({
66 'intl.sync.i18n': 'first',
7- 'about.html.image': 'first'
7+ 'intl.sync.i18n_n': 'first',
8+ 'about.html.image': 'first',
9+ 'about.obs.name': 'first'
810 })
911
1012 exports.gives = nest({
1113 'feed.html.metaSummary': true
1214 })
1315
16+var i18nActions = {
17+ from: {
18+ followed: 'followed %s people',
19+ unfollowed: 'unfollowed %s people',
20+ subscribed: 'subscribed to %s channels',
21+ unsubscribed: 'unsubscribed from %s channels',
22+ identified: 'identified %s people'
23+ },
24+ to: {
25+ followed: '%s people followed',
26+ unfollowed: '%s people unfollowed',
27+ subscribed: '%s people subscribed to',
28+ unsubscribed: '%s unsubscribed from',
29+ identified: '%s people identified'
30+ },
31+ one: {
32+ followed: 'followed',
33+ unfollowed: 'unfollowed',
34+ subscribed: 'subscribed to',
35+ unsubscribed: 'unsubscribed from',
36+ identified: 'identified'
37+ }
38+}
39+
1440 exports.create = function (api) {
1541 const i18n = api.intl.sync.i18n
42+ const plural = api.intl.sync.i18n_n
43+
1644 return nest('feed.html', {metaSummary})
1745
1846 function metaSummary (group, renderItem, opts) {
1947 var expanded = Value(false)
@@ -24,9 +52,9 @@
2452 var contentSummary = h('FeedMetaSummary', [
2553 reduced.map(item => {
2654 return h('div -' + item.action, [
2755 h('div -left', item.from.slice(0, 10).map(avatarFormatter)),
28- h('span.action'),
56+ h('span.action', {title: actionDescription(item)}),
2957 h('div -right', item.to.slice(0, 10).map(avatarFormatter))
3058 ])
3159 })
3260 ])
@@ -54,8 +82,37 @@
5482 } else {
5583 return h('a', {href: id}, api.about.html.image(id))
5684 }
5785 }
86+
87+ function actionDescription (item) {
88+ if (item.from.length === item.to.length) {
89+ if (item.action === 'identified' && item.from[0] === item.to[0]) {
90+ return computed([
91+ getName(item.from[0])
92+ ], (name) => {
93+ return name + ' ' + i18n('updated their profile')
94+ })
95+ } else {
96+ return computed([
97+ getName(item.from[0]),
98+ getName(item.to[0])
99+ ], (a, b) => {
100+ return a + ' ' + i18n(i18nActions.one[item.action]) + ' ' + b
101+ })
102+ }
103+ } else if (item.from.length < item.to.length) {
104+ let name = getName(item.from[0])
105+ return computed([name, item.to.length], (name, count) => name + ' ' + plural(i18nActions.from[item.action], count))
106+ } else {
107+ let name = getName(item.to[0])
108+ return computed([name, item.from.length], (name, count) => plural(i18nActions.to[item.action], count) + ' ' + name)
109+ }
110+ }
111+
112+ function getName (id) {
113+ return id.startsWith('#') ? id : api.about.obs.name(id)
114+ }
58115 }
59116
60117 function getActions (msgs) {
61118 var actions = {}
modules/feed/html/rollup.jsView
@@ -19,8 +19,11 @@
1919
2020 // bump even for first message
2121 var rootBumpTypes = ['mention', 'channel-mention']
2222
23+// group these message types together using meta-summary
24+var metaSummaryTypes = ['about', 'channel', 'contact']
25+
2326 exports.needs = nest({
2427 'about.obs.name': 'first',
2528 'about.html.image': 'first',
2629 'app.sync.externalHandler': 'first',
@@ -451,12 +454,10 @@
451454 pull.map(function (msgs) {
452455 var result = []
453456 var groups = {}
454457
455- var metaSummaryTypes = ['about', 'channel', 'contact']
456-
457458 msgs.forEach(msg => {
458- var type = 'metaSummary' // msg.value.content.type
459+ var type = 'metaSummary'
459460 if (metaSummaryTypes.includes(msg.value.content.type) && !hasReply(msg) && !ungroupFilter(msg)) {
460461 if (!groups[type]) {
461462 groups[type] = {group: type, msgs: []}
462463 result.push(groups[type])

Built with git-ssb-web