Commit fca7e884b005b72ad936e12d9186829ea5e7d0df
added i18n hover descriptions to meta summary actions
Matt McKegg committed on 7/6/2018, 8:03:50 AMParent: a289f670e3c164407deae3baa673d2f9d1ab03ee
Files changed
locales/en.json | changed |
modules/feed/html/meta-summary.js | changed |
modules/feed/html/rollup.js | changed |
locales/en.json | ||
---|---|---|
@@ -211,6 +211,34 @@ | ||
211 | 211 | "Only visible to you and other thread participants": "Only visible to you and other thread participants", |
212 | 212 | "This message will be public and cannot be edited or deleted": "This message will be public and cannot be edited or deleted", |
213 | 213 | "This message will be public and can be edited by anyone": "This message will be public and can be edited by anyone", |
214 | 214 | "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" | |
216 | 244 | } |
modules/feed/html/meta-summary.js | ||
---|---|---|
@@ -1,19 +1,47 @@ | ||
1 | 1 | var nest = require('depnest') |
2 | 2 | var ref = require('ssb-ref') |
3 | -var { when, h, Value } = require('mutant') | |
3 | +var { when, h, Value, computed } = require('mutant') | |
4 | 4 | |
5 | 5 | exports.needs = nest({ |
6 | 6 | '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' | |
8 | 10 | }) |
9 | 11 | |
10 | 12 | exports.gives = nest({ |
11 | 13 | 'feed.html.metaSummary': true |
12 | 14 | }) |
13 | 15 | |
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 | + | |
14 | 40 | exports.create = function (api) { |
15 | 41 | const i18n = api.intl.sync.i18n |
42 | + const plural = api.intl.sync.i18n_n | |
43 | + | |
16 | 44 | return nest('feed.html', {metaSummary}) |
17 | 45 | |
18 | 46 | function metaSummary (group, renderItem, opts) { |
19 | 47 | var expanded = Value(false) |
@@ -24,9 +52,9 @@ | ||
24 | 52 | var contentSummary = h('FeedMetaSummary', [ |
25 | 53 | reduced.map(item => { |
26 | 54 | return h('div -' + item.action, [ |
27 | 55 | h('div -left', item.from.slice(0, 10).map(avatarFormatter)), |
28 | - h('span.action'), | |
56 | + h('span.action', {title: actionDescription(item)}), | |
29 | 57 | h('div -right', item.to.slice(0, 10).map(avatarFormatter)) |
30 | 58 | ]) |
31 | 59 | }) |
32 | 60 | ]) |
@@ -54,8 +82,37 @@ | ||
54 | 82 | } else { |
55 | 83 | return h('a', {href: id}, api.about.html.image(id)) |
56 | 84 | } |
57 | 85 | } |
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 | + } | |
58 | 115 | } |
59 | 116 | |
60 | 117 | function getActions (msgs) { |
61 | 118 | var actions = {} |
modules/feed/html/rollup.js | ||
---|---|---|
@@ -19,8 +19,11 @@ | ||
19 | 19 | |
20 | 20 | // bump even for first message |
21 | 21 | var rootBumpTypes = ['mention', 'channel-mention'] |
22 | 22 | |
23 | +// group these message types together using meta-summary | |
24 | +var metaSummaryTypes = ['about', 'channel', 'contact'] | |
25 | + | |
23 | 26 | exports.needs = nest({ |
24 | 27 | 'about.obs.name': 'first', |
25 | 28 | 'about.html.image': 'first', |
26 | 29 | 'app.sync.externalHandler': 'first', |
@@ -451,12 +454,10 @@ | ||
451 | 454 | pull.map(function (msgs) { |
452 | 455 | var result = [] |
453 | 456 | var groups = {} |
454 | 457 | |
455 | - var metaSummaryTypes = ['about', 'channel', 'contact'] | |
456 | - | |
457 | 458 | msgs.forEach(msg => { |
458 | - var type = 'metaSummary' // msg.value.content.type | |
459 | + var type = 'metaSummary' | |
459 | 460 | if (metaSummaryTypes.includes(msg.value.content.type) && !hasReply(msg) && !ungroupFilter(msg)) { |
460 | 461 | if (!groups[type]) { |
461 | 462 | groups[type] = {group: type, msgs: []} |
462 | 463 | result.push(groups[type]) |
Built with git-ssb-web