git ssb

10+

Matt McKegg / patchwork



Commit 77e7fa628b43035fa4c24ea1a9eb35529874721d

Change global i18n to a depject approach

Marcos Gutierrez committed on 9/29/2017, 2:26:15 PM
Parent: d245481b81b4075ba2a29823d0441ec941545a32

Files changed

index.jschanged
lib/window.jschanged
main-window.jschanged
modules/app/html/progress-notifier.jschanged
modules/app/html/search.jschanged
modules/feed/html/rollup.jschanged
modules/gathering/sheet/edit.jschanged
modules/invite/sheet.jschanged
modules/message/async/publish.jschanged
modules/message/html/backlinks.jschanged
modules/message/html/compose.jschanged
modules/message/sheet/likes.jschanged
modules/page/html/render/all.jschanged
modules/page/html/render/channel.jschanged
modules/page/html/render/channels.jschanged
modules/page/html/render/gatherings.jschanged
modules/page/html/render/message.jschanged
modules/page/html/render/private.jschanged
modules/page/html/render/profile.jschanged
modules/page/html/render/public.jschanged
modules/page/html/render/search.jschanged
modules/page/html/render/settings.jschanged
modules/profile/sheet/edit.jschanged
plugs/message/html/layout/default.jschanged
plugs/message/html/meta/likes.jschanged
plugs/message/html/render/about.jschanged
plugs/message/html/render/channel.jschanged
plugs/message/html/render/following.jschanged
index.jsView
@@ -2,10 +2,8 @@
22 console.log(err)
33 process.exit()
44 })
55
6-var i18n = require('./lib/i18n').i18n
7-
86 var electron = require('electron')
97 var openWindow = require('./lib/window')
108
119 var Path = require('path')
@@ -82,9 +80,9 @@
8280 width: windowState.width,
8381 height: windowState.height,
8482 titleBarStyle: 'hidden-inset',
8583 autoHideMenuBar: true,
86- title: i18n.__("Patchwork"),
84+ title: "Patchwork",
8785 show: true,
8886 backgroundColor: '#EEE',
8987 webPreferences: {
9088 experimentalFeatures: true
lib/window.jsView
@@ -18,9 +18,9 @@
1818 electron.webFrame.setZoomLevelLimits(1, 1)
1919
2020 var config = ${JSON.stringify(config)}
2121 var data = ${JSON.stringify(opts.data)}
22- var title = ${JSON.stringify(opts.title || i18n.__("Patchwork"))}
22+ var title = ${JSON.stringify(opts.title || "Patchwork" )}
2323
2424 document.documentElement.querySelector('head').appendChild(
2525 h('title', title)
2626 )
main-window.jsView
@@ -11,9 +11,8 @@
1111 var LatestUpdate = require('./lib/latest-update')
1212 var ref = require('ssb-ref')
1313 var setupContextMenuAndSpellCheck = require('./lib/context-menu-and-spellcheck')
1414 var watch = require('mutant/watch')
15-var i18n = require('./lib/i18n').i18n
1615
1716
1817 module.exports = function (config) {
1918 var sockets = combine(
@@ -41,16 +40,19 @@
4140 'profile.sheet.edit': 'first',
4241 'app.navigate': 'first',
4342 'channel.obs.subscribed': 'first',
4443 'settings.obs.get': 'first',
44+ 'intl.sync.i18n': 'first',
4545 }))
4646
4747 setupContextMenuAndSpellCheck(api.config.sync.load())
48+
49+ const i18n = api.intl.sync.i18n
4850
4951 var id = api.keys.sync.id()
5052 var latestUpdate = LatestUpdate()
5153 var subscribedChannels = api.channel.obs.subscribed(id)
52-
54+
5355 // prompt to setup profile on first use
5456 onceTrue(api.sbot.obs.connection, (sbot) => {
5557 sbot.latestSequence(sbot.id, (_, key) => {
5658 if (key == null) {
@@ -92,32 +94,32 @@
9294 classList: [ when(views.canGoForward, '-active') ]
9395 })
9496 ]),
9597 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'), [
99101 getSubscribedChannelMenu,
100- [i18n.__('Gatherings'), '/gatherings'],
101- [i18n.__('Extended Network'), '/all'],
102+ [i18n('Gatherings'), '/gatherings'],
103+ [i18n('Extended Network'), '/all'],
102104 {separator: true},
103- [i18n.__('Settings'), '/settings']
105+ [i18n('Settings'), '/settings']
104106 ])
105107 ]),
106108 h('span.appTitle', [
107- h('span.title', i18n.__("Patchwork")),
109+ h('span.title', i18n("Patchwork")),
108110 api.app.html.progressNotifier()
109111 ]),
110112 h('span', [ api.app.html.search(api.app.navigate) ]),
111113 h('span.nav', [
112- tab(i18n.__('Profile'), id),
113- tab(i18n.__('Mentions'), '/mentions')
114+ tab(i18n('Profile'), id),
115+ tab(i18n('Mentions'), '/mentions')
114116 ])
115117 ]),
116118 when(latestUpdate,
117119 h('div.info', [
118120 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!'),
120122 h('a.ignore', {'ev-click': latestUpdate.ignore}, 'X')
121123 ])
122124 ])
123125 ),
@@ -151,11 +153,11 @@
151153 var channels = Array.from(subscribedChannels()).sort(localeCompare)
152154
153155 if (channels.length) {
154156 return {
155- label: i18n.__('Channels'),
157+ label: i18n('Channels'),
156158 submenu: [
157- { label: i18n.__('Browse All'),
159+ { label: i18n('Browse All'),
158160 click () {
159161 setView('/channels')
160162 }
161163 },
@@ -170,9 +172,9 @@
170172 }))
171173 }
172174 } else {
173175 return {
174- label: i18n.__('Browse Channels'),
176+ label: i18n('Browse Channels'),
175177 click () {
176178 setView('/channels')
177179 }
178180 }
modules/app/html/progress-notifier.jsView
@@ -1,9 +1,8 @@
11 var {computed, when, h, Value} = require('mutant')
22 var nest = require('depnest')
33 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')
65
76 exports.gives = nest('app.html.progressNotifier')
87
98 exports.needs = nest({
@@ -12,12 +11,14 @@
1211 'progress.obs': {
1312 indexes: 'first',
1413 replicate: 'first',
1514 migration: 'first'
16- }
15+ },
16+ 'intl.sync.i18n':'first'
1717 })
1818
1919 exports.create = function (api) {
20+ const i18n = api.intl.sync.i18n
2021 return nest('app.html.progressNotifier', function (id) {
2122 var replicateProgress = api.progress.obs.replicate()
2223 var indexes = api.progress.obs.indexes()
2324 var migration = api.progress.obs.migration()
@@ -47,14 +48,14 @@
4748 return h('div.info', { hidden }, [
4849 h('div.status', [
4950 when(displaying, h('Loading -small', [
5051 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 })],
5253 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 })],
5455 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...'))
5758 )
5859 )
5960 ]))
6061 ])
modules/app/html/search.jsView
@@ -2,27 +2,27 @@
22 var nest = require('depnest')
33 var addSuggest = require('suggest-box')
44
55 var appRoot = require('app-root-path');
6-var i18n = require(appRoot + '/lib/i18n').i18n
76
8-
97 exports.needs = nest({
108 'profile.async.suggest': 'first',
11- 'channel.async.suggest': 'first'
9+ 'channel.async.suggest': 'first',
10+ 'intl.sync.i18n': 'first'
1211 })
1312
1413 exports.gives = nest('app.html.search')
1514
1615 var pages = ['/public', '/private', '/mentions', '/all', '/gatherings']
1716
1817 exports.create = function (api) {
18+ const i18n = api.intl.sync.i18n
1919 return nest('app.html.search', function (setView) {
2020 var getProfileSuggestions = api.profile.async.suggest()
2121 var getChannelSuggestions = api.channel.async.suggest()
2222 var searchBox = h('input.search', {
2323 type: 'search',
24- placeholder: i18n.__('word, @key, #channel'),
24+ placeholder: i18n('word, @key, #channel'),
2525 'ev-suggestselect': (ev) => {
2626 setView(ev.detail.id)
2727 searchBox.value = ev.detail.id
2828 },
modules/feed/html/rollup.jsView
@@ -6,17 +6,14 @@
66 var nextStepper = require('../../../lib/next-stepper')
77 var extend = require('xtend')
88 var paramap = require('pull-paramap')
99
10-var appRoot = require('app-root-path');
11-var i18n = require(appRoot + '/lib/i18n').i18n
12-
1310 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'
1916 }
2017
2118 // bump even for first message
2219 var rootBumpTypes = ['mention', 'channel-mention']
@@ -30,16 +27,18 @@
3027 'message.html.link': 'first',
3128 'message.sync.root': 'first',
3229 'feed.pull.rollup': 'first',
3330 'sbot.async.get': 'first',
34- 'keys.sync.id': 'first'
31+ 'keys.sync.id': 'first',
32+ 'intl.sync.i18n': 'first',
3533 })
3634
3735 exports.gives = nest({
3836 'feed.html.rollup': true
3937 })
4038
4139 exports.create = function (api) {
40+ const i18n = api.intl.sync.i18n
4241 return nest('feed.html.rollup', function (getStream, {
4342 prepend,
4443 rootFilter = returnTrue,
4544 bumpFilter = returnTrue,
@@ -50,9 +49,9 @@
5049 var updates = Value(0)
5150 var yourId = api.keys.sync.id()
5251 var throttledUpdates = throttle(updates, 200)
5352 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'))
5554 ])
5655
5756 var abortLastFeed = null
5857 var content = Value()
@@ -194,11 +193,11 @@
194193 var bumps = lastBumpType === 'vote'
195194 ? getLikeAuthors(groupedBumps[lastBumpType])
196195 : getAuthors(groupedBumps[lastBumpType])
197196
198- var description = bumpMessages[lastBumpType] || 'added changes'
197+ var description = i18n(bumpMessages[lastBumpType] || 'added changes')
199198 meta = h('div.meta', { title: names(bumps) }, [
200- many(bumps, api.profile.html.person), ' ', description
199+ many(bumps, api.profile.html.person, i18n), ' ', description
201200 ])
202201 }
203202
204203 return h('FeedEvent -post', {
@@ -209,9 +208,9 @@
209208 meta,
210209 renderedMessage,
211210 when(replyElements.length, [
212211 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, ')'])
214213 ),
215214 h('div.replies', replyElements)
216215 ])
217216 ])
@@ -248,36 +247,36 @@
248247 }
249248 })
250249 }
251250
252-function many (ids, fn) {
251+function many (ids, fn, intl) {
253252 ids = Array.from(ids)
254253 var featuredIds = ids.slice(0, 4)
255254
256255 if (ids.length) {
257256 if (ids.length > 4) {
258257 return [
259258 fn(featuredIds[0]), ', ',
260259 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'),
263262 ]
264263 } else if (ids.length === 4) {
265264 return [
266265 fn(featuredIds[0]), ', ',
267266 fn(featuredIds[1]), ', ',
268- fn(featuredIds[2]), i18n.__(' and '),
267+ fn(featuredIds[2]), intl(' and '),
269268 fn(featuredIds[3])
270269 ]
271270 } else if (ids.length === 3) {
272271 return [
273272 fn(featuredIds[0]), ', ',
274- fn(featuredIds[1]), i18n.__(' and '),
273+ fn(featuredIds[1]), intl(' and '),
275274 fn(featuredIds[2])
276275 ]
277276 } else if (ids.length === 2) {
278277 return [
279- fn(featuredIds[0]), i18n.__(' and '),
278+ fn(featuredIds[0]), intl(' and '),
280279 fn(featuredIds[1])
281280 ]
282281 } else {
283282 return fn(featuredIds[0])
modules/gathering/sheet/edit.jsView
@@ -1,10 +1,8 @@
11 var nest = require('depnest')
22 var extend = require('xtend')
33 var Pickr = require('flatpickr')
44 var spacetime = require('spacetime')
5-var appRoot = require('app-root-path');
6-var i18n = require(appRoot + '/lib/i18n').i18n
75
86 var {Value, h, computed, when} = require('mutant')
97
108 exports.gives = nest('gathering.sheet.edit')
@@ -14,12 +12,14 @@
1412 'keys.sync.id': 'first',
1513 'sbot.async.publish': 'first',
1614 'about.obs.latestValue': 'first',
1715 'blob.html.input': 'first',
18- 'blob.sync.url': 'first'
16+ 'blob.sync.url': 'first',
17+ 'intl.sync.i18n': 'first',
1918 })
2019
2120 exports.create = function (api) {
21+ const i18n = api.intl.sync.i18n
2222 return nest('gathering.sheet.edit', function (id) {
2323 api.sheet.display(close => {
2424 var current = id ? {
2525 title: api.about.obs.latestValue(id, 'title'),
@@ -54,44 +54,44 @@
5454 h('h2', {
5555 style: {
5656 'font-weight': 'normal'
5757 }
58- }, [id ? i18n.__('Edit') : i18n.__('Create'), i18n.__(' Gathering')]),
58+ }, [id ? i18n('Edit') : i18n('Create'), i18n(' Gathering')]),
5959 h('GatheringEditor', [
6060 h('input.title', {
61- placeholder: i18n.__('Choose a title'),
61+ placeholder: i18n('Choose a title'),
6262 hooks: [ValueHook(chosen.title), FocusHook()]
6363 }),
6464 h('input.date', {
65- placeholder: i18n.__('Choose date and time'),
65+ placeholder: i18n('Choose date and time'),
6666 hooks: [
6767 PickrHook(chosen.startDateTime)
6868 ]
6969 }),
7070 h('ImageInput .banner', {
7171 style: { 'background-image': computed(imageUrl, x => `url(${x})`) }
7272 }, [
73- h('span', ['🖼 ', i18n.__('Choose Banner Image...')]),
73+ h('span', ['🖼 ', i18n('Choose Banner Image...')]),
7474 api.blob.html.input(file => {
7575 chosen.image.set(file)
7676 }, {
7777 accept: 'image/*'
7878 })
7979 ]),
8080 h('textarea.description', {
81- placeholder: i18n.__('Describe the gathering (if you want)'),
81+ placeholder: i18n('Describe the gathering (if you want)'),
8282 hooks: [ValueHook(chosen.description)]
8383 })
8484 ])
8585 ]),
8686 footer: [
8787 h('button -save', {
8888 'ev-click': save,
8989 'disabled': publishing
90- }, when(publishing, i18n.__('Publishing...'), i18n.__('Publish'))),
90+ }, when(publishing, i18n('Publishing...'), i18n('Publish'))),
9191 h('button -cancel', {
9292 'ev-click': close
93- }, i18n.__('Cancel'))
93+ }, i18n('Cancel'))
9494 ]
9595 }
9696
9797 function ensureExists (cb) {
@@ -112,9 +112,9 @@
112112 var update = {}
113113
114114 if (!compareImage(chosen.image(), current.image())) update.image = chosen.image()
115115 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')
117117 if (chosen.description() !== current.description()) update.description = chosen.description()
118118
119119 if (Object.keys(update).length) {
120120 publishing.set(true)
@@ -127,11 +127,11 @@
127127 if (err) {
128128 publishing.set(false)
129129 showDialog({
130130 type: 'error',
131- title: i18n.__('Error'),
131+ title: i18n('Error'),
132132 buttons: ['OK'],
133- message: i18n.__('An error occurred while attempting to publish gathering.'),
133+ message: i18n('An error occurred while attempting to publish gathering.'),
134134 detail: err.message
135135 })
136136 } else {
137137 close()
modules/invite/sheet.jsView
@@ -1,19 +1,18 @@
11 var {h, when, Value, Proxy} = require('mutant')
22 var nest = require('depnest')
33 var electron = require('electron')
44
5-var appRoot = require('app-root-path');
6-var i18n = require(appRoot + '/lib/i18n').i18n
7-
85 exports.needs = nest({
96 'sheet.display': 'first',
10- 'invite.async.accept': 'first'
7+ 'invite.async.accept': 'first',
8+ 'intl.sync.i18n': 'first',
119 })
1210
1311 exports.gives = nest('invite.sheet')
1412
1513 exports.create = function (api) {
14+ const i18n = api.intl.sync.i18n
1615 return nest('invite.sheet', function () {
1716 api.sheet.display(close => {
1817 var publishing = Value()
1918 var publishStatus = Proxy()
@@ -23,9 +22,9 @@
2322 'font-size': '200%',
2423 'margin-top': '20px',
2524 'width': '100%'
2625 },
27- placeholder: i18n.__('paste invite code here')
26+ placeholder: i18n('paste invite code here')
2827 })
2928 setTimeout(() => {
3029 input.focus()
3130 input.select()
@@ -39,11 +38,11 @@
3938 h('h2', {
4039 style: {
4140 'font-weight': 'normal'
4241 }
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.')]),
4443 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.')
4645 ]),
4746 input
4847 ]),
4948 footer: [
@@ -55,22 +54,22 @@
5554 if (err) {
5655 publishing.set(false)
5756 showDialog({
5857 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.'),
6261 detail: err.message
6362 })
6463 } else {
6564 close()
6665 }
6766 }))
6867 }
69- }, [ when(publishing, publishStatus, i18n.__('Redeem Invite')) ]),
68+ }, [ when(publishing, publishStatus, i18n('Redeem Invite')) ]),
7069 h('button -cancel', {
7170 'ev-click': close
72- }, i18n.__('Cancel'))
71+ }, i18n('Cancel'))
7372 ]
7473 }
7574 })
7675 })
modules/message/async/publish.jsView
@@ -1,21 +1,19 @@
11 var h = require('mutant/h')
22 var nest = require('depnest')
3-var i18n = require('i18n')
43
5-var appRoot = require('app-root-path')
6-var i18n = require(appRoot + '/lib/i18n').i18n
7-
84 exports.needs = nest({
95 'sheet.display': 'first',
106 'message.html.render': 'first',
117 'sbot.async.publish': 'first',
12- 'keys.sync.id': 'first'
8+ 'keys.sync.id': 'first',
9+ 'intl.sync.i18n': 'first',
1310 })
1411
1512 exports.gives = nest('message.async.publish')
1613
1714 exports.create = function (api) {
15+ const i18n = api.intl.sync.i18n
1816 return nest('message.async.publish', function (content, cb) {
1917 api.sheet.display(function (close) {
2018 return {
2119 content: [
@@ -25,10 +23,10 @@
2523 author: api.keys.sync.id()
2624 }})
2725 ],
2826 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'))
3129 ]
3230 }
3331
3432 function publish () {
modules/message/html/backlinks.jsView
@@ -1,22 +1,22 @@
11 var nest = require('depnest')
22 var ref = require('ssb-ref')
33 var { h, map, computed } = require('mutant')
4-var appRoot = require('app-root-path')
5-var i18n = require(appRoot + '/lib/i18n').i18n
64
75 exports.needs = nest({
86 'message.obs': {
97 backlinks: 'first',
108 name: 'first',
119 author: 'first'
1210 },
13- 'profile.html.person': 'first'
11+ 'profile.html.person': 'first',
12+ 'intl.sync.i18n': 'first',
1413 })
1514
1615 exports.gives = nest('message.html.backlinks')
1716
1817 exports.create = function (api) {
18+ const i18n = api.intl.sync.i18n
1919 return nest('message.html.backlinks', function (msg, {includeReferences = true, includeForks = true} = {}) {
2020 if (!ref.type(msg.key)) return []
2121 var backlinks = api.message.obs.backlinks(msg.key)
2222 var references = includeReferences ? computed([backlinks, msg], onlyReferences) : []
@@ -26,9 +26,9 @@
2626 return h('a.backlink', {
2727 href: link.id, title: link.id
2828 }, [
2929 h('strong', [
30- api.profile.html.person(link.author), i18n.__(' forked this discussion:')
30+ api.profile.html.person(link.author), i18n(' forked this discussion:')
3131 ]), ' ',
3232 api.message.obs.name(link.id)
3333 ])
3434 }),
@@ -36,9 +36,9 @@
3636 return h('a.backlink', {
3737 href: link.id, title: link.id
3838 }, [
3939 h('strong', [
40- api.profile.html.person(link.author), i18n.__(' referenced this message:')
40+ api.profile.html.person(link.author), i18n(' referenced this message:')
4141 ]), ' ',
4242 api.message.obs.name(link.id)
4343 ])
4444 })
modules/message/html/compose.jsView
@@ -8,23 +8,22 @@
88 var mentions = require('ssb-mentions')
99 var extend = require('xtend')
1010 var addSuggest = require('suggest-box')
1111
12-var appRoot = require('app-root-path');
13-var i18n = require(appRoot + '/lib/i18n').i18n
14-
1512 exports.needs = nest({
1613 'blob.html.input': 'first',
1714 'profile.async.suggest': 'first',
1815 'channel.async.suggest': 'first',
1916 'message.async.publish': 'first',
2017 'emoji.sync.names': 'first',
21- 'emoji.sync.url': 'first'
18+ 'emoji.sync.url': 'first',
19+ 'intl.sync.i18n': 'first',
2220 })
2321
2422 exports.gives = nest('message.html.compose')
2523
2624 exports.create = function (api) {
25+ const i18n = api.intl.sync.i18n
2726 return nest('message.html.compose', function ({shrink = true, meta, prepublish, placeholder = 'Write a message'}, cb) {
2827 var files = []
2928 var filesById = {}
3029 var focused = Value(false)
@@ -98,9 +97,9 @@
9897
9998 var publishBtn = h('button', {
10099 'ev-click': publish,
101100 disabled: publishing
102- }, when(publishing, i18n.__('Publishing...'), i18n.__('Publish')))
101+ }, when(publishing, i18n('Publishing...'), i18n('Publish')))
103102
104103 var actions = h('section.actions', [
105104 fileInput,
106105 publishBtn
modules/message/sheet/likes.jsView
@@ -1,32 +1,31 @@
11 var {h, when, map, computed} = require('mutant')
22 var nest = require('depnest')
33 var catchLinks = require('../../../lib/catch-links')
44
5-var appRoot = require('app-root-path');
6-var i18n = require(appRoot + '/lib/i18n').i18n
7-
85 exports.needs = nest({
96 'sheet.display': 'first',
107 'keys.sync.id': 'first',
118 'contact.obs.following': 'first',
129 'profile.obs.rank': 'first',
1310 'about.html.image': 'first',
1411 'about.obs.name': 'first',
15- 'app.navigate': 'first'
12+ 'app.navigate': 'first',
13+ 'intl.sync.i18n': 'first',
1614 })
1715
1816 exports.gives = nest('message.sheet.likes')
1917
2018 exports.create = function (api) {
19+ const i18n = api.intl.sync.i18n
2120 return nest('message.sheet.likes', function (ids) {
2221 api.sheet.display(close => {
2322 var content = h('div', {
2423 style: { padding: '20px' }
2524 }, [
2625 h('h2', {
2726 style: { 'font-weight': 'normal' }
28- }, [i18n.__('Liked by')]),
27+ }, [i18n('Liked by')]),
2928 renderContactBlock(ids)
3029 ])
3130
3231 catchLinks(content, (href, external) => {
@@ -40,9 +39,9 @@
4039 content,
4140 footer: [
4241 h('button -close', {
4342 'ev-click': close
44- }, i18n.__('Close'))
43+ }, i18n('Close'))
4544 ]
4645 }
4746 })
4847 })
modules/page/html/render/all.jsView
@@ -1,34 +1,34 @@
11 var nest = require('depnest')
22 var { h } = require('mutant')
3-var appRoot = require('app-root-path')
4-var i18n = require(appRoot + '/lib/i18n').i18n
53
64 exports.needs = nest({
75 'feed.pull.public': 'first',
86 'message.html.compose': 'first',
97 'message.async.publish': 'first',
10- 'feed.html.rollup': 'first'
8+ 'feed.html.rollup': 'first',
9+ 'intl.sync.i18n': 'first',
1110 })
1211
1312 exports.gives = nest({
1413 'page.html.render': true
1514 })
1615
1716 exports.create = function (api) {
17+ const i18n = api.intl.sync.i18n
1818 return nest('page.html.render', page)
1919
2020 function page (path) {
2121 if (path !== '/all') return // "/" is a sigil for "page"
2222
2323 var prepend = [
2424 h('PageHeading', [
2525 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'))
2828 ])
2929 ]),
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') })
3131 ]
3232
3333 var feedView = api.feed.html.rollup(api.feed.pull.public, {
3434 bumpFilter: (msg) => {
modules/page/html/render/channel.jsView
@@ -1,22 +1,22 @@
11 var { h, when, send } = require('mutant')
22 var nest = require('depnest')
3-var appRoot = require('app-root-path')
4-var i18n = require(appRoot + '/lib/i18n').i18n
53
64 exports.needs = nest({
75 'channel.obs.subscribed': 'first',
86 'message.html.compose': 'first',
97 'feed.html.rollup': 'first',
108 'feed.pull.channel': 'first',
119 'sbot.pull.log': 'first',
1210 'message.async.publish': 'first',
13- 'keys.sync.id': 'first'
11+ 'keys.sync.id': 'first',
12+ 'intl.sync.i18n': 'first',
1413 })
1514
1615 exports.gives = nest('page.html.render')
1716
1817 exports.create = function (api) {
18+ const i18n = api.intl.sync.i18n
1919 return nest('page.html.render', function channel (path) {
2020 if (path[0] !== '#') return
2121
2222 var channel = path.substr(1)
@@ -28,21 +28,21 @@
2828 h('div.meta', [
2929 when(subscribedChannels.has(channel),
3030 h('a.ToggleButton.-unsubscribe', {
3131 'href': '#',
32- 'title': i18n.__('Click to unsubscribe'),
32+ 'title': i18n('Click to unsubscribe'),
3333 'ev-click': send(unsubscribe, channel)
34- }, i18n.__('Subscribed')),
34+ }, i18n('Subscribed')),
3535 h('a.ToggleButton.-subscribe', {
3636 'href': '#',
3737 'ev-click': send(subscribe, channel)
38- }, i18n.__('Subscribe'))
38+ }, i18n('Subscribe'))
3939 )
4040 ])
4141 ]),
4242 api.message.html.compose({
4343 meta: {type: 'post', channel},
44- placeholder: i18n.__('Write a message in this channel')
44+ placeholder: i18n('Write a message in this channel')
4545 })
4646 ]
4747
4848 return api.feed.html.rollup(api.feed.pull.channel(channel), {
modules/page/html/render/channels.jsView
@@ -1,21 +1,21 @@
11 var nest = require('depnest')
22 var { h, send, when, computed, map } = require('mutant')
3-var appRoot = require('app-root-path')
4-var i18n = require(appRoot + '/lib/i18n').i18n
53
64 exports.needs = nest({
75 'message.async.publish': 'first',
86 'keys.sync.id': 'first',
97 'channel.obs': {
108 subscribed: 'first',
119 recent: 'first'
12- }
10+ },
11+ 'intl.sync.i18n': 'first'
1312 })
1413
1514 exports.gives = nest('page.html.render')
1615
1716 exports.create = function(api){
17+ const i18n = api.intl.sync.i18n
1818 return nest('page.html.render', function page(path){
1919 if (path !== '/channels') return
2020
2121 var id = api.keys.sync.id()
@@ -40,12 +40,12 @@
4040 h('span.name', '#' + channel),
4141 when(subscribed,
4242 h('a.-unsubscribe', {
4343 'ev-click': send(unsubscribe, channel)
44- }, i18n.__('Unsubscribe')),
44+ }, i18n('Unsubscribe')),
4545 h('a.-subscribe', {
4646 'ev-click': send(subscribe, channel)
47- }, i18n.__('Subscribe'))
47+ }, i18n('Subscribe'))
4848 )
4949 ])
5050 }, {maxTime: 5, idle: true})
5151 ])
modules/page/html/render/gatherings.jsView
@@ -1,35 +1,35 @@
11 var { h } = require('mutant')
22 var nest = require('depnest')
3-var appRoot = require('app-root-path')
4-var i18n = require(appRoot + '/lib/i18n').i18n
53
64 exports.needs = nest({
75 'feed.pull.type': 'first',
86 'feed.html.rollup': 'first',
97 'feed.pull.public': 'first',
108 'gathering.sheet.edit': 'first',
119 'keys.sync.id': 'first',
1210 'contact.obs.following': 'first',
13- 'sbot.pull.stream': 'first'
11+ 'sbot.pull.stream': 'first',
12+ 'intl.sync.i18n': 'first',
1413 })
1514
1615 exports.gives = nest('page.html.render')
1716
1817 exports.create = function (api) {
18+ const i18n = api.intl.sync.i18n
1919 return nest('page.html.render', function channel (path) {
2020 if (path !== '/gatherings') return
2121
2222 var id = api.keys.sync.id()
2323 var following = api.contact.obs.following(id)
2424
2525 var prepend = [
2626 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')]),
2828 h('div.meta', [
2929 h('button -add', {
3030 'ev-click': createGathering
31- }, i18n.__('+ Add Gathering'))
31+ }, i18n('+ Add Gathering'))
3232 ])
3333 ])
3434 ]
3535
modules/page/html/render/message.jsView
@@ -1,25 +1,24 @@
11 var { h, when, map, Proxy, Struct, Value, computed } = require('mutant')
22 var nest = require('depnest')
33 var ref = require('ssb-ref')
44
5-var appRoot = require('app-root-path')
6-var i18n = require(appRoot + '/lib/i18n').i18n
7-
85 exports.needs = nest({
96 'keys.sync.id': 'first',
107 'feed.obs.thread': 'first',
118 'message.sync.unbox': 'first',
129 'message.html': {
1310 render: 'first',
1411 compose: 'first'
1512 },
16- 'sbot.async.get': 'first'
13+ 'sbot.async.get': 'first',
14+ 'intl.sync.i18n':'first',
1715 })
1816
1917 exports.gives = nest('page.html.render')
2018
2119 exports.create = function (api) {
20+ const i18n = api.intl.sync.i18n
2221 return nest('page.html.render', function (id) {
2322 if (!ref.isMsg(id)) return
2423 var loader = h('div', {className: 'Loading -large'})
2524
@@ -35,15 +34,15 @@
3534
3635 var compose = api.message.html.compose({
3736 meta,
3837 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'))
4039 })
4140
4241 api.sbot.async.get(id, (err, value) => {
4342 if (err) {
4443 return result.set(h('PageHeading', [
45- h('h1', i18n.__('Cannot load thead'))
44+ h('h1', i18n('Cannot load thead'))
4645 ]))
4746 }
4847
4948 if (typeof value.content === 'string') {
@@ -51,9 +50,9 @@
5150 }
5251
5352 if (!value) {
5453 return result.set(h('PageHeading', [
55- h('h1', i18n.__('Cannot display message.'))
54+ h('h1', i18n('Cannot display message.'))
5655 ]))
5756 }
5857
5958 // what happens in private stays in private!
@@ -69,9 +68,9 @@
6968 meta.branch.set(isReply ? thread.branchId : thread.lastId)
7069
7170 var container = h('Thread', [
7271 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')])),
7473 map(thread.messages, (msg) => {
7574 return computed([msg, thread.previousKey(msg)], (msg, previousId) => {
7675 return api.message.html.render(msg, {pageId: id, previousId, includeReferences: true})
7776 })
modules/page/html/render/private.jsView
@@ -1,19 +1,19 @@
11 var nest = require('depnest')
22 var ref = require('ssb-ref')
3-var appRoot = require('app-root-path')
4-var i18n = require(appRoot + '/lib/i18n').i18n
53
64 exports.needs = nest({
75 'feed.html.rollup': 'first',
86 'feed.pull.private': 'first',
97 'message.html.compose': 'first',
10- 'keys.sync.id': 'first'
8+ 'keys.sync.id': 'first',
9+ 'intl.sync.i18n': 'first',
1110 })
1211
1312 exports.gives = nest('page.html.render')
1413
1514 exports.create = function (api) {
15+ const i18n = api.intl.sync.i18n
1616 return nest('page.html.render', function channel (path) {
1717 if (path !== '/private') return
1818
1919 var id = api.keys.sync.id()
@@ -25,9 +25,9 @@
2525 return ref.isFeed(typeof e === 'string' ? e : e.link)
2626 })
2727 return msg
2828 },
29- placeholder: i18n.__('Write a private message')
29+ placeholder: i18n('Write a private message')
3030 })
3131 ]
3232
3333 return api.feed.html.rollup(api.feed.pull.private, { prepend })
modules/page/html/render/profile.jsView
@@ -1,10 +1,8 @@
11 var nest = require('depnest')
22 var ref = require('ssb-ref')
33 var {h, when, computed, map, send, dictToCollection, resolve} = require('mutant')
44 var extend = require('xtend')
5-var appRoot = require('app-root-path')
6-var i18n = require(appRoot + '/lib/i18n').i18n
75
86 exports.needs = nest({
97 'about.obs': {
108 name: 'first',
@@ -27,13 +25,15 @@
2725 'profile.sheet.edit': 'first',
2826 'contact.obs': {
2927 followers: 'first',
3028 following: 'first'
31- }
29+ },
30+ 'intl.sync.i18n': 'first',
3231 })
3332 exports.gives = nest('page.html.render')
3433
3534 exports.create = function (api) {
35+ const i18n = api.intl.sync.i18n
3636 return nest('page.html.render', function profile (id) {
3737 if (!ref.isFeed(id)) return
3838
3939 var name = api.about.obs.name(id)
@@ -85,9 +85,9 @@
8585 classList: [
8686 when(isSelf, '-self'),
8787 when(isAssigned, '-assigned')
8888 ],
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)
9090 }, [
9191 item.key
9292 ])
9393 }),
@@ -113,9 +113,9 @@
113113 classList: [
114114 when(isSelf, '-self'),
115115 when(isAssigned, '-assigned')
116116 ],
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)
118118 }, [
119119 h('img', {
120120 className: 'Avatar',
121121 style: { 'background-color': api.about.obs.color(id) },
@@ -139,20 +139,20 @@
139139 h('div.title', [
140140 h('h1', [name]),
141141 h('div.meta', [
142142 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'))
144144 ], [
145145 when(youFollow,
146146 h('a.ToggleButton.-unsubscribe', {
147147 'href': '#',
148- 'title': i18n.__('Click to unfollow'),
148+ 'title': i18n('Click to unfollow'),
149149 'ev-click': send(unfollow, id)
150- }, when(isFriends, i18n.__('Friends'), i18n.__('Following'))),
150+ }, when(isFriends, i18n('Friends'), i18n('Following'))),
151151 h('a.ToggleButton.-subscribe', {
152152 'href': '#',
153153 'ev-click': send(follow, id)
154- }, when(followsYou, i18n.__('Follow Back'), i18n.__('Follow')))
154+ }, when(followsYou, i18n('Follow Back'), i18n('Follow')))
155155 )
156156 ])
157157 ])
158158 ]),
@@ -179,11 +179,11 @@
179179 ]),
180180 h('div.side.-right', [
181181 when(friendsLoaded,
182182 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)
186186 ]),
187187 h('div', {className: 'Loading'})
188188 )
189189 ])
@@ -275,9 +275,9 @@
275275 h('h2', {
276276 style: {
277277 'font-weight': 'normal'
278278 }
279- }, [i18n.__('What whould you like to call '), h('strong', [currentName]), '?']),
279+ }, [i18n('What whould you like to call '), h('strong', [currentName]), '?']),
280280 input
281281 ]),
282282 footer: [
283283 h('button -save', {
@@ -291,12 +291,12 @@
291291 })
292292 }
293293 close()
294294 }
295- }, i18n.__('Confirm')),
295+ }, i18n('Confirm')),
296296 h('button -cancel', {
297297 'ev-click': close
298- }, i18n.__('Cancel'))
298+ }, i18n('Cancel'))
299299 ]
300300 }
301301 })
302302 }
modules/page/html/render/public.jsView
@@ -3,12 +3,8 @@
33 var pull = require('pull-stream')
44 var normalizeChannel = require('../../../../lib/normalize-channel')
55 var { h, send, when, computed, map } = require('mutant')
66
7-var appRoot = require('app-root-path');
8-var i18n = require(appRoot + '/lib/i18n').i18n
9-
10-
117 exports.needs = nest({
128 sbot: {
139 obs: {
1410 connectedPeers: 'first',
@@ -32,16 +28,18 @@
3228 subscribed: 'first',
3329 recent: 'first'
3430 },
3531 'keys.sync.id': 'first',
36- 'settings.obs.get': 'first'
32+ 'settings.obs.get': 'first',
33+ 'intl.sync.i18n': 'first',
3734 })
3835
3936 exports.gives = nest({
4037 'page.html.render': true
4138 })
4239
4340 exports.create = function (api) {
41+ const i18n = api.intl.sync.i18n
4442 return nest('page.html.render', page)
4543
4644 function page (path) {
4745 if (path !== '/public') return // "/" is a sigil for "page"
@@ -56,9 +54,9 @@
5654 var localPeers = api.sbot.obs.localPeers()
5755 var connectedPubs = computed([connectedPeers, localPeers], (c, l) => c.filter(x => !l.includes(x)))
5856
5957 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') })
6159 ]
6260
6361 var getStream = (opts) => {
6462 if (opts.lt != null && !opts.lt.marker) {
@@ -115,11 +113,11 @@
115113 })
116114 return [
117115 h('button -pub -full', {
118116 'ev-click': api.invite.sheet
119- }, i18n.__('+ Join Pub')),
117+ }, i18n('+ Join Pub')),
120118 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"))),
122120 h('div', {
123121 classList: 'ChannelList',
124122 hidden: loading
125123 }, [
@@ -134,23 +132,23 @@
134132 h('span.name', '#' + channel),
135133 when(subscribed,
136134 h('a.-unsubscribe', {
137135 'ev-click': send(unsubscribe, channel)
138- }, i18n.__('Unsubscribe')),
136+ }, i18n('Unsubscribe')),
139137 h('a.-subscribe', {
140138 'ev-click': send(subscribe, channel)
141- }, i18n.__('Subscribe'))
139+ }, i18n('Subscribe'))
142140 )
143141 ])
144142 }, {maxTime: 5}),
145- h('a.channel -more', {href: '/channels'}, i18n.__('More Channels...'))
143+ h('a.channel -more', {href: '/channels'}, i18n('More Channels...'))
146144 ])
147145 ]),
148146
149- PeerList(localPeers, i18n.__('Local')),
150- PeerList(connectedPubs, i18n.__('Connected Pubs')),
147+ PeerList(localPeers, i18n('Local')),
148+ PeerList(connectedPubs, i18n('Connected Pubs')),
151149
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'))),
153151 when(following.sync,
154152 h('div', {
155153 classList: 'ProfileList'
156154 }, [
modules/page/html/render/search.jsView
@@ -6,20 +6,20 @@
66 var Scroller = require('../../../../lib/scroller')
77 var nextStepper = require('../../../../lib/next-stepper')
88 var nest = require('depnest')
99 var Proxy = require('mutant/proxy')
10-var appRoot = require('app-root-path')
11-var i18n = require(appRoot + '/lib/i18n').i18n
1210
1311 exports.needs = nest({
1412 'sbot.pull.stream': 'first',
1513 'keys.sync.id': 'first',
16- 'message.html.render': 'first'
14+ 'message.html.render': 'first',
15+ 'intl.sync.i18n': 'first'
1716 })
1817
1918 exports.gives = nest('page.html.render')
2019
2120 exports.create = function (api) {
21+ const i18n = api.intl.sync.i18n
2222 return nest('page.html.render', function channel (path) {
2323 if (path[0] !== '?') return
2424
2525 var queryStr = path.substr(1).trim()
@@ -30,13 +30,13 @@
3030 var updates = Value(0)
3131 var aborter = null
3232
3333 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(' ')])
3535 ])
3636
3737 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'))
3939 ])
4040
4141 var content = Proxy()
4242 var container = h('Scroller', {
@@ -50,9 +50,9 @@
5050 style: {
5151 'padding': '60px 0',
5252 'font-size': '150%'
5353 }
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'))]))
5555 ])
5656 ])
5757 ])
5858
modules/page/html/render/settings.jsView
@@ -1,29 +1,33 @@
11 var { h, computed } = require('mutant')
22 var nest = require('depnest')
33 var appRoot = require('app-root-path')
4-var i18n = require(appRoot + '/lib/i18n').i18n
54
65 var themeNames = Object.keys(require('../../../../styles'))
76
87 exports.needs = nest({
98 'settings.obs.get': 'first',
109 'settings.sync.set': 'first',
10+ 'intl.sync.locales': 'first',
11+ 'intl.sync.i18n': 'first'
1112 })
1213
1314 exports.gives = nest('page.html.render')
1415
1516 exports.create = function (api) {
1617 return nest('page.html.render', function channel (path) {
1718 if (path !== '/settings') return
18-
19+ const i18n = api.intl.sync.i18n
20+
1921 const currentTheme = api.settings.obs.get('patchwork.theme')
22+ const currentLang = api.settings.obs.get('patchwork.lang')
23+ const langNames = api.intl.sync.locales()
2024 const filterFollowing = api.settings.obs.get('filters.following')
2125
2226 var prepend = [
2327 h('PageHeading', [
2428 h('h1', [
25- h('strong', i18n.__('Settings'))
29+ h('strong', i18n('Settings'))
2630 ]),
2731 ])
2832 ]
2933
@@ -31,9 +35,9 @@
3135 h('div.wrapper', [
3236 h('section.prepend', prepend),
3337 h('section.content', [
3438 h('section', [
35- h('h2', i18n.__('Theme')),
39+ h('h2', i18n('Theme')),
3640 computed(currentTheme, currentTheme => {
3741 return themeNames.map(name => {
3842 const style = currentTheme == name
3943 ? { 'margin-right': '1rem', 'border-color': 'teal' }
@@ -50,17 +54,34 @@
5054 themeNames.map(name => h('option', {value: name}, [name]))
5155 ])
5256 ]),
5357 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')),
5576 h('label', [
5677 h('input', {
5778 type: 'checkbox',
5879 checked: filterFollowing,
5980 'ev-change': (ev) => api.settings.sync.set({
6081 filters: {following: ev.target.checked}
6182 })
62- }), i18n.__(' Hide following messages')
83+ }), i18n(' Hide following messages')
6384 ])
6485 ])
6586 ])
6687 ])
modules/profile/sheet/edit.jsView
@@ -1,9 +1,7 @@
11 var nest = require('depnest')
22 var extend = require('xtend')
33 var {Value, h, computed, when} = require('mutant')
4-var appRoot = require('app-root-path')
5-var i18n = require(appRoot + '/lib/i18n').i18n
64 var fallbackImageUrl = 'data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='
75
86 exports.gives = nest('profile.sheet.edit')
97
@@ -17,12 +15,14 @@
1715 image: 'first',
1816 color: 'first'
1917 },
2018 'blob.html.input': 'first',
21- 'blob.sync.url': 'first'
19+ 'blob.sync.url': 'first',
20+ 'intl.sync.i18n': 'first',
2221 })
2322
2423 exports.create = function (api) {
24+ const i18n = api.intl.sync.i18n
2525 return nest('profile.sheet.edit', function () {
2626 var id = api.keys.sync.id()
2727 api.sheet.display(close => {
2828 var currentName = api.about.obs.name(id)
@@ -46,17 +46,17 @@
4646 h('h2', {
4747 style: {
4848 'font-weight': 'normal'
4949 }
50- }, [i18n.__('Your Profile')]),
50+ }, [i18n('Your Profile')]),
5151 h('ProfileEditor', [
5252 h('div.side', [
5353 h('ImageInput', [
5454 h('img', {
5555 style: { 'background-color': api.about.obs.color(id) },
5656 src: computed(chosenImage, (id) => id ? api.blob.sync.url(id) : fallbackImageUrl)
5757 }),
58- h('span', ['🖼 ', i18n.__('Choose Profile Image...')]),
58+ h('span', ['🖼 ', i18n('Choose Profile Image...')]),
5959 api.blob.html.input(file => {
6060 chosenImage.set(file.link)
6161 }, {
6262 accept: 'image/*',
@@ -65,13 +65,13 @@
6565 ])
6666 ]),
6767 h('div.main', [
6868 h('input.name', {
69- placeholder: i18n.__('Choose a name'),
69+ placeholder: i18n('Choose a name'),
7070 hooks: [ValueHook(chosenName), FocusHook()]
7171 }),
7272 h('textarea.description', {
73- placeholder: i18n.__('Describe yourself (if you want)'),
73+ placeholder: i18n('Describe yourself (if you want)'),
7474 hooks: [ValueHook(chosenDescription)]
7575 })
7676 ])
7777 ])
@@ -79,12 +79,12 @@
7979 footer: [
8080 h('button -save', {
8181 'ev-click': save,
8282 'disabled': publishing
83- }, when(publishing, i18n.__('Publishing...'), i18n.__('Publish'))),
83+ }, when(publishing, i18n('Publishing...'), i18n('Publish'))),
8484 h('button -cancel', {
8585 'ev-click': close
86- }, i18n.__('Cancel'))
86+ }, i18n('Cancel'))
8787 ]
8888 }
8989
9090 function save () {
@@ -105,11 +105,11 @@
105105 if (err) {
106106 publishing.set(false)
107107 showDialog({
108108 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.'),
112112 detail: err.message
113113 })
114114 } else {
115115 close()
plugs/message/html/layout/default.jsView
@@ -1,9 +1,7 @@
11 const { h, map, computed } = require('mutant')
22 var nest = require('depnest')
33 var ref = require('ssb-ref')
4-var appRoot = require('app-root-path')
5-var i18n = require(appRoot + '/lib/i18n').i18n
64
75 exports.needs = nest({
86 'profile.html.person': 'first',
97 'message.obs.backlinks': 'first',
@@ -15,14 +13,16 @@
1513 action: 'map',
1614 timestamp: 'first',
1715 backlinks: 'first'
1816 },
19- 'about.html.image': 'first'
17+ 'about.html.image': 'first',
18+ 'intl.sync.i18n': 'first',
2019 })
2120
2221 exports.gives = nest('message.html.layout')
2322
2423 exports.create = function (api) {
24+ const i18n = api.intl.sync.i18n
2525 return nest('message.html.layout', layout)
2626
2727 function layout (msg, {layout, previousId, priority, content, includeReferences = false}) {
2828 if (!(layout === undefined || layout === 'default')) return
@@ -34,13 +34,13 @@
3434 classList.push('-reply')
3535 var branch = msg.value.content.branch
3636 if (branch) {
3737 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))])
3939 }
4040 }
4141 } 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)])
4343 }
4444
4545 if (priority === 2) {
4646 classList.push('-new')
@@ -67,9 +67,9 @@
6767
6868 function messageHeader (msg, {replyInfo, priority}) {
6969 var additionalMeta = []
7070 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')}))
7272 }
7373 return h('header', [
7474 h('div.main', [
7575 h('a.avatar', {href: `${msg.value.author}`}, [
plugs/message/html/meta/likes.jsView
@@ -1,18 +1,17 @@
11 var nest = require('depnest')
22 var { h, computed, map, send } = require('mutant')
33
4-var appRoot = require('app-root-path');
5-var i18n = require(appRoot + '/lib/i18n').i18n
6-
74 exports.gives = nest('message.html.meta')
85 exports.needs = nest({
96 'message.obs.likes': 'first',
107 'message.sheet.likes': 'first',
11- 'about.obs.name': 'first'
8+ 'about.obs.name': 'first',
9+ 'intl.sync.i18n': 'first',
1210 })
1311
1412 exports.create = function (api) {
13+ const i18n = api.intl.sync.i18n
1514 return nest('message.html.meta', function likes (msg) {
1615 if (msg.key) {
1716 return computed(api.message.obs.likes(msg.key), likeCount)
1817 }
@@ -23,15 +22,15 @@
2322 return [' ', h('a.likes', {
2423 title: names(likes),
2524 href: '#',
2625 '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')}`])]
2827 }
2928 }
3029
3130 function names (ids) {
3231 var items = map(ids, api.about.obs.name)
3332 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')
3534 })
3635 }
3736 }
plugs/message/html/render/about.jsView
@@ -2,10 +2,8 @@
22 var computed = require('mutant/computed')
33 var nest = require('depnest')
44 var extend = require('xtend')
55 var ref = require('ssb-ref')
6-var appRoot = require('app-root-path');
7-var i18n = require(appRoot + '/lib/i18n').i18n
86
97 exports.needs = nest({
108 'message.html': {
119 decorate: 'reduce',
@@ -14,14 +12,16 @@
1412 },
1513 'keys.sync.id': 'first',
1614 'profile.html.person': 'first',
1715 'about.obs.name': 'first',
18- 'blob.sync.url': 'first'
16+ 'blob.sync.url': 'first',
17+ 'intl.sync.i18n': 'first',
1918 })
2019
2120 exports.gives = nest('message.html.render')
2221
2322 exports.create = function (api) {
23+ const i18n = api.intl.sync.i18n
2424 return nest('message.html.render', function about (msg, opts) {
2525 if (msg.value.content.type !== 'about') return
2626 if (!ref.isFeed(msg.value.content.about)) return
2727
@@ -34,20 +34,20 @@
3434 if (c.name) {
3535 var target = api.profile.html.person(c.about, c.name)
3636 miniContent.push(computed([self, api.about.obs.name(c.about), c.name], (self, a, b) => {
3737 if (self) {
38- return [i18n.__('self identifies as "'), target, '"']
38+ return [i18n('self identifies as "'), target, '"']
3939 } else if (a === b) {
40- return [i18n.__('identified '), api.profile.html.person(c.about)]
40+ return [i18n('identified '), api.profile.html.person(c.about)]
4141 } 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, '"']
4343 }
4444 }))
4545 }
4646
4747 if (c.image) {
4848 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)]
5050 miniContent.push(imageAction)
5151 }
5252
5353 content.push(h('a AboutImage', {
@@ -71,9 +71,9 @@
7171
7272 if (c.description) {
7373 elements.push(api.message.html.decorate(api.message.html.layout(msg, extend({
7474 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)],
7676 content: api.message.html.markdown(c.description),
7777 layout: 'mini'
7878 }, opts)), { msg }))
7979 }
plugs/message/html/render/channel.jsView
@@ -1,20 +1,20 @@
11 var h = require('mutant/h')
22 var nest = require('depnest')
33 var extend = require('xtend')
4-var appRoot = require('app-root-path');
5-var i18n = require(appRoot + '/lib/i18n').i18n
64
75 exports.needs = nest({
86 'message.html': {
97 decorate: 'reduce',
108 layout: 'first'
11- }
9+ },
10+ 'intl.sync.i18n':'first',
1211 })
1312
1413 exports.gives = nest('message.html.render')
1514
1615 exports.create = function (api) {
16+ const i18n = api.intl.sync.i18n
1717 return nest('message.html.render', function renderMessage (msg, opts) {
1818 if (msg.value.content.type !== 'channel') return
1919 var element = api.message.html.layout(msg, extend({
2020 miniContent: messageContent(msg),
@@ -27,9 +27,9 @@
2727 function messageContent (msg) {
2828 var channel = `#${msg.value.content.channel}`
2929 var subscribed = msg.value.content.subscribed
3030 return [
31- subscribed ? i18n.__('subscribed to ') : i18n.__('unsubscribed from '),
31+ subscribed ? i18n('subscribed to ') : i18n('unsubscribed from '),
3232 h('a', {href: channel}, channel)
3333 ]
3434 }
3535 }
plugs/message/html/render/following.jsView
@@ -1,22 +1,22 @@
11 var h = require('mutant/h')
22 var nest = require('depnest')
33 var extend = require('xtend')
44 var ref = require('ssb-ref')
5-var appRoot = require('app-root-path');
6-var i18n = require(appRoot + '/lib/i18n').i18n
75
86 exports.needs = nest({
97 'message.html': {
108 decorate: 'reduce',
119 layout: 'first'
1210 },
13- 'profile.html.person': 'first'
11+ 'profile.html.person': 'first',
12+ 'intl.sync.i18n': 'first',
1413 })
1514
1615 exports.gives = nest('message.html.render')
1716
1817 exports.create = function (api) {
18+ const i18n = api.intl.sync.i18n
1919 return nest('message.html.render', function renderMessage (msg, opts) {
2020 if (msg.value.content.type !== 'contact') return
2121 if (!ref.isFeed(msg.value.content.contact)) return
2222 if (typeof msg.value.content.following !== 'boolean') return
@@ -31,9 +31,9 @@
3131
3232 function messageContent (msg) {
3333 var following = msg.value.content.following
3434 return [
35- following ? i18n.__('followed ') : i18n.__('unfollowed '),
35+ following ? i18n('followed ') : i18n('unfollowed '),
3636 api.profile.html.person(msg.value.content.contact)
3737 ]
3838 }
3939 }

Built with git-ssb-web