Commit 77e7fa628b43035fa4c24ea1a9eb35529874721d
Change global i18n to a depject approach
Marcos Gutierrez committed on 9/29/2017, 2:26:15 PMParent: d245481b81b4075ba2a29823d0441ec941545a32
Files changed
index.js | ||
---|---|---|
@@ -2,10 +2,8 @@ | ||
2 | 2 | console.log(err) |
3 | 3 | process.exit() |
4 | 4 | }) |
5 | 5 | |
6 | -var i18n = require('./lib/i18n').i18n | |
7 | - | |
8 | 6 | var electron = require('electron') |
9 | 7 | var openWindow = require('./lib/window') |
10 | 8 | |
11 | 9 | var Path = require('path') |
@@ -82,9 +80,9 @@ | ||
82 | 80 | width: windowState.width, |
83 | 81 | height: windowState.height, |
84 | 82 | titleBarStyle: 'hidden-inset', |
85 | 83 | autoHideMenuBar: true, |
86 | - title: i18n.__("Patchwork"), | |
84 | + title: "Patchwork", | |
87 | 85 | show: true, |
88 | 86 | backgroundColor: '#EEE', |
89 | 87 | webPreferences: { |
90 | 88 | experimentalFeatures: true |
lib/window.js | ||
---|---|---|
@@ -18,9 +18,9 @@ | ||
18 | 18 | electron.webFrame.setZoomLevelLimits(1, 1) |
19 | 19 | |
20 | 20 | var config = ${JSON.stringify(config)} |
21 | 21 | var data = ${JSON.stringify(opts.data)} |
22 | - var title = ${JSON.stringify(opts.title || i18n.__("Patchwork"))} | |
22 | + var title = ${JSON.stringify(opts.title || "Patchwork" )} | |
23 | 23 | |
24 | 24 | document.documentElement.querySelector('head').appendChild( |
25 | 25 | h('title', title) |
26 | 26 | ) |
main-window.js | ||
---|---|---|
@@ -11,9 +11,8 @@ | ||
11 | 11 | var LatestUpdate = require('./lib/latest-update') |
12 | 12 | var ref = require('ssb-ref') |
13 | 13 | var setupContextMenuAndSpellCheck = require('./lib/context-menu-and-spellcheck') |
14 | 14 | var watch = require('mutant/watch') |
15 | -var i18n = require('./lib/i18n').i18n | |
16 | 15 | |
17 | 16 | |
18 | 17 | module.exports = function (config) { |
19 | 18 | var sockets = combine( |
@@ -41,16 +40,19 @@ | ||
41 | 40 | 'profile.sheet.edit': 'first', |
42 | 41 | 'app.navigate': 'first', |
43 | 42 | 'channel.obs.subscribed': 'first', |
44 | 43 | 'settings.obs.get': 'first', |
44 | + 'intl.sync.i18n': 'first', | |
45 | 45 | })) |
46 | 46 | |
47 | 47 | setupContextMenuAndSpellCheck(api.config.sync.load()) |
48 | + | |
49 | + const i18n = api.intl.sync.i18n | |
48 | 50 | |
49 | 51 | var id = api.keys.sync.id() |
50 | 52 | var latestUpdate = LatestUpdate() |
51 | 53 | var subscribedChannels = api.channel.obs.subscribed(id) |
52 | - | |
54 | + | |
53 | 55 | // prompt to setup profile on first use |
54 | 56 | onceTrue(api.sbot.obs.connection, (sbot) => { |
55 | 57 | sbot.latestSequence(sbot.id, (_, key) => { |
56 | 58 | if (key == null) { |
@@ -92,32 +94,32 @@ | ||
92 | 94 | classList: [ when(views.canGoForward, '-active') ] |
93 | 95 | }) |
94 | 96 | ]), |
95 | 97 | h('span.nav', [ |
96 | - tab(i18n.__("Public"), '/public'), | |
97 | - tab(i18n.__("Private"), '/private'), | |
98 | - dropTab(i18n.__('More'), [ | |
98 | + tab(i18n("Public"), '/public'), | |
99 | + tab(i18n("Private"), '/private'), | |
100 | + dropTab(i18n('More'), [ | |
99 | 101 | getSubscribedChannelMenu, |
100 | - [i18n.__('Gatherings'), '/gatherings'], | |
101 | - [i18n.__('Extended Network'), '/all'], | |
102 | + [i18n('Gatherings'), '/gatherings'], | |
103 | + [i18n('Extended Network'), '/all'], | |
102 | 104 | {separator: true}, |
103 | - [i18n.__('Settings'), '/settings'] | |
105 | + [i18n('Settings'), '/settings'] | |
104 | 106 | ]) |
105 | 107 | ]), |
106 | 108 | h('span.appTitle', [ |
107 | - h('span.title', i18n.__("Patchwork")), | |
109 | + h('span.title', i18n("Patchwork")), | |
108 | 110 | api.app.html.progressNotifier() |
109 | 111 | ]), |
110 | 112 | h('span', [ api.app.html.search(api.app.navigate) ]), |
111 | 113 | h('span.nav', [ |
112 | - tab(i18n.__('Profile'), id), | |
113 | - tab(i18n.__('Mentions'), '/mentions') | |
114 | + tab(i18n('Profile'), id), | |
115 | + tab(i18n('Mentions'), '/mentions') | |
114 | 116 | ]) |
115 | 117 | ]), |
116 | 118 | when(latestUpdate, |
117 | 119 | h('div.info', [ |
118 | 120 | h('a.message -update', { href: 'https://github.com/ssbc/patchwork/releases' }, [ |
119 | - h('strong', ['Patchwork ', latestUpdate, i18n.__(' has been released.')]), i18n.__(' Click here to download and view more info!'), | |
121 | + h('strong', ['Patchwork ', latestUpdate, i18n(' has been released.')]), i18n(' Click here to download and view more info!'), | |
120 | 122 | h('a.ignore', {'ev-click': latestUpdate.ignore}, 'X') |
121 | 123 | ]) |
122 | 124 | ]) |
123 | 125 | ), |
@@ -151,11 +153,11 @@ | ||
151 | 153 | var channels = Array.from(subscribedChannels()).sort(localeCompare) |
152 | 154 | |
153 | 155 | if (channels.length) { |
154 | 156 | return { |
155 | - label: i18n.__('Channels'), | |
157 | + label: i18n('Channels'), | |
156 | 158 | submenu: [ |
157 | - { label: i18n.__('Browse All'), | |
159 | + { label: i18n('Browse All'), | |
158 | 160 | click () { |
159 | 161 | setView('/channels') |
160 | 162 | } |
161 | 163 | }, |
@@ -170,9 +172,9 @@ | ||
170 | 172 | })) |
171 | 173 | } |
172 | 174 | } else { |
173 | 175 | return { |
174 | - label: i18n.__('Browse Channels'), | |
176 | + label: i18n('Browse Channels'), | |
175 | 177 | click () { |
176 | 178 | setView('/channels') |
177 | 179 | } |
178 | 180 | } |
modules/app/html/progress-notifier.js | ||
---|---|---|
@@ -1,9 +1,8 @@ | ||
1 | 1 | var {computed, when, h, Value} = require('mutant') |
2 | 2 | var nest = require('depnest') |
3 | 3 | var sustained = require('../../../lib/sustained') |
4 | -var appRoot = require('app-root-path'); | |
5 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
4 | +const pull = require('pull-stream') | |
6 | 5 | |
7 | 6 | exports.gives = nest('app.html.progressNotifier') |
8 | 7 | |
9 | 8 | exports.needs = nest({ |
@@ -12,12 +11,14 @@ | ||
12 | 11 | 'progress.obs': { |
13 | 12 | indexes: 'first', |
14 | 13 | replicate: 'first', |
15 | 14 | migration: 'first' |
16 | - } | |
15 | + }, | |
16 | + 'intl.sync.i18n':'first' | |
17 | 17 | }) |
18 | 18 | |
19 | 19 | exports.create = function (api) { |
20 | + const i18n = api.intl.sync.i18n | |
20 | 21 | return nest('app.html.progressNotifier', function (id) { |
21 | 22 | var replicateProgress = api.progress.obs.replicate() |
22 | 23 | var indexes = api.progress.obs.indexes() |
23 | 24 | var migration = api.progress.obs.migration() |
@@ -47,14 +48,14 @@ | ||
47 | 48 | return h('div.info', { hidden }, [ |
48 | 49 | h('div.status', [ |
49 | 50 | when(displaying, h('Loading -small', [ |
50 | 51 | when(pendingMigration, |
51 | - [h('span.info', i18n.__('Upgrading database')), h('progress', { style: {'margin-left': '10px'}, min: 0, max: 1, value: migrationProgress })], | |
52 | + [h('span.info', i18n('Upgrading database')), h('progress', { style: {'margin-left': '10px'}, min: 0, max: 1, value: migrationProgress })], | |
52 | 53 | when(computed(replicateProgress.incompleteFeeds, (v) => v > 5), |
53 | - [h('span.info', i18n.__('Downloading new messages')), h('progress', { style: {'margin-left': '10px'}, min: 0, max: 1, value: downloadProgress })], | |
54 | + [h('span.info', i18n('Downloading new messages')), h('progress', { style: {'margin-left': '10px'}, min: 0, max: 1, value: downloadProgress })], | |
54 | 55 | when(pending, [ |
55 | - [h('span.info', i18n.__('Indexing database')), h('progress', { style: {'margin-left': '10px'}, min: 0, max: 1, value: indexProgress })] | |
56 | - ], i18n.__('Scuttling...')) | |
56 | + [h('span.info', i18n('Indexing database')), h('progress', { style: {'margin-left': '10px'}, min: 0, max: 1, value: indexProgress })] | |
57 | + ], i18n('Scuttling...')) | |
57 | 58 | ) |
58 | 59 | ) |
59 | 60 | ])) |
60 | 61 | ]) |
modules/app/html/search.js | ||
---|---|---|
@@ -2,27 +2,27 @@ | ||
2 | 2 | var nest = require('depnest') |
3 | 3 | var addSuggest = require('suggest-box') |
4 | 4 | |
5 | 5 | var appRoot = require('app-root-path'); |
6 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
7 | 6 | |
8 | - | |
9 | 7 | exports.needs = nest({ |
10 | 8 | 'profile.async.suggest': 'first', |
11 | - 'channel.async.suggest': 'first' | |
9 | + 'channel.async.suggest': 'first', | |
10 | + 'intl.sync.i18n': 'first' | |
12 | 11 | }) |
13 | 12 | |
14 | 13 | exports.gives = nest('app.html.search') |
15 | 14 | |
16 | 15 | var pages = ['/public', '/private', '/mentions', '/all', '/gatherings'] |
17 | 16 | |
18 | 17 | exports.create = function (api) { |
18 | + const i18n = api.intl.sync.i18n | |
19 | 19 | return nest('app.html.search', function (setView) { |
20 | 20 | var getProfileSuggestions = api.profile.async.suggest() |
21 | 21 | var getChannelSuggestions = api.channel.async.suggest() |
22 | 22 | var searchBox = h('input.search', { |
23 | 23 | type: 'search', |
24 | - placeholder: i18n.__('word, @key, #channel'), | |
24 | + placeholder: i18n('word, @key, #channel'), | |
25 | 25 | 'ev-suggestselect': (ev) => { |
26 | 26 | setView(ev.detail.id) |
27 | 27 | searchBox.value = ev.detail.id |
28 | 28 | }, |
modules/feed/html/rollup.js | ||
---|---|---|
@@ -6,17 +6,14 @@ | ||
6 | 6 | var nextStepper = require('../../../lib/next-stepper') |
7 | 7 | var extend = require('xtend') |
8 | 8 | var paramap = require('pull-paramap') |
9 | 9 | |
10 | -var appRoot = require('app-root-path'); | |
11 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
12 | - | |
13 | 10 | var bumpMessages = { |
14 | - 'vote': i18n.__('liked this message'), | |
15 | - 'post': i18n.__('replied to this message'), | |
16 | - 'about': i18n.__('added changes'), | |
17 | - 'mention': i18n.__('mentioned you'), | |
18 | - 'channel-mention': i18n.__('mentioned this channel') | |
11 | + 'vote': 'liked this message', | |
12 | + 'post': 'replied to this message', | |
13 | + 'about': 'added changes', | |
14 | + 'mention': 'mentioned you', | |
15 | + 'channel-mention': 'mentioned this channel' | |
19 | 16 | } |
20 | 17 | |
21 | 18 | // bump even for first message |
22 | 19 | var rootBumpTypes = ['mention', 'channel-mention'] |
@@ -30,16 +27,18 @@ | ||
30 | 27 | 'message.html.link': 'first', |
31 | 28 | 'message.sync.root': 'first', |
32 | 29 | 'feed.pull.rollup': 'first', |
33 | 30 | 'sbot.async.get': 'first', |
34 | - 'keys.sync.id': 'first' | |
31 | + 'keys.sync.id': 'first', | |
32 | + 'intl.sync.i18n': 'first', | |
35 | 33 | }) |
36 | 34 | |
37 | 35 | exports.gives = nest({ |
38 | 36 | 'feed.html.rollup': true |
39 | 37 | }) |
40 | 38 | |
41 | 39 | exports.create = function (api) { |
40 | + const i18n = api.intl.sync.i18n | |
42 | 41 | return nest('feed.html.rollup', function (getStream, { |
43 | 42 | prepend, |
44 | 43 | rootFilter = returnTrue, |
45 | 44 | bumpFilter = returnTrue, |
@@ -50,9 +49,9 @@ | ||
50 | 49 | var updates = Value(0) |
51 | 50 | var yourId = api.keys.sync.id() |
52 | 51 | var throttledUpdates = throttle(updates, 200) |
53 | 52 | var updateLoader = h('a Notifier -loader', { href: '#', 'ev-click': refresh }, [ |
54 | - 'Show ', h('strong', [throttledUpdates]), ' ', plural(throttledUpdates, i18n.__('update'), i18n.__('updates')) | |
53 | + 'Show ', h('strong', [throttledUpdates]), ' ', plural(throttledUpdates, i18n('update'), i18n('updates')) | |
55 | 54 | ]) |
56 | 55 | |
57 | 56 | var abortLastFeed = null |
58 | 57 | var content = Value() |
@@ -194,11 +193,11 @@ | ||
194 | 193 | var bumps = lastBumpType === 'vote' |
195 | 194 | ? getLikeAuthors(groupedBumps[lastBumpType]) |
196 | 195 | : getAuthors(groupedBumps[lastBumpType]) |
197 | 196 | |
198 | - var description = bumpMessages[lastBumpType] || 'added changes' | |
197 | + var description = i18n(bumpMessages[lastBumpType] || 'added changes') | |
199 | 198 | meta = h('div.meta', { title: names(bumps) }, [ |
200 | - many(bumps, api.profile.html.person), ' ', description | |
199 | + many(bumps, api.profile.html.person, i18n), ' ', description | |
201 | 200 | ]) |
202 | 201 | } |
203 | 202 | |
204 | 203 | return h('FeedEvent -post', { |
@@ -209,9 +208,9 @@ | ||
209 | 208 | meta, |
210 | 209 | renderedMessage, |
211 | 210 | when(replyElements.length, [ |
212 | 211 | when(replies.length > replyElements.length || partial, |
213 | - h('a.full', {href: item.key}, [i18n.__('View full thread') +' (', replies.length, ')']) | |
212 | + h('a.full', {href: item.key}, [i18n('View full thread') +' (', replies.length, ')']) | |
214 | 213 | ), |
215 | 214 | h('div.replies', replyElements) |
216 | 215 | ]) |
217 | 216 | ]) |
@@ -248,36 +247,36 @@ | ||
248 | 247 | } |
249 | 248 | }) |
250 | 249 | } |
251 | 250 | |
252 | -function many (ids, fn) { | |
251 | +function many (ids, fn, intl) { | |
253 | 252 | ids = Array.from(ids) |
254 | 253 | var featuredIds = ids.slice(0, 4) |
255 | 254 | |
256 | 255 | if (ids.length) { |
257 | 256 | if (ids.length > 4) { |
258 | 257 | return [ |
259 | 258 | fn(featuredIds[0]), ', ', |
260 | 259 | fn(featuredIds[1]), ', ', |
261 | - fn(featuredIds[2]), i18n.__(' and '), | |
262 | - ids.length - 3, i18n.__(' others') | |
260 | + fn(featuredIds[2]), intl(' and '), | |
261 | + ids.length - 3, intl(' others'), | |
263 | 262 | ] |
264 | 263 | } else if (ids.length === 4) { |
265 | 264 | return [ |
266 | 265 | fn(featuredIds[0]), ', ', |
267 | 266 | fn(featuredIds[1]), ', ', |
268 | - fn(featuredIds[2]), i18n.__(' and '), | |
267 | + fn(featuredIds[2]), intl(' and '), | |
269 | 268 | fn(featuredIds[3]) |
270 | 269 | ] |
271 | 270 | } else if (ids.length === 3) { |
272 | 271 | return [ |
273 | 272 | fn(featuredIds[0]), ', ', |
274 | - fn(featuredIds[1]), i18n.__(' and '), | |
273 | + fn(featuredIds[1]), intl(' and '), | |
275 | 274 | fn(featuredIds[2]) |
276 | 275 | ] |
277 | 276 | } else if (ids.length === 2) { |
278 | 277 | return [ |
279 | - fn(featuredIds[0]), i18n.__(' and '), | |
278 | + fn(featuredIds[0]), intl(' and '), | |
280 | 279 | fn(featuredIds[1]) |
281 | 280 | ] |
282 | 281 | } else { |
283 | 282 | return fn(featuredIds[0]) |
modules/gathering/sheet/edit.js | ||
---|---|---|
@@ -1,10 +1,8 @@ | ||
1 | 1 | var nest = require('depnest') |
2 | 2 | var extend = require('xtend') |
3 | 3 | var Pickr = require('flatpickr') |
4 | 4 | var spacetime = require('spacetime') |
5 | -var appRoot = require('app-root-path'); | |
6 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
7 | 5 | |
8 | 6 | var {Value, h, computed, when} = require('mutant') |
9 | 7 | |
10 | 8 | exports.gives = nest('gathering.sheet.edit') |
@@ -14,12 +12,14 @@ | ||
14 | 12 | 'keys.sync.id': 'first', |
15 | 13 | 'sbot.async.publish': 'first', |
16 | 14 | 'about.obs.latestValue': 'first', |
17 | 15 | 'blob.html.input': 'first', |
18 | - 'blob.sync.url': 'first' | |
16 | + 'blob.sync.url': 'first', | |
17 | + 'intl.sync.i18n': 'first', | |
19 | 18 | }) |
20 | 19 | |
21 | 20 | exports.create = function (api) { |
21 | + const i18n = api.intl.sync.i18n | |
22 | 22 | return nest('gathering.sheet.edit', function (id) { |
23 | 23 | api.sheet.display(close => { |
24 | 24 | var current = id ? { |
25 | 25 | title: api.about.obs.latestValue(id, 'title'), |
@@ -54,44 +54,44 @@ | ||
54 | 54 | h('h2', { |
55 | 55 | style: { |
56 | 56 | 'font-weight': 'normal' |
57 | 57 | } |
58 | - }, [id ? i18n.__('Edit') : i18n.__('Create'), i18n.__(' Gathering')]), | |
58 | + }, [id ? i18n('Edit') : i18n('Create'), i18n(' Gathering')]), | |
59 | 59 | h('GatheringEditor', [ |
60 | 60 | h('input.title', { |
61 | - placeholder: i18n.__('Choose a title'), | |
61 | + placeholder: i18n('Choose a title'), | |
62 | 62 | hooks: [ValueHook(chosen.title), FocusHook()] |
63 | 63 | }), |
64 | 64 | h('input.date', { |
65 | - placeholder: i18n.__('Choose date and time'), | |
65 | + placeholder: i18n('Choose date and time'), | |
66 | 66 | hooks: [ |
67 | 67 | PickrHook(chosen.startDateTime) |
68 | 68 | ] |
69 | 69 | }), |
70 | 70 | h('ImageInput .banner', { |
71 | 71 | style: { 'background-image': computed(imageUrl, x => `url(${x})`) } |
72 | 72 | }, [ |
73 | - h('span', ['🖼 ', i18n.__('Choose Banner Image...')]), | |
73 | + h('span', ['🖼 ', i18n('Choose Banner Image...')]), | |
74 | 74 | api.blob.html.input(file => { |
75 | 75 | chosen.image.set(file) |
76 | 76 | }, { |
77 | 77 | accept: 'image/*' |
78 | 78 | }) |
79 | 79 | ]), |
80 | 80 | h('textarea.description', { |
81 | - placeholder: i18n.__('Describe the gathering (if you want)'), | |
81 | + placeholder: i18n('Describe the gathering (if you want)'), | |
82 | 82 | hooks: [ValueHook(chosen.description)] |
83 | 83 | }) |
84 | 84 | ]) |
85 | 85 | ]), |
86 | 86 | footer: [ |
87 | 87 | h('button -save', { |
88 | 88 | 'ev-click': save, |
89 | 89 | 'disabled': publishing |
90 | - }, when(publishing, i18n.__('Publishing...'), i18n.__('Publish'))), | |
90 | + }, when(publishing, i18n('Publishing...'), i18n('Publish'))), | |
91 | 91 | h('button -cancel', { |
92 | 92 | 'ev-click': close |
93 | - }, i18n.__('Cancel')) | |
93 | + }, i18n('Cancel')) | |
94 | 94 | ] |
95 | 95 | } |
96 | 96 | |
97 | 97 | function ensureExists (cb) { |
@@ -112,9 +112,9 @@ | ||
112 | 112 | var update = {} |
113 | 113 | |
114 | 114 | if (!compareImage(chosen.image(), current.image())) update.image = chosen.image() |
115 | 115 | if (!compareTime(chosen.startDateTime(), current.startDateTime())) update.startDateTime = chosen.startDateTime() |
116 | - if (chosen.title() !== current.title()) update.title = chosen.title() || i18n.__('Untitled Gathering') | |
116 | + if (chosen.title() !== current.title()) update.title = chosen.title() || i18n('Untitled Gathering') | |
117 | 117 | if (chosen.description() !== current.description()) update.description = chosen.description() |
118 | 118 | |
119 | 119 | if (Object.keys(update).length) { |
120 | 120 | publishing.set(true) |
@@ -127,11 +127,11 @@ | ||
127 | 127 | if (err) { |
128 | 128 | publishing.set(false) |
129 | 129 | showDialog({ |
130 | 130 | type: 'error', |
131 | - title: i18n.__('Error'), | |
131 | + title: i18n('Error'), | |
132 | 132 | buttons: ['OK'], |
133 | - message: i18n.__('An error occurred while attempting to publish gathering.'), | |
133 | + message: i18n('An error occurred while attempting to publish gathering.'), | |
134 | 134 | detail: err.message |
135 | 135 | }) |
136 | 136 | } else { |
137 | 137 | close() |
modules/invite/sheet.js | ||
---|---|---|
@@ -1,19 +1,18 @@ | ||
1 | 1 | var {h, when, Value, Proxy} = require('mutant') |
2 | 2 | var nest = require('depnest') |
3 | 3 | var electron = require('electron') |
4 | 4 | |
5 | -var appRoot = require('app-root-path'); | |
6 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
7 | - | |
8 | 5 | exports.needs = nest({ |
9 | 6 | 'sheet.display': 'first', |
10 | - 'invite.async.accept': 'first' | |
7 | + 'invite.async.accept': 'first', | |
8 | + 'intl.sync.i18n': 'first', | |
11 | 9 | }) |
12 | 10 | |
13 | 11 | exports.gives = nest('invite.sheet') |
14 | 12 | |
15 | 13 | exports.create = function (api) { |
14 | + const i18n = api.intl.sync.i18n | |
16 | 15 | return nest('invite.sheet', function () { |
17 | 16 | api.sheet.display(close => { |
18 | 17 | var publishing = Value() |
19 | 18 | var publishStatus = Proxy() |
@@ -23,9 +22,9 @@ | ||
23 | 22 | 'font-size': '200%', |
24 | 23 | 'margin-top': '20px', |
25 | 24 | 'width': '100%' |
26 | 25 | }, |
27 | - placeholder: i18n.__('paste invite code here') | |
26 | + placeholder: i18n('paste invite code here') | |
28 | 27 | }) |
29 | 28 | setTimeout(() => { |
30 | 29 | input.focus() |
31 | 30 | input.select() |
@@ -39,11 +38,11 @@ | ||
39 | 38 | h('h2', { |
40 | 39 | style: { |
41 | 40 | 'font-weight': 'normal' |
42 | 41 | } |
43 | - }, [i18n.__('By default, Patchwork will only see other users that are on the same local area network as you.')]), | |
42 | + }, [i18n('By default, Patchwork will only see other users that are on the same local area network as you.')]), | |
44 | 43 | h('div', [ |
45 | - i18n.__('In order to share with users on the internet, you need to be invited to a pub server.') | |
44 | + i18n('In order to share with users on the internet, you need to be invited to a pub server.') | |
46 | 45 | ]), |
47 | 46 | input |
48 | 47 | ]), |
49 | 48 | footer: [ |
@@ -55,22 +54,22 @@ | ||
55 | 54 | if (err) { |
56 | 55 | publishing.set(false) |
57 | 56 | showDialog({ |
58 | 57 | type: 'error', |
59 | - title: i18n.__('Error'), | |
60 | - buttons: [i18n.__('OK')], | |
61 | - message: i18n.__('An error occurred while attempting to redeem invite.'), | |
58 | + title: i18n('Error'), | |
59 | + buttons: [i18n('OK')], | |
60 | + message: i18n('An error occurred while attempting to redeem invite.'), | |
62 | 61 | detail: err.message |
63 | 62 | }) |
64 | 63 | } else { |
65 | 64 | close() |
66 | 65 | } |
67 | 66 | })) |
68 | 67 | } |
69 | - }, [ when(publishing, publishStatus, i18n.__('Redeem Invite')) ]), | |
68 | + }, [ when(publishing, publishStatus, i18n('Redeem Invite')) ]), | |
70 | 69 | h('button -cancel', { |
71 | 70 | 'ev-click': close |
72 | - }, i18n.__('Cancel')) | |
71 | + }, i18n('Cancel')) | |
73 | 72 | ] |
74 | 73 | } |
75 | 74 | }) |
76 | 75 | }) |
modules/message/async/publish.js | ||
---|---|---|
@@ -1,21 +1,19 @@ | ||
1 | 1 | var h = require('mutant/h') |
2 | 2 | var nest = require('depnest') |
3 | -var i18n = require('i18n') | |
4 | 3 | |
5 | -var appRoot = require('app-root-path') | |
6 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
7 | - | |
8 | 4 | exports.needs = nest({ |
9 | 5 | 'sheet.display': 'first', |
10 | 6 | 'message.html.render': 'first', |
11 | 7 | 'sbot.async.publish': 'first', |
12 | - 'keys.sync.id': 'first' | |
8 | + 'keys.sync.id': 'first', | |
9 | + 'intl.sync.i18n': 'first', | |
13 | 10 | }) |
14 | 11 | |
15 | 12 | exports.gives = nest('message.async.publish') |
16 | 13 | |
17 | 14 | exports.create = function (api) { |
15 | + const i18n = api.intl.sync.i18n | |
18 | 16 | return nest('message.async.publish', function (content, cb) { |
19 | 17 | api.sheet.display(function (close) { |
20 | 18 | return { |
21 | 19 | content: [ |
@@ -25,10 +23,10 @@ | ||
25 | 23 | author: api.keys.sync.id() |
26 | 24 | }}) |
27 | 25 | ], |
28 | 26 | footer: [ |
29 | - h('button -save', { 'ev-click': publish }, i18n.__('Confirm')), | |
30 | - h('button -cancel', { 'ev-click': cancel }, i18n.__('Cancel')) | |
27 | + h('button -save', { 'ev-click': publish }, i18n('Confirm')), | |
28 | + h('button -cancel', { 'ev-click': cancel }, i18n('Cancel')) | |
31 | 29 | ] |
32 | 30 | } |
33 | 31 | |
34 | 32 | function publish () { |
modules/message/html/backlinks.js | ||
---|---|---|
@@ -1,22 +1,22 @@ | ||
1 | 1 | var nest = require('depnest') |
2 | 2 | var ref = require('ssb-ref') |
3 | 3 | var { h, map, computed } = require('mutant') |
4 | -var appRoot = require('app-root-path') | |
5 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
6 | 4 | |
7 | 5 | exports.needs = nest({ |
8 | 6 | 'message.obs': { |
9 | 7 | backlinks: 'first', |
10 | 8 | name: 'first', |
11 | 9 | author: 'first' |
12 | 10 | }, |
13 | - 'profile.html.person': 'first' | |
11 | + 'profile.html.person': 'first', | |
12 | + 'intl.sync.i18n': 'first', | |
14 | 13 | }) |
15 | 14 | |
16 | 15 | exports.gives = nest('message.html.backlinks') |
17 | 16 | |
18 | 17 | exports.create = function (api) { |
18 | + const i18n = api.intl.sync.i18n | |
19 | 19 | return nest('message.html.backlinks', function (msg, {includeReferences = true, includeForks = true} = {}) { |
20 | 20 | if (!ref.type(msg.key)) return [] |
21 | 21 | var backlinks = api.message.obs.backlinks(msg.key) |
22 | 22 | var references = includeReferences ? computed([backlinks, msg], onlyReferences) : [] |
@@ -26,9 +26,9 @@ | ||
26 | 26 | return h('a.backlink', { |
27 | 27 | href: link.id, title: link.id |
28 | 28 | }, [ |
29 | 29 | h('strong', [ |
30 | - api.profile.html.person(link.author), i18n.__(' forked this discussion:') | |
30 | + api.profile.html.person(link.author), i18n(' forked this discussion:') | |
31 | 31 | ]), ' ', |
32 | 32 | api.message.obs.name(link.id) |
33 | 33 | ]) |
34 | 34 | }), |
@@ -36,9 +36,9 @@ | ||
36 | 36 | return h('a.backlink', { |
37 | 37 | href: link.id, title: link.id |
38 | 38 | }, [ |
39 | 39 | h('strong', [ |
40 | - api.profile.html.person(link.author), i18n.__(' referenced this message:') | |
40 | + api.profile.html.person(link.author), i18n(' referenced this message:') | |
41 | 41 | ]), ' ', |
42 | 42 | api.message.obs.name(link.id) |
43 | 43 | ]) |
44 | 44 | }) |
modules/message/html/compose.js | ||
---|---|---|
@@ -8,23 +8,22 @@ | ||
8 | 8 | var mentions = require('ssb-mentions') |
9 | 9 | var extend = require('xtend') |
10 | 10 | var addSuggest = require('suggest-box') |
11 | 11 | |
12 | -var appRoot = require('app-root-path'); | |
13 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
14 | - | |
15 | 12 | exports.needs = nest({ |
16 | 13 | 'blob.html.input': 'first', |
17 | 14 | 'profile.async.suggest': 'first', |
18 | 15 | 'channel.async.suggest': 'first', |
19 | 16 | 'message.async.publish': 'first', |
20 | 17 | 'emoji.sync.names': 'first', |
21 | - 'emoji.sync.url': 'first' | |
18 | + 'emoji.sync.url': 'first', | |
19 | + 'intl.sync.i18n': 'first', | |
22 | 20 | }) |
23 | 21 | |
24 | 22 | exports.gives = nest('message.html.compose') |
25 | 23 | |
26 | 24 | exports.create = function (api) { |
25 | + const i18n = api.intl.sync.i18n | |
27 | 26 | return nest('message.html.compose', function ({shrink = true, meta, prepublish, placeholder = 'Write a message'}, cb) { |
28 | 27 | var files = [] |
29 | 28 | var filesById = {} |
30 | 29 | var focused = Value(false) |
@@ -98,9 +97,9 @@ | ||
98 | 97 | |
99 | 98 | var publishBtn = h('button', { |
100 | 99 | 'ev-click': publish, |
101 | 100 | disabled: publishing |
102 | - }, when(publishing, i18n.__('Publishing...'), i18n.__('Publish'))) | |
101 | + }, when(publishing, i18n('Publishing...'), i18n('Publish'))) | |
103 | 102 | |
104 | 103 | var actions = h('section.actions', [ |
105 | 104 | fileInput, |
106 | 105 | publishBtn |
modules/message/sheet/likes.js | ||
---|---|---|
@@ -1,32 +1,31 @@ | ||
1 | 1 | var {h, when, map, computed} = require('mutant') |
2 | 2 | var nest = require('depnest') |
3 | 3 | var catchLinks = require('../../../lib/catch-links') |
4 | 4 | |
5 | -var appRoot = require('app-root-path'); | |
6 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
7 | - | |
8 | 5 | exports.needs = nest({ |
9 | 6 | 'sheet.display': 'first', |
10 | 7 | 'keys.sync.id': 'first', |
11 | 8 | 'contact.obs.following': 'first', |
12 | 9 | 'profile.obs.rank': 'first', |
13 | 10 | 'about.html.image': 'first', |
14 | 11 | 'about.obs.name': 'first', |
15 | - 'app.navigate': 'first' | |
12 | + 'app.navigate': 'first', | |
13 | + 'intl.sync.i18n': 'first', | |
16 | 14 | }) |
17 | 15 | |
18 | 16 | exports.gives = nest('message.sheet.likes') |
19 | 17 | |
20 | 18 | exports.create = function (api) { |
19 | + const i18n = api.intl.sync.i18n | |
21 | 20 | return nest('message.sheet.likes', function (ids) { |
22 | 21 | api.sheet.display(close => { |
23 | 22 | var content = h('div', { |
24 | 23 | style: { padding: '20px' } |
25 | 24 | }, [ |
26 | 25 | h('h2', { |
27 | 26 | style: { 'font-weight': 'normal' } |
28 | - }, [i18n.__('Liked by')]), | |
27 | + }, [i18n('Liked by')]), | |
29 | 28 | renderContactBlock(ids) |
30 | 29 | ]) |
31 | 30 | |
32 | 31 | catchLinks(content, (href, external) => { |
@@ -40,9 +39,9 @@ | ||
40 | 39 | content, |
41 | 40 | footer: [ |
42 | 41 | h('button -close', { |
43 | 42 | 'ev-click': close |
44 | - }, i18n.__('Close')) | |
43 | + }, i18n('Close')) | |
45 | 44 | ] |
46 | 45 | } |
47 | 46 | }) |
48 | 47 | }) |
modules/page/html/render/all.js | ||
---|---|---|
@@ -1,34 +1,34 @@ | ||
1 | 1 | var nest = require('depnest') |
2 | 2 | var { h } = require('mutant') |
3 | -var appRoot = require('app-root-path') | |
4 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
5 | 3 | |
6 | 4 | exports.needs = nest({ |
7 | 5 | 'feed.pull.public': 'first', |
8 | 6 | 'message.html.compose': 'first', |
9 | 7 | 'message.async.publish': 'first', |
10 | - 'feed.html.rollup': 'first' | |
8 | + 'feed.html.rollup': 'first', | |
9 | + 'intl.sync.i18n': 'first', | |
11 | 10 | }) |
12 | 11 | |
13 | 12 | exports.gives = nest({ |
14 | 13 | 'page.html.render': true |
15 | 14 | }) |
16 | 15 | |
17 | 16 | exports.create = function (api) { |
17 | + const i18n = api.intl.sync.i18n | |
18 | 18 | return nest('page.html.render', page) |
19 | 19 | |
20 | 20 | function page (path) { |
21 | 21 | if (path !== '/all') return // "/" is a sigil for "page" |
22 | 22 | |
23 | 23 | var prepend = [ |
24 | 24 | h('PageHeading', [ |
25 | 25 | h('h1', [ |
26 | - i18n.__('All Posts from Your '), | |
27 | - h('strong', i18n.__('Extended Network')) | |
26 | + i18n('All Posts from Your '), | |
27 | + h('strong', i18n('Extended Network')) | |
28 | 28 | ]) |
29 | 29 | ]), |
30 | - api.message.html.compose({ meta: { type: 'post' }, placeholder: i18n.__('Write a public message') }) | |
30 | + api.message.html.compose({ meta: { type: 'post' }, placeholder: i18n('Write a public message') }) | |
31 | 31 | ] |
32 | 32 | |
33 | 33 | var feedView = api.feed.html.rollup(api.feed.pull.public, { |
34 | 34 | bumpFilter: (msg) => { |
modules/page/html/render/channel.js | ||
---|---|---|
@@ -1,22 +1,22 @@ | ||
1 | 1 | var { h, when, send } = require('mutant') |
2 | 2 | var nest = require('depnest') |
3 | -var appRoot = require('app-root-path') | |
4 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
5 | 3 | |
6 | 4 | exports.needs = nest({ |
7 | 5 | 'channel.obs.subscribed': 'first', |
8 | 6 | 'message.html.compose': 'first', |
9 | 7 | 'feed.html.rollup': 'first', |
10 | 8 | 'feed.pull.channel': 'first', |
11 | 9 | 'sbot.pull.log': 'first', |
12 | 10 | 'message.async.publish': 'first', |
13 | - 'keys.sync.id': 'first' | |
11 | + 'keys.sync.id': 'first', | |
12 | + 'intl.sync.i18n': 'first', | |
14 | 13 | }) |
15 | 14 | |
16 | 15 | exports.gives = nest('page.html.render') |
17 | 16 | |
18 | 17 | exports.create = function (api) { |
18 | + const i18n = api.intl.sync.i18n | |
19 | 19 | return nest('page.html.render', function channel (path) { |
20 | 20 | if (path[0] !== '#') return |
21 | 21 | |
22 | 22 | var channel = path.substr(1) |
@@ -28,21 +28,21 @@ | ||
28 | 28 | h('div.meta', [ |
29 | 29 | when(subscribedChannels.has(channel), |
30 | 30 | h('a.ToggleButton.-unsubscribe', { |
31 | 31 | 'href': '#', |
32 | - 'title': i18n.__('Click to unsubscribe'), | |
32 | + 'title': i18n('Click to unsubscribe'), | |
33 | 33 | 'ev-click': send(unsubscribe, channel) |
34 | - }, i18n.__('Subscribed')), | |
34 | + }, i18n('Subscribed')), | |
35 | 35 | h('a.ToggleButton.-subscribe', { |
36 | 36 | 'href': '#', |
37 | 37 | 'ev-click': send(subscribe, channel) |
38 | - }, i18n.__('Subscribe')) | |
38 | + }, i18n('Subscribe')) | |
39 | 39 | ) |
40 | 40 | ]) |
41 | 41 | ]), |
42 | 42 | api.message.html.compose({ |
43 | 43 | meta: {type: 'post', channel}, |
44 | - placeholder: i18n.__('Write a message in this channel') | |
44 | + placeholder: i18n('Write a message in this channel') | |
45 | 45 | }) |
46 | 46 | ] |
47 | 47 | |
48 | 48 | return api.feed.html.rollup(api.feed.pull.channel(channel), { |
modules/page/html/render/channels.js | ||
---|---|---|
@@ -1,21 +1,21 @@ | ||
1 | 1 | var nest = require('depnest') |
2 | 2 | var { h, send, when, computed, map } = require('mutant') |
3 | -var appRoot = require('app-root-path') | |
4 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
5 | 3 | |
6 | 4 | exports.needs = nest({ |
7 | 5 | 'message.async.publish': 'first', |
8 | 6 | 'keys.sync.id': 'first', |
9 | 7 | 'channel.obs': { |
10 | 8 | subscribed: 'first', |
11 | 9 | recent: 'first' |
12 | - } | |
10 | + }, | |
11 | + 'intl.sync.i18n': 'first' | |
13 | 12 | }) |
14 | 13 | |
15 | 14 | exports.gives = nest('page.html.render') |
16 | 15 | |
17 | 16 | exports.create = function(api){ |
17 | + const i18n = api.intl.sync.i18n | |
18 | 18 | return nest('page.html.render', function page(path){ |
19 | 19 | if (path !== '/channels') return |
20 | 20 | |
21 | 21 | var id = api.keys.sync.id() |
@@ -40,12 +40,12 @@ | ||
40 | 40 | h('span.name', '#' + channel), |
41 | 41 | when(subscribed, |
42 | 42 | h('a.-unsubscribe', { |
43 | 43 | 'ev-click': send(unsubscribe, channel) |
44 | - }, i18n.__('Unsubscribe')), | |
44 | + }, i18n('Unsubscribe')), | |
45 | 45 | h('a.-subscribe', { |
46 | 46 | 'ev-click': send(subscribe, channel) |
47 | - }, i18n.__('Subscribe')) | |
47 | + }, i18n('Subscribe')) | |
48 | 48 | ) |
49 | 49 | ]) |
50 | 50 | }, {maxTime: 5, idle: true}) |
51 | 51 | ]) |
modules/page/html/render/gatherings.js | ||
---|---|---|
@@ -1,35 +1,35 @@ | ||
1 | 1 | var { h } = require('mutant') |
2 | 2 | var nest = require('depnest') |
3 | -var appRoot = require('app-root-path') | |
4 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
5 | 3 | |
6 | 4 | exports.needs = nest({ |
7 | 5 | 'feed.pull.type': 'first', |
8 | 6 | 'feed.html.rollup': 'first', |
9 | 7 | 'feed.pull.public': 'first', |
10 | 8 | 'gathering.sheet.edit': 'first', |
11 | 9 | 'keys.sync.id': 'first', |
12 | 10 | 'contact.obs.following': 'first', |
13 | - 'sbot.pull.stream': 'first' | |
11 | + 'sbot.pull.stream': 'first', | |
12 | + 'intl.sync.i18n': 'first', | |
14 | 13 | }) |
15 | 14 | |
16 | 15 | exports.gives = nest('page.html.render') |
17 | 16 | |
18 | 17 | exports.create = function (api) { |
18 | + const i18n = api.intl.sync.i18n | |
19 | 19 | return nest('page.html.render', function channel (path) { |
20 | 20 | if (path !== '/gatherings') return |
21 | 21 | |
22 | 22 | var id = api.keys.sync.id() |
23 | 23 | var following = api.contact.obs.following(id) |
24 | 24 | |
25 | 25 | var prepend = [ |
26 | 26 | h('PageHeading', [ |
27 | - h('h1', [h('strong', i18n.__('Gatherings')), i18n.__(' from your extended network')]), | |
27 | + h('h1', [h('strong', i18n('Gatherings')), i18n(' from your extended network')]), | |
28 | 28 | h('div.meta', [ |
29 | 29 | h('button -add', { |
30 | 30 | 'ev-click': createGathering |
31 | - }, i18n.__('+ Add Gathering')) | |
31 | + }, i18n('+ Add Gathering')) | |
32 | 32 | ]) |
33 | 33 | ]) |
34 | 34 | ] |
35 | 35 |
modules/page/html/render/message.js | ||
---|---|---|
@@ -1,25 +1,24 @@ | ||
1 | 1 | var { h, when, map, Proxy, Struct, Value, computed } = require('mutant') |
2 | 2 | var nest = require('depnest') |
3 | 3 | var ref = require('ssb-ref') |
4 | 4 | |
5 | -var appRoot = require('app-root-path') | |
6 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
7 | - | |
8 | 5 | exports.needs = nest({ |
9 | 6 | 'keys.sync.id': 'first', |
10 | 7 | 'feed.obs.thread': 'first', |
11 | 8 | 'message.sync.unbox': 'first', |
12 | 9 | 'message.html': { |
13 | 10 | render: 'first', |
14 | 11 | compose: 'first' |
15 | 12 | }, |
16 | - 'sbot.async.get': 'first' | |
13 | + 'sbot.async.get': 'first', | |
14 | + 'intl.sync.i18n':'first', | |
17 | 15 | }) |
18 | 16 | |
19 | 17 | exports.gives = nest('page.html.render') |
20 | 18 | |
21 | 19 | exports.create = function (api) { |
20 | + const i18n = api.intl.sync.i18n | |
22 | 21 | return nest('page.html.render', function (id) { |
23 | 22 | if (!ref.isMsg(id)) return |
24 | 23 | var loader = h('div', {className: 'Loading -large'}) |
25 | 24 | |
@@ -35,15 +34,15 @@ | ||
35 | 34 | |
36 | 35 | var compose = api.message.html.compose({ |
37 | 36 | meta, |
38 | 37 | shrink: false, |
39 | - placeholder: when(meta.recps, i18n.__('Write a private reply'), i18n.__('Write a public reply')) | |
38 | + placeholder: when(meta.recps, i18n('Write a private reply'), i18n('Write a public reply')) | |
40 | 39 | }) |
41 | 40 | |
42 | 41 | api.sbot.async.get(id, (err, value) => { |
43 | 42 | if (err) { |
44 | 43 | return result.set(h('PageHeading', [ |
45 | - h('h1', i18n.__('Cannot load thead')) | |
44 | + h('h1', i18n('Cannot load thead')) | |
46 | 45 | ])) |
47 | 46 | } |
48 | 47 | |
49 | 48 | if (typeof value.content === 'string') { |
@@ -51,9 +50,9 @@ | ||
51 | 50 | } |
52 | 51 | |
53 | 52 | if (!value) { |
54 | 53 | return result.set(h('PageHeading', [ |
55 | - h('h1', i18n.__('Cannot display message.')) | |
54 | + h('h1', i18n('Cannot display message.')) | |
56 | 55 | ])) |
57 | 56 | } |
58 | 57 | |
59 | 58 | // what happens in private stays in private! |
@@ -69,9 +68,9 @@ | ||
69 | 68 | meta.branch.set(isReply ? thread.branchId : thread.lastId) |
70 | 69 | |
71 | 70 | var container = h('Thread', [ |
72 | 71 | h('div.messages', [ |
73 | - when(thread.branchId, h('a.full', {href: thread.rootId}, [i18n.__('View full thread')])), | |
72 | + when(thread.branchId, h('a.full', {href: thread.rootId}, [i18n('View full thread')])), | |
74 | 73 | map(thread.messages, (msg) => { |
75 | 74 | return computed([msg, thread.previousKey(msg)], (msg, previousId) => { |
76 | 75 | return api.message.html.render(msg, {pageId: id, previousId, includeReferences: true}) |
77 | 76 | }) |
modules/page/html/render/private.js | ||
---|---|---|
@@ -1,19 +1,19 @@ | ||
1 | 1 | var nest = require('depnest') |
2 | 2 | var ref = require('ssb-ref') |
3 | -var appRoot = require('app-root-path') | |
4 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
5 | 3 | |
6 | 4 | exports.needs = nest({ |
7 | 5 | 'feed.html.rollup': 'first', |
8 | 6 | 'feed.pull.private': 'first', |
9 | 7 | 'message.html.compose': 'first', |
10 | - 'keys.sync.id': 'first' | |
8 | + 'keys.sync.id': 'first', | |
9 | + 'intl.sync.i18n': 'first', | |
11 | 10 | }) |
12 | 11 | |
13 | 12 | exports.gives = nest('page.html.render') |
14 | 13 | |
15 | 14 | exports.create = function (api) { |
15 | + const i18n = api.intl.sync.i18n | |
16 | 16 | return nest('page.html.render', function channel (path) { |
17 | 17 | if (path !== '/private') return |
18 | 18 | |
19 | 19 | var id = api.keys.sync.id() |
@@ -25,9 +25,9 @@ | ||
25 | 25 | return ref.isFeed(typeof e === 'string' ? e : e.link) |
26 | 26 | }) |
27 | 27 | return msg |
28 | 28 | }, |
29 | - placeholder: i18n.__('Write a private message') | |
29 | + placeholder: i18n('Write a private message') | |
30 | 30 | }) |
31 | 31 | ] |
32 | 32 | |
33 | 33 | return api.feed.html.rollup(api.feed.pull.private, { prepend }) |
modules/page/html/render/profile.js | ||
---|---|---|
@@ -1,10 +1,8 @@ | ||
1 | 1 | var nest = require('depnest') |
2 | 2 | var ref = require('ssb-ref') |
3 | 3 | var {h, when, computed, map, send, dictToCollection, resolve} = require('mutant') |
4 | 4 | var extend = require('xtend') |
5 | -var appRoot = require('app-root-path') | |
6 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
7 | 5 | |
8 | 6 | exports.needs = nest({ |
9 | 7 | 'about.obs': { |
10 | 8 | name: 'first', |
@@ -27,13 +25,15 @@ | ||
27 | 25 | 'profile.sheet.edit': 'first', |
28 | 26 | 'contact.obs': { |
29 | 27 | followers: 'first', |
30 | 28 | following: 'first' |
31 | - } | |
29 | + }, | |
30 | + 'intl.sync.i18n': 'first', | |
32 | 31 | }) |
33 | 32 | exports.gives = nest('page.html.render') |
34 | 33 | |
35 | 34 | exports.create = function (api) { |
35 | + const i18n = api.intl.sync.i18n | |
36 | 36 | return nest('page.html.render', function profile (id) { |
37 | 37 | if (!ref.isFeed(id)) return |
38 | 38 | |
39 | 39 | var name = api.about.obs.name(id) |
@@ -85,9 +85,9 @@ | ||
85 | 85 | classList: [ |
86 | 86 | when(isSelf, '-self'), |
87 | 87 | when(isAssigned, '-assigned') |
88 | 88 | ], |
89 | - title: nameList(when(isSelf, i18n.__('Self Assigned'), i18n.__('Assigned By')), item.value) | |
89 | + title: nameList(when(isSelf, i18n('Self Assigned'), i18n('Assigned By')), item.value) | |
90 | 90 | }, [ |
91 | 91 | item.key |
92 | 92 | ]) |
93 | 93 | }), |
@@ -113,9 +113,9 @@ | ||
113 | 113 | classList: [ |
114 | 114 | when(isSelf, '-self'), |
115 | 115 | when(isAssigned, '-assigned') |
116 | 116 | ], |
117 | - title: nameList(when(isSelf, i18n.__('Self Assigned'), i18n.__('Assigned By')), item.value) | |
117 | + title: nameList(when(isSelf, i18n('Self Assigned'), i18n('Assigned By')), item.value) | |
118 | 118 | }, [ |
119 | 119 | h('img', { |
120 | 120 | className: 'Avatar', |
121 | 121 | style: { 'background-color': api.about.obs.color(id) }, |
@@ -139,20 +139,20 @@ | ||
139 | 139 | h('div.title', [ |
140 | 140 | h('h1', [name]), |
141 | 141 | h('div.meta', [ |
142 | 142 | when(id === yourId, [ |
143 | - h('button', {'ev-click': api.profile.sheet.edit}, i18n.__('Edit Your Profile')) | |
143 | + h('button', {'ev-click': api.profile.sheet.edit}, i18n('Edit Your Profile')) | |
144 | 144 | ], [ |
145 | 145 | when(youFollow, |
146 | 146 | h('a.ToggleButton.-unsubscribe', { |
147 | 147 | 'href': '#', |
148 | - 'title': i18n.__('Click to unfollow'), | |
148 | + 'title': i18n('Click to unfollow'), | |
149 | 149 | 'ev-click': send(unfollow, id) |
150 | - }, when(isFriends, i18n.__('Friends'), i18n.__('Following'))), | |
150 | + }, when(isFriends, i18n('Friends'), i18n('Following'))), | |
151 | 151 | h('a.ToggleButton.-subscribe', { |
152 | 152 | 'href': '#', |
153 | 153 | 'ev-click': send(follow, id) |
154 | - }, when(followsYou, i18n.__('Follow Back'), i18n.__('Follow'))) | |
154 | + }, when(followsYou, i18n('Follow Back'), i18n('Follow'))) | |
155 | 155 | ) |
156 | 156 | ]) |
157 | 157 | ]) |
158 | 158 | ]), |
@@ -179,11 +179,11 @@ | ||
179 | 179 | ]), |
180 | 180 | h('div.side.-right', [ |
181 | 181 | when(friendsLoaded, |
182 | 182 | h('div', [ |
183 | - renderContactBlock(i18n.__('Friends'), friends, yourFollows), | |
184 | - renderContactBlock(i18n.__('Followers'), followers, yourFollows), | |
185 | - renderContactBlock(i18n.__('Following'), following, yourFollows) | |
183 | + renderContactBlock(i18n('Friends'), friends, yourFollows), | |
184 | + renderContactBlock(i18n('Followers'), followers, yourFollows), | |
185 | + renderContactBlock(i18n('Following'), following, yourFollows) | |
186 | 186 | ]), |
187 | 187 | h('div', {className: 'Loading'}) |
188 | 188 | ) |
189 | 189 | ]) |
@@ -275,9 +275,9 @@ | ||
275 | 275 | h('h2', { |
276 | 276 | style: { |
277 | 277 | 'font-weight': 'normal' |
278 | 278 | } |
279 | - }, [i18n.__('What whould you like to call '), h('strong', [currentName]), '?']), | |
279 | + }, [i18n('What whould you like to call '), h('strong', [currentName]), '?']), | |
280 | 280 | input |
281 | 281 | ]), |
282 | 282 | footer: [ |
283 | 283 | h('button -save', { |
@@ -291,12 +291,12 @@ | ||
291 | 291 | }) |
292 | 292 | } |
293 | 293 | close() |
294 | 294 | } |
295 | - }, i18n.__('Confirm')), | |
295 | + }, i18n('Confirm')), | |
296 | 296 | h('button -cancel', { |
297 | 297 | 'ev-click': close |
298 | - }, i18n.__('Cancel')) | |
298 | + }, i18n('Cancel')) | |
299 | 299 | ] |
300 | 300 | } |
301 | 301 | }) |
302 | 302 | } |
modules/page/html/render/public.js | ||
---|---|---|
@@ -3,12 +3,8 @@ | ||
3 | 3 | var pull = require('pull-stream') |
4 | 4 | var normalizeChannel = require('../../../../lib/normalize-channel') |
5 | 5 | var { h, send, when, computed, map } = require('mutant') |
6 | 6 | |
7 | -var appRoot = require('app-root-path'); | |
8 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
9 | - | |
10 | - | |
11 | 7 | exports.needs = nest({ |
12 | 8 | sbot: { |
13 | 9 | obs: { |
14 | 10 | connectedPeers: 'first', |
@@ -32,16 +28,18 @@ | ||
32 | 28 | subscribed: 'first', |
33 | 29 | recent: 'first' |
34 | 30 | }, |
35 | 31 | 'keys.sync.id': 'first', |
36 | - 'settings.obs.get': 'first' | |
32 | + 'settings.obs.get': 'first', | |
33 | + 'intl.sync.i18n': 'first', | |
37 | 34 | }) |
38 | 35 | |
39 | 36 | exports.gives = nest({ |
40 | 37 | 'page.html.render': true |
41 | 38 | }) |
42 | 39 | |
43 | 40 | exports.create = function (api) { |
41 | + const i18n = api.intl.sync.i18n | |
44 | 42 | return nest('page.html.render', page) |
45 | 43 | |
46 | 44 | function page (path) { |
47 | 45 | if (path !== '/public') return // "/" is a sigil for "page" |
@@ -56,9 +54,9 @@ | ||
56 | 54 | var localPeers = api.sbot.obs.localPeers() |
57 | 55 | var connectedPubs = computed([connectedPeers, localPeers], (c, l) => c.filter(x => !l.includes(x))) |
58 | 56 | |
59 | 57 | var prepend = [ |
60 | - api.message.html.compose({ meta: { type: 'post' }, placeholder: i18n.__('Write a public message') }) | |
58 | + api.message.html.compose({ meta: { type: 'post' }, placeholder: i18n('Write a public message') }) | |
61 | 59 | ] |
62 | 60 | |
63 | 61 | var getStream = (opts) => { |
64 | 62 | if (opts.lt != null && !opts.lt.marker) { |
@@ -115,11 +113,11 @@ | ||
115 | 113 | }) |
116 | 114 | return [ |
117 | 115 | h('button -pub -full', { |
118 | 116 | 'ev-click': api.invite.sheet |
119 | - }, i18n.__('+ Join Pub')), | |
117 | + }, i18n('+ Join Pub')), | |
120 | 118 | when(loading, [ h("Loading") ], [ |
121 | - when(computed(channels, x => x.length), h('h2', i18n.__("Active Channels"))), | |
119 | + when(computed(channels, x => x.length), h('h2', i18n("Active Channels"))), | |
122 | 120 | h('div', { |
123 | 121 | classList: 'ChannelList', |
124 | 122 | hidden: loading |
125 | 123 | }, [ |
@@ -134,23 +132,23 @@ | ||
134 | 132 | h('span.name', '#' + channel), |
135 | 133 | when(subscribed, |
136 | 134 | h('a.-unsubscribe', { |
137 | 135 | 'ev-click': send(unsubscribe, channel) |
138 | - }, i18n.__('Unsubscribe')), | |
136 | + }, i18n('Unsubscribe')), | |
139 | 137 | h('a.-subscribe', { |
140 | 138 | 'ev-click': send(subscribe, channel) |
141 | - }, i18n.__('Subscribe')) | |
139 | + }, i18n('Subscribe')) | |
142 | 140 | ) |
143 | 141 | ]) |
144 | 142 | }, {maxTime: 5}), |
145 | - h('a.channel -more', {href: '/channels'}, i18n.__('More Channels...')) | |
143 | + h('a.channel -more', {href: '/channels'}, i18n('More Channels...')) | |
146 | 144 | ]) |
147 | 145 | ]), |
148 | 146 | |
149 | - PeerList(localPeers, i18n.__('Local')), | |
150 | - PeerList(connectedPubs, i18n.__('Connected Pubs')), | |
147 | + PeerList(localPeers, i18n('Local')), | |
148 | + PeerList(connectedPubs, i18n('Connected Pubs')), | |
151 | 149 | |
152 | - when(computed(whoToFollow, x => x.length), h('h2', i18n.__('Who to follow'))), | |
150 | + when(computed(whoToFollow, x => x.length), h('h2', i18n('Who to follow'))), | |
153 | 151 | when(following.sync, |
154 | 152 | h('div', { |
155 | 153 | classList: 'ProfileList' |
156 | 154 | }, [ |
modules/page/html/render/search.js | ||
---|---|---|
@@ -6,20 +6,20 @@ | ||
6 | 6 | var Scroller = require('../../../../lib/scroller') |
7 | 7 | var nextStepper = require('../../../../lib/next-stepper') |
8 | 8 | var nest = require('depnest') |
9 | 9 | var Proxy = require('mutant/proxy') |
10 | -var appRoot = require('app-root-path') | |
11 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
12 | 10 | |
13 | 11 | exports.needs = nest({ |
14 | 12 | 'sbot.pull.stream': 'first', |
15 | 13 | 'keys.sync.id': 'first', |
16 | - 'message.html.render': 'first' | |
14 | + 'message.html.render': 'first', | |
15 | + 'intl.sync.i18n': 'first' | |
17 | 16 | }) |
18 | 17 | |
19 | 18 | exports.gives = nest('page.html.render') |
20 | 19 | |
21 | 20 | exports.create = function (api) { |
21 | + const i18n = api.intl.sync.i18n | |
22 | 22 | return nest('page.html.render', function channel (path) { |
23 | 23 | if (path[0] !== '?') return |
24 | 24 | |
25 | 25 | var queryStr = path.substr(1).trim() |
@@ -30,13 +30,13 @@ | ||
30 | 30 | var updates = Value(0) |
31 | 31 | var aborter = null |
32 | 32 | |
33 | 33 | const searchHeader = h('div', {className: 'PageHeading'}, [ |
34 | - h('h1', [h('strong', i18n.__('Search Results:')), ' ', query.join(' ')]) | |
34 | + h('h1', [h('strong', i18n('Search Results:')), ' ', query.join(' ')]) | |
35 | 35 | ]) |
36 | 36 | |
37 | 37 | var updateLoader = h('a Notifier -loader', { href: '#', 'ev-click': refresh }, [ |
38 | - 'Show ', h('strong', [updates]), ' ', plural(updates, i18n.__('update'), i18n.__('updates')) | |
38 | + 'Show ', h('strong', [updates]), ' ', plural(updates, i18n('update'), i18n('updates')) | |
39 | 39 | ]) |
40 | 40 | |
41 | 41 | var content = Proxy() |
42 | 42 | var container = h('Scroller', { |
@@ -50,9 +50,9 @@ | ||
50 | 50 | style: { |
51 | 51 | 'padding': '60px 0', |
52 | 52 | 'font-size': '150%' |
53 | 53 | } |
54 | - }, [h('strong', i18n.__('Search completed.')), ' ', count, ' ', plural(count, i18n.__('result found'), i18n.__('results found'))])) | |
54 | + }, [h('strong', i18n('Search completed.')), ' ', count, ' ', plural(count, i18n('result found'), i18n('results found'))])) | |
55 | 55 | ]) |
56 | 56 | ]) |
57 | 57 | ]) |
58 | 58 |
modules/page/html/render/settings.js | ||
---|---|---|
@@ -1,29 +1,33 @@ | ||
1 | 1 | var { h, computed } = require('mutant') |
2 | 2 | var nest = require('depnest') |
3 | 3 | var appRoot = require('app-root-path') |
4 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
5 | 4 | |
6 | 5 | var themeNames = Object.keys(require('../../../../styles')) |
7 | 6 | |
8 | 7 | exports.needs = nest({ |
9 | 8 | 'settings.obs.get': 'first', |
10 | 9 | 'settings.sync.set': 'first', |
10 | + 'intl.sync.locales': 'first', | |
11 | + 'intl.sync.i18n': 'first' | |
11 | 12 | }) |
12 | 13 | |
13 | 14 | exports.gives = nest('page.html.render') |
14 | 15 | |
15 | 16 | exports.create = function (api) { |
16 | 17 | return nest('page.html.render', function channel (path) { |
17 | 18 | if (path !== '/settings') return |
18 | - | |
19 | + const i18n = api.intl.sync.i18n | |
20 | + | |
19 | 21 | const currentTheme = api.settings.obs.get('patchwork.theme') |
22 | + const currentLang = api.settings.obs.get('patchwork.lang') | |
23 | + const langNames = api.intl.sync.locales() | |
20 | 24 | const filterFollowing = api.settings.obs.get('filters.following') |
21 | 25 | |
22 | 26 | var prepend = [ |
23 | 27 | h('PageHeading', [ |
24 | 28 | h('h1', [ |
25 | - h('strong', i18n.__('Settings')) | |
29 | + h('strong', i18n('Settings')) | |
26 | 30 | ]), |
27 | 31 | ]) |
28 | 32 | ] |
29 | 33 | |
@@ -31,9 +35,9 @@ | ||
31 | 35 | h('div.wrapper', [ |
32 | 36 | h('section.prepend', prepend), |
33 | 37 | h('section.content', [ |
34 | 38 | h('section', [ |
35 | - h('h2', i18n.__('Theme')), | |
39 | + h('h2', i18n('Theme')), | |
36 | 40 | computed(currentTheme, currentTheme => { |
37 | 41 | return themeNames.map(name => { |
38 | 42 | const style = currentTheme == name |
39 | 43 | ? { 'margin-right': '1rem', 'border-color': 'teal' } |
@@ -50,17 +54,34 @@ | ||
50 | 54 | themeNames.map(name => h('option', {value: name}, [name])) |
51 | 55 | ]) |
52 | 56 | ]), |
53 | 57 | h('section', [ |
54 | - h('h2', i18n.__('Filters')), | |
58 | + h('h2', i18n('Language')), | |
59 | + computed(currentLang, currentLang => { | |
60 | + return langNames.map(lang => { | |
61 | + const style = currentLang == lang | |
62 | + ? { 'margin-right': '1rem', 'border-color': 'teal' } | |
63 | + : { 'margin-right': '1rem' } | |
64 | + | |
65 | + return h('button', { | |
66 | + 'ev-click': () => api.settings.sync.set({ | |
67 | + patchwork: {lang: lang} | |
68 | + }), | |
69 | + style | |
70 | + }, lang) | |
71 | + }) | |
72 | + }) | |
73 | + ]), | |
74 | + h('section', [ | |
75 | + h('h2', i18n('Filters')), | |
55 | 76 | h('label', [ |
56 | 77 | h('input', { |
57 | 78 | type: 'checkbox', |
58 | 79 | checked: filterFollowing, |
59 | 80 | 'ev-change': (ev) => api.settings.sync.set({ |
60 | 81 | filters: {following: ev.target.checked} |
61 | 82 | }) |
62 | - }), i18n.__(' Hide following messages') | |
83 | + }), i18n(' Hide following messages') | |
63 | 84 | ]) |
64 | 85 | ]) |
65 | 86 | ]) |
66 | 87 | ]) |
modules/profile/sheet/edit.js | ||
---|---|---|
@@ -1,9 +1,7 @@ | ||
1 | 1 | var nest = require('depnest') |
2 | 2 | var extend = require('xtend') |
3 | 3 | var {Value, h, computed, when} = require('mutant') |
4 | -var appRoot = require('app-root-path') | |
5 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
6 | 4 | var fallbackImageUrl = 'data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==' |
7 | 5 | |
8 | 6 | exports.gives = nest('profile.sheet.edit') |
9 | 7 | |
@@ -17,12 +15,14 @@ | ||
17 | 15 | image: 'first', |
18 | 16 | color: 'first' |
19 | 17 | }, |
20 | 18 | 'blob.html.input': 'first', |
21 | - 'blob.sync.url': 'first' | |
19 | + 'blob.sync.url': 'first', | |
20 | + 'intl.sync.i18n': 'first', | |
22 | 21 | }) |
23 | 22 | |
24 | 23 | exports.create = function (api) { |
24 | + const i18n = api.intl.sync.i18n | |
25 | 25 | return nest('profile.sheet.edit', function () { |
26 | 26 | var id = api.keys.sync.id() |
27 | 27 | api.sheet.display(close => { |
28 | 28 | var currentName = api.about.obs.name(id) |
@@ -46,17 +46,17 @@ | ||
46 | 46 | h('h2', { |
47 | 47 | style: { |
48 | 48 | 'font-weight': 'normal' |
49 | 49 | } |
50 | - }, [i18n.__('Your Profile')]), | |
50 | + }, [i18n('Your Profile')]), | |
51 | 51 | h('ProfileEditor', [ |
52 | 52 | h('div.side', [ |
53 | 53 | h('ImageInput', [ |
54 | 54 | h('img', { |
55 | 55 | style: { 'background-color': api.about.obs.color(id) }, |
56 | 56 | src: computed(chosenImage, (id) => id ? api.blob.sync.url(id) : fallbackImageUrl) |
57 | 57 | }), |
58 | - h('span', ['🖼 ', i18n.__('Choose Profile Image...')]), | |
58 | + h('span', ['🖼 ', i18n('Choose Profile Image...')]), | |
59 | 59 | api.blob.html.input(file => { |
60 | 60 | chosenImage.set(file.link) |
61 | 61 | }, { |
62 | 62 | accept: 'image/*', |
@@ -65,13 +65,13 @@ | ||
65 | 65 | ]) |
66 | 66 | ]), |
67 | 67 | h('div.main', [ |
68 | 68 | h('input.name', { |
69 | - placeholder: i18n.__('Choose a name'), | |
69 | + placeholder: i18n('Choose a name'), | |
70 | 70 | hooks: [ValueHook(chosenName), FocusHook()] |
71 | 71 | }), |
72 | 72 | h('textarea.description', { |
73 | - placeholder: i18n.__('Describe yourself (if you want)'), | |
73 | + placeholder: i18n('Describe yourself (if you want)'), | |
74 | 74 | hooks: [ValueHook(chosenDescription)] |
75 | 75 | }) |
76 | 76 | ]) |
77 | 77 | ]) |
@@ -79,12 +79,12 @@ | ||
79 | 79 | footer: [ |
80 | 80 | h('button -save', { |
81 | 81 | 'ev-click': save, |
82 | 82 | 'disabled': publishing |
83 | - }, when(publishing, i18n.__('Publishing...'), i18n.__('Publish'))), | |
83 | + }, when(publishing, i18n('Publishing...'), i18n('Publish'))), | |
84 | 84 | h('button -cancel', { |
85 | 85 | 'ev-click': close |
86 | - }, i18n.__('Cancel')) | |
86 | + }, i18n('Cancel')) | |
87 | 87 | ] |
88 | 88 | } |
89 | 89 | |
90 | 90 | function save () { |
@@ -105,11 +105,11 @@ | ||
105 | 105 | if (err) { |
106 | 106 | publishing.set(false) |
107 | 107 | showDialog({ |
108 | 108 | type: 'error', |
109 | - title: i18n.__('Error'), | |
110 | - buttons: [i18n.__('OK')], | |
111 | - message: i18n.__('An error occurred while attempting to publish about message.'), | |
109 | + title: i18n('Error'), | |
110 | + buttons: [i18n('OK')], | |
111 | + message: i18n('An error occurred while attempting to publish about message.'), | |
112 | 112 | detail: err.message |
113 | 113 | }) |
114 | 114 | } else { |
115 | 115 | close() |
plugs/message/html/layout/default.js | ||
---|---|---|
@@ -1,9 +1,7 @@ | ||
1 | 1 | const { h, map, computed } = require('mutant') |
2 | 2 | var nest = require('depnest') |
3 | 3 | var ref = require('ssb-ref') |
4 | -var appRoot = require('app-root-path') | |
5 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
6 | 4 | |
7 | 5 | exports.needs = nest({ |
8 | 6 | 'profile.html.person': 'first', |
9 | 7 | 'message.obs.backlinks': 'first', |
@@ -15,14 +13,16 @@ | ||
15 | 13 | action: 'map', |
16 | 14 | timestamp: 'first', |
17 | 15 | backlinks: 'first' |
18 | 16 | }, |
19 | - 'about.html.image': 'first' | |
17 | + 'about.html.image': 'first', | |
18 | + 'intl.sync.i18n': 'first', | |
20 | 19 | }) |
21 | 20 | |
22 | 21 | exports.gives = nest('message.html.layout') |
23 | 22 | |
24 | 23 | exports.create = function (api) { |
24 | + const i18n = api.intl.sync.i18n | |
25 | 25 | return nest('message.html.layout', layout) |
26 | 26 | |
27 | 27 | function layout (msg, {layout, previousId, priority, content, includeReferences = false}) { |
28 | 28 | if (!(layout === undefined || layout === 'default')) return |
@@ -34,13 +34,13 @@ | ||
34 | 34 | classList.push('-reply') |
35 | 35 | var branch = msg.value.content.branch |
36 | 36 | if (branch) { |
37 | 37 | if (!previousId || (previousId && last(branch) && previousId !== last(branch))) { |
38 | - replyInfo = h('span', [i18n.__('in reply to '), api.message.html.link(last(branch))]) | |
38 | + replyInfo = h('span', [i18n('in reply to '), api.message.html.link(last(branch))]) | |
39 | 39 | } |
40 | 40 | } |
41 | 41 | } else if (msg.value.content.project) { |
42 | - replyInfo = h('span', [i18n.__('on '), api.message.html.link(msg.value.content.project)]) | |
42 | + replyInfo = h('span', [i18n('on '), api.message.html.link(msg.value.content.project)]) | |
43 | 43 | } |
44 | 44 | |
45 | 45 | if (priority === 2) { |
46 | 46 | classList.push('-new') |
@@ -67,9 +67,9 @@ | ||
67 | 67 | |
68 | 68 | function messageHeader (msg, {replyInfo, priority}) { |
69 | 69 | var additionalMeta = [] |
70 | 70 | if (priority >= 2) { |
71 | - additionalMeta.push(h('span.flag -new', {title: i18n.__('New Message')})) | |
71 | + additionalMeta.push(h('span.flag -new', {title: i18n('New Message')})) | |
72 | 72 | } |
73 | 73 | return h('header', [ |
74 | 74 | h('div.main', [ |
75 | 75 | h('a.avatar', {href: `${msg.value.author}`}, [ |
plugs/message/html/meta/likes.js | ||
---|---|---|
@@ -1,18 +1,17 @@ | ||
1 | 1 | var nest = require('depnest') |
2 | 2 | var { h, computed, map, send } = require('mutant') |
3 | 3 | |
4 | -var appRoot = require('app-root-path'); | |
5 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
6 | - | |
7 | 4 | exports.gives = nest('message.html.meta') |
8 | 5 | exports.needs = nest({ |
9 | 6 | 'message.obs.likes': 'first', |
10 | 7 | 'message.sheet.likes': 'first', |
11 | - 'about.obs.name': 'first' | |
8 | + 'about.obs.name': 'first', | |
9 | + 'intl.sync.i18n': 'first', | |
12 | 10 | }) |
13 | 11 | |
14 | 12 | exports.create = function (api) { |
13 | + const i18n = api.intl.sync.i18n | |
15 | 14 | return nest('message.html.meta', function likes (msg) { |
16 | 15 | if (msg.key) { |
17 | 16 | return computed(api.message.obs.likes(msg.key), likeCount) |
18 | 17 | } |
@@ -23,15 +22,15 @@ | ||
23 | 22 | return [' ', h('a.likes', { |
24 | 23 | title: names(likes), |
25 | 24 | href: '#', |
26 | 25 | 'ev-click': send(api.message.sheet.likes, likes) |
27 | - }, [`${likes.length} ${likes.length === 1 ? i18n.__('like') : i18n.__('likes')}`])] | |
26 | + }, [`${likes.length} ${likes.length === 1 ? i18n('like') : i18n('likes')}`])] | |
28 | 27 | } |
29 | 28 | } |
30 | 29 | |
31 | 30 | function names (ids) { |
32 | 31 | var items = map(ids, api.about.obs.name) |
33 | 32 | return computed([items], (names) => { |
34 | - return i18n.__('Liked by\n') + names.map((n) => `- ${n}`).join('\n') | |
33 | + return i18n('Liked by\n') + names.map((n) => `- ${n}`).join('\n') | |
35 | 34 | }) |
36 | 35 | } |
37 | 36 | } |
plugs/message/html/render/about.js | ||
---|---|---|
@@ -2,10 +2,8 @@ | ||
2 | 2 | var computed = require('mutant/computed') |
3 | 3 | var nest = require('depnest') |
4 | 4 | var extend = require('xtend') |
5 | 5 | var ref = require('ssb-ref') |
6 | -var appRoot = require('app-root-path'); | |
7 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
8 | 6 | |
9 | 7 | exports.needs = nest({ |
10 | 8 | 'message.html': { |
11 | 9 | decorate: 'reduce', |
@@ -14,14 +12,16 @@ | ||
14 | 12 | }, |
15 | 13 | 'keys.sync.id': 'first', |
16 | 14 | 'profile.html.person': 'first', |
17 | 15 | 'about.obs.name': 'first', |
18 | - 'blob.sync.url': 'first' | |
16 | + 'blob.sync.url': 'first', | |
17 | + 'intl.sync.i18n': 'first', | |
19 | 18 | }) |
20 | 19 | |
21 | 20 | exports.gives = nest('message.html.render') |
22 | 21 | |
23 | 22 | exports.create = function (api) { |
23 | + const i18n = api.intl.sync.i18n | |
24 | 24 | return nest('message.html.render', function about (msg, opts) { |
25 | 25 | if (msg.value.content.type !== 'about') return |
26 | 26 | if (!ref.isFeed(msg.value.content.about)) return |
27 | 27 | |
@@ -34,20 +34,20 @@ | ||
34 | 34 | if (c.name) { |
35 | 35 | var target = api.profile.html.person(c.about, c.name) |
36 | 36 | miniContent.push(computed([self, api.about.obs.name(c.about), c.name], (self, a, b) => { |
37 | 37 | if (self) { |
38 | - return [i18n.__('self identifies as "'), target, '"'] | |
38 | + return [i18n('self identifies as "'), target, '"'] | |
39 | 39 | } else if (a === b) { |
40 | - return [i18n.__('identified '), api.profile.html.person(c.about)] | |
40 | + return [i18n('identified '), api.profile.html.person(c.about)] | |
41 | 41 | } else { |
42 | - return [i18n.__('identifies '), api.profile.html.person(c.about), i18n.__(' as "'), target, '"'] | |
42 | + return [i18n('identifies '), api.profile.html.person(c.about), i18n(' as "'), target, '"'] | |
43 | 43 | } |
44 | 44 | })) |
45 | 45 | } |
46 | 46 | |
47 | 47 | if (c.image) { |
48 | 48 | if (!miniContent.length) { |
49 | - var imageAction = self ? i18n.__('self assigned a display image') : [i18n.__('assigned a display image to '), api.profile.html.person(c.about)] | |
49 | + var imageAction = self ? i18n('self assigned a display image') : [i18n('assigned a display image to '), api.profile.html.person(c.about)] | |
50 | 50 | miniContent.push(imageAction) |
51 | 51 | } |
52 | 52 | |
53 | 53 | content.push(h('a AboutImage', { |
@@ -71,9 +71,9 @@ | ||
71 | 71 | |
72 | 72 | if (c.description) { |
73 | 73 | elements.push(api.message.html.decorate(api.message.html.layout(msg, extend({ |
74 | 74 | showActions: true, |
75 | - miniContent: self ? i18n.__('self assigned a description') : [i18n.__('assigned a description to '), api.profile.html.person(c.about)], | |
75 | + miniContent: self ? i18n('self assigned a description') : [i18n('assigned a description to '), api.profile.html.person(c.about)], | |
76 | 76 | content: api.message.html.markdown(c.description), |
77 | 77 | layout: 'mini' |
78 | 78 | }, opts)), { msg })) |
79 | 79 | } |
plugs/message/html/render/channel.js | ||
---|---|---|
@@ -1,20 +1,20 @@ | ||
1 | 1 | var h = require('mutant/h') |
2 | 2 | var nest = require('depnest') |
3 | 3 | var extend = require('xtend') |
4 | -var appRoot = require('app-root-path'); | |
5 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
6 | 4 | |
7 | 5 | exports.needs = nest({ |
8 | 6 | 'message.html': { |
9 | 7 | decorate: 'reduce', |
10 | 8 | layout: 'first' |
11 | - } | |
9 | + }, | |
10 | + 'intl.sync.i18n':'first', | |
12 | 11 | }) |
13 | 12 | |
14 | 13 | exports.gives = nest('message.html.render') |
15 | 14 | |
16 | 15 | exports.create = function (api) { |
16 | + const i18n = api.intl.sync.i18n | |
17 | 17 | return nest('message.html.render', function renderMessage (msg, opts) { |
18 | 18 | if (msg.value.content.type !== 'channel') return |
19 | 19 | var element = api.message.html.layout(msg, extend({ |
20 | 20 | miniContent: messageContent(msg), |
@@ -27,9 +27,9 @@ | ||
27 | 27 | function messageContent (msg) { |
28 | 28 | var channel = `#${msg.value.content.channel}` |
29 | 29 | var subscribed = msg.value.content.subscribed |
30 | 30 | return [ |
31 | - subscribed ? i18n.__('subscribed to ') : i18n.__('unsubscribed from '), | |
31 | + subscribed ? i18n('subscribed to ') : i18n('unsubscribed from '), | |
32 | 32 | h('a', {href: channel}, channel) |
33 | 33 | ] |
34 | 34 | } |
35 | 35 | } |
plugs/message/html/render/following.js | ||
---|---|---|
@@ -1,22 +1,22 @@ | ||
1 | 1 | var h = require('mutant/h') |
2 | 2 | var nest = require('depnest') |
3 | 3 | var extend = require('xtend') |
4 | 4 | var ref = require('ssb-ref') |
5 | -var appRoot = require('app-root-path'); | |
6 | -var i18n = require(appRoot + '/lib/i18n').i18n | |
7 | 5 | |
8 | 6 | exports.needs = nest({ |
9 | 7 | 'message.html': { |
10 | 8 | decorate: 'reduce', |
11 | 9 | layout: 'first' |
12 | 10 | }, |
13 | - 'profile.html.person': 'first' | |
11 | + 'profile.html.person': 'first', | |
12 | + 'intl.sync.i18n': 'first', | |
14 | 13 | }) |
15 | 14 | |
16 | 15 | exports.gives = nest('message.html.render') |
17 | 16 | |
18 | 17 | exports.create = function (api) { |
18 | + const i18n = api.intl.sync.i18n | |
19 | 19 | return nest('message.html.render', function renderMessage (msg, opts) { |
20 | 20 | if (msg.value.content.type !== 'contact') return |
21 | 21 | if (!ref.isFeed(msg.value.content.contact)) return |
22 | 22 | if (typeof msg.value.content.following !== 'boolean') return |
@@ -31,9 +31,9 @@ | ||
31 | 31 | |
32 | 32 | function messageContent (msg) { |
33 | 33 | var following = msg.value.content.following |
34 | 34 | return [ |
35 | - following ? i18n.__('followed ') : i18n.__('unfollowed '), | |
35 | + following ? i18n('followed ') : i18n('unfollowed '), | |
36 | 36 | api.profile.html.person(msg.value.content.contact) |
37 | 37 | ] |
38 | 38 | } |
39 | 39 | } |
Built with git-ssb-web