Commit b562e05b785dd3f68360267ec1b32b9c9e775278
move all strings into translations
Dominic Tarr committed on 8/16/2017, 4:19:22 AMParent: 7cf0304bc911d7894179eec462e0b37166f9535c
Files changed
app/html/app.js | changed |
app/page/channel.js | changed |
app/page/error.js | changed |
app/page/groupFind.js | changed |
app/page/groupIndex.js | changed |
app/page/groupNew.js | changed |
app/page/groupShow.js | changed |
app/page/home.js | changed |
app/page/settings.js | changed |
app/page/threadNew.js | changed |
app/page/threadShow.js | changed |
app/page/userFind.js | changed |
app/page/userShow.js | changed |
translations/sync.js | changed |
app/html/app.js | ||
---|---|---|
@@ -2,47 +2,62 @@ | ||
2 | 2 | const values = require('lodash/values') |
3 | 3 | const insertCss = require('insert-css') |
4 | 4 | const openExternal = require('open-external') |
5 | 5 | |
6 | -exports.gives = nest('app.html.app') | |
6 | +const HyperNav = require('hypernav') | |
7 | +const computed = require('mutant/computed') | |
8 | +const h = require('mutant/h') | |
7 | 9 | |
10 | +exports.gives = nest({ | |
11 | + 'app.html.app': true, | |
12 | + 'history.obs.location': true, | |
13 | + 'history.sync.push': true, | |
14 | + 'history.sync.back': true, | |
15 | +}) | |
16 | + | |
8 | 17 | exports.needs = nest({ |
9 | 18 | 'app.async.catchLinkClick': 'first', |
10 | - 'history.sync.push': 'first', | |
11 | - 'history.obs.location': 'first', | |
12 | - 'history.obs.store': 'first', | |
19 | +// 'history.sync.push': 'first', | |
20 | +// 'history.obs.location': 'first', | |
21 | +// 'history.obs.store': 'first', | |
13 | 22 | 'router.sync.router': 'first', |
14 | 23 | 'styles.css': 'first' |
15 | 24 | }) |
16 | 25 | |
17 | 26 | exports.create = (api) => { |
18 | - return nest('app.html.app', app) | |
19 | 27 | |
20 | - function app () { | |
21 | - const css = values(api.styles.css()).join('\n') | |
22 | - insertCss(css) | |
28 | + var nav = HyperNav(api.router.sync.router, function (nav) { | |
29 | + return h('Header', [ | |
30 | + h('h1', [ | |
31 | + computed(nav.last, function (e) { return e.element.title }) | |
32 | + ]), | |
33 | + h('Nav', [ | |
34 | + h('div.back', { 'ev-click': nav.back }, '←'), | |
35 | + h('div', { 'ev-click': () => nav.push({page:'home'}) }, 'Home') | |
36 | + ]) | |
37 | + ]) | |
38 | + }) | |
23 | 39 | |
24 | - api.app.async.catchLinkClick(document.body, (link, { isExternal }) => { | |
25 | - if (isExternal) return openExternal(link) | |
40 | + return nest({ | |
41 | + 'app.html.app': function app () { | |
42 | + const css = values(api.styles.css()).join('\n') | |
43 | + insertCss(css) | |
26 | 44 | |
27 | - api.history.sync.push(link) | |
28 | - }) | |
45 | + api.app.async.catchLinkClick(document.body, (link, { isExternal }) => { | |
46 | + if (isExternal) return openExternal(link) | |
47 | + nav.push(link) | |
48 | + }) | |
49 | + nav.push({page: 'home'}) | |
50 | + document.body.appendChild(nav) | |
51 | + }, | |
52 | + 'history.sync.push': (location) => nav.push(location), | |
53 | + 'history.sync.back': () => nav.back(), | |
54 | + 'history.obs.location': () => nav.history, | |
55 | + }) | |
29 | 56 | |
30 | - api.history.obs.location()(render) | |
31 | - api.history.obs.store()(his => console.log('history', his)) // REMOVE) | |
32 | - api.history.sync.push({ page: 'home' }) | |
33 | - } | |
57 | +} | |
34 | 58 | |
35 | - function render (location) { | |
36 | - const newView = api.router.sync.router(location) | |
37 | 59 | |
38 | - if (!newView) { | |
39 | - api.history.obs.store().pop() // remove bogus location | |
40 | - return | |
41 | - } | |
42 | 60 | |
43 | - const oldView = document.body.firstChild | |
44 | - oldView | |
45 | - ? document.body.replaceChild(newView, oldView) | |
46 | - : document.body.appendChild(newView) | |
47 | - } | |
48 | -} | |
61 | + | |
62 | + | |
63 | + |
app/page/channel.js | ||
---|---|---|
@@ -62,11 +62,9 @@ | ||
62 | 62 | return container |
63 | 63 | } |
64 | 64 | ) |
65 | 65 | |
66 | - return h('Page -home', [ | |
67 | - h('h1', location.channel), | |
68 | - api.app.html.nav(), | |
66 | + return h('Page -home', {title: location.channel}, [ | |
69 | 67 | threadsHtmlObs, |
70 | 68 | h('button', { |
71 | 69 | 'ev-click': threadsHtmlObs.more, |
72 | 70 | disabled: disableShowMore |
@@ -74,4 +72,5 @@ | ||
74 | 72 | ]) |
75 | 73 | }) |
76 | 74 | } |
77 | 75 | |
76 | + |
app/page/error.js | ||
---|---|---|
@@ -3,20 +3,23 @@ | ||
3 | 3 | |
4 | 4 | exports.gives = nest('app.page.error') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
7 | + 'translations.sync.strings': 'first', | |
7 | 8 | 'app.html.nav': 'first' |
8 | 9 | }) |
9 | 10 | |
10 | 11 | exports.create = (api) => { |
12 | + var strings = api.translations.sync.strings() | |
13 | + | |
11 | 14 | return nest('app.page.error', error) |
12 | 15 | |
13 | 16 | function error (location) { |
14 | - | |
15 | - return h('Page -error', [ | |
16 | - h('h1', 'Error'), | |
17 | - api.app.html.nav(), | |
18 | - "The route wasn't found of there was an error", | |
17 | + return h('Page -error', {title: strings.error}, [ | |
18 | + strings.errorNotFound, | |
19 | 19 | location.error |
20 | 20 | ]) |
21 | 21 | } |
22 | 22 | } |
23 | + | |
24 | + | |
25 | + |
app/page/groupFind.js | ||
---|---|---|
@@ -3,19 +3,20 @@ | ||
3 | 3 | |
4 | 4 | exports.gives = nest('app.page.groupFind') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
7 | + 'translations.sync.strings': 'first', | |
7 | 8 | 'app.html.nav': 'first' |
8 | 9 | }) |
9 | 10 | |
10 | 11 | exports.create = (api) => { |
12 | + var strings = api.translations.sync.strings() | |
11 | 13 | return nest('app.page.groupFind', groupFind) |
12 | 14 | |
13 | 15 | function groupFind (location) { |
14 | - | |
15 | - return h('Page -groupFind', [ | |
16 | - h('h1', 'Group Find'), | |
17 | - api.app.html.nav(), | |
16 | + return h('Page -groupFind', {title: strings.groupFind}, [ | |
18 | 17 | h('p', `key: ${location.key}`) |
19 | 18 | ]) |
20 | 19 | } |
21 | 20 | } |
21 | + | |
22 | + |
app/page/groupIndex.js | ||
---|---|---|
@@ -3,17 +3,21 @@ | ||
3 | 3 | |
4 | 4 | exports.gives = nest('app.page.groupIndex') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
7 | + 'translations.sync.strings': 'first', | |
7 | 8 | 'app.html.nav': 'first' |
8 | 9 | }) |
9 | 10 | |
10 | 11 | exports.create = (api) => { |
12 | + var strings = api.translations.sync.strings() | |
11 | 13 | return nest('app.page.groupIndex', groupIndex) |
12 | 14 | |
13 | 15 | function groupIndex (location) { |
14 | - return h('Page -groupIndex', [ | |
15 | - h('h1', 'Group Index'), | |
16 | - api.app.html.nav() | |
16 | + return h('Page -groupIndex', {title: strings.groupIndex}, [ | |
17 | + strings.stub | |
17 | 18 | ]) |
18 | 19 | } |
19 | 20 | } |
21 | + | |
22 | + | |
23 | + |
app/page/groupNew.js | ||
---|---|---|
@@ -3,17 +3,19 @@ | ||
3 | 3 | |
4 | 4 | exports.gives = nest('app.page.groupNew') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
7 | - 'app.html.nav': 'first' | |
7 | + 'app.html.nav': 'first', | |
8 | + 'translations.sync.strings': 'first' | |
8 | 9 | }) |
9 | 10 | |
10 | 11 | exports.create = (api) => { |
11 | 12 | return nest('app.page.groupNew', groupNew) |
12 | - | |
13 | + var strings = api.translations.sync.strings() | |
13 | 14 | function groupNew (location) { |
14 | - return h('Page -groupNew', [ | |
15 | - h('h1', 'Group New'), | |
16 | - api.app.html.nav() | |
15 | + return h('Page -groupNew', {title: strings.groupNew}, [ | |
16 | + strings.stub | |
17 | 17 | ]) |
18 | 18 | } |
19 | 19 | } |
20 | + | |
21 | + |
app/page/groupShow.js | ||
---|---|---|
@@ -3,21 +3,25 @@ | ||
3 | 3 | |
4 | 4 | exports.gives = nest('app.page.groupShow') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
7 | + 'translations.sync.strings': 'first', | |
7 | 8 | 'app.html.nav': 'first' |
8 | 9 | }) |
9 | 10 | |
10 | 11 | exports.create = (api) => { |
12 | + var strings = api.translations.sync.strings() | |
11 | 13 | return nest('app.page.groupShow', groupShow) |
12 | 14 | |
13 | 15 | function groupShow (location) { |
14 | 16 | // location here can be the root message of a group : { type: 'group', key } |
15 | 17 | // TODO show specific group index described by key |
16 | 18 | |
17 | - return h('Page -groupShow', [ | |
18 | - h('h1', 'Group Show'), | |
19 | - api.app.html.nav(), | |
19 | + return h('Page -groupShow', {title: strings.groupShow}, [ | |
20 | 20 | h('p', `key: ${location.key}`) |
21 | 21 | ]) |
22 | 22 | } |
23 | 23 | } |
24 | + | |
25 | + | |
26 | + | |
27 | + |
app/page/home.js | ||
---|---|---|
@@ -27,9 +27,9 @@ | ||
27 | 27 | } |
28 | 28 | |
29 | 29 | exports.create = (api) => { |
30 | 30 | return nest('app.page.home', function (location) { |
31 | - // location here can expected to be: { page: 'home' } | |
31 | + // location here can expected to be: { page: 'home'} | |
32 | 32 | var strings = api.translations.sync.strings() |
33 | 33 | |
34 | 34 | var container = h('div.container', []) |
35 | 35 | |
@@ -124,14 +124,12 @@ | ||
124 | 124 | |
125 | 125 | return container |
126 | 126 | } |
127 | 127 | ) |
128 | - | |
129 | - return h('Page -home', [ | |
130 | - h('h1', 'Home'), | |
131 | - api.app.html.nav(), | |
128 | + return h('Page -home', {title: strings.home}, [ | |
132 | 129 | threadsHtmlObs, |
133 | 130 | h('button', {'ev-click': threadsHtmlObs.more}, [strings.showMore]) |
134 | 131 | ]) |
135 | 132 | }) |
136 | 133 | } |
137 | 134 | |
135 | + |
app/page/settings.js | ||
---|---|---|
@@ -3,18 +3,20 @@ | ||
3 | 3 | |
4 | 4 | exports.gives = nest('app.page.settings') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
7 | + 'translations.sync.strings': 'first', | |
7 | 8 | 'app.html.nav': 'first' |
8 | 9 | }) |
9 | 10 | |
10 | 11 | exports.create = (api) => { |
11 | 12 | return nest('app.page.settings', settings) |
12 | 13 | |
13 | 14 | function settings (location) { |
14 | 15 | |
15 | - return h('Page -settings', [ | |
16 | - h('h1', 'Settings'), | |
17 | - api.app.html.nav(), | |
16 | + return h('Page -settings', {title: strings.settings}, [ | |
17 | + strings.stub | |
18 | 18 | ]) |
19 | 19 | } |
20 | 20 | } |
21 | + | |
22 | + |
app/page/threadNew.js | ||
---|---|---|
@@ -3,24 +3,29 @@ | ||
3 | 3 | |
4 | 4 | exports.gives = nest('app.page.threadNew') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
7 | + 'translations.sync.strings': 'first', | |
7 | 8 | 'about.html.image': 'first', |
8 | 9 | 'about.obs.name': 'first', |
9 | 10 | 'app.html.nav': 'first', |
10 | 11 | 'app.html.thread': 'first', |
11 | 12 | }) |
12 | 13 | |
13 | 14 | exports.create = (api) => { |
15 | + var strings = api.translations.sync.strings() | |
16 | + | |
14 | 17 | return nest('app.page.threadNew', threadNew) |
15 | 18 | |
16 | 19 | function threadNew (location) { |
17 | 20 | const { feed } = location |
18 | 21 | |
19 | - return h('Page -threadNew', [ | |
22 | + return h('Page -threadNew', {title: strings.threadNew}, [ | |
20 | 23 | h('h1', ['New thread with ', api.about.obs.name(feed)]), |
21 | 24 | api.about.html.image(feed), |
22 | - api.app.html.nav(), | |
23 | 25 | h('div', 'compose box') // a special one which takes us to threadShow |
24 | 26 | ]) |
25 | 27 | } |
26 | 28 | } |
29 | + | |
30 | + | |
31 | + |
app/page/threadShow.js | ||
---|---|---|
@@ -5,14 +5,17 @@ | ||
5 | 5 | |
6 | 6 | exports.gives = nest('app.page.threadShow') |
7 | 7 | |
8 | 8 | exports.needs = nest({ |
9 | + 'translations.sync.strings': 'first', | |
9 | 10 | 'app.html.nav': 'first', |
10 | 11 | 'app.html.thread': 'first', |
11 | 12 | 'message.html.compose': 'first' |
12 | 13 | }) |
13 | 14 | |
14 | 15 | exports.create = (api) => { |
16 | + var strings = api.translations.sync.strings() | |
17 | + | |
15 | 18 | return nest('app.page.threadShow', threadShow) |
16 | 19 | |
17 | 20 | function threadShow (location) { |
18 | 21 | // location = a thread (message decorated with replies) |
@@ -22,20 +25,20 @@ | ||
22 | 25 | |
23 | 26 | const meta = { |
24 | 27 | type: 'post', |
25 | 28 | root, |
26 | - branch: get(last(location.replies), 'key'), // >> lastId? CHECK THIS LOGIC | |
27 | - channel, | |
29 | + branch: get(last(location.replies), 'key'), | |
30 | + // >> lastId? CHECK THIS LOGIC | |
31 | + channel: channel, | |
28 | 32 | recps: get(location, 'value.content.recps') |
29 | 33 | } |
30 | 34 | const composer = api.message.html.compose({ meta, shrink: false }) |
31 | 35 | |
32 | - return h('Page -threadShow', [ | |
33 | - h('h1', 'Private message'), | |
34 | - api.app.html.nav(), | |
36 | + return h('Page -threadShow', {title: strings.threadShow}, [ | |
35 | 37 | h('div.container', [ |
36 | 38 | thread, |
37 | 39 | composer |
38 | 40 | ]), |
39 | 41 | ]) |
40 | 42 | } |
41 | 43 | } |
44 | + |
app/page/userFind.js | ||
---|---|---|
@@ -3,18 +3,22 @@ | ||
3 | 3 | |
4 | 4 | exports.gives = nest('app.page.userFind') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
7 | + 'translations.sync.strings': 'first', | |
7 | 8 | 'app.html.nav': 'first' |
8 | 9 | }) |
9 | 10 | |
10 | 11 | exports.create = (api) => { |
12 | + var strings = api.translations.sync.strings() | |
11 | 13 | return nest('app.page.userFind', userFind) |
12 | 14 | |
13 | 15 | function userFind (location) { |
14 | 16 | |
15 | - return h('Page -userFind', [ | |
16 | - h('h1', 'Find a User'), | |
17 | - api.app.html.nav() | |
17 | + return h('Page -userFind', {title: strings.userFind}, [ | |
18 | + string.stub | |
18 | 19 | ]) |
19 | 20 | } |
20 | 21 | } |
22 | + | |
23 | + | |
24 | + |
app/page/userShow.js | ||
---|---|---|
@@ -3,34 +3,39 @@ | ||
3 | 3 | |
4 | 4 | exports.gives = nest('app.page.userShow') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
7 | + 'translations.sync.strings': 'first', | |
7 | 8 | 'app.html.link': 'first', |
8 | 9 | 'app.html.nav': 'first', |
9 | 10 | 'about.html.image': 'first', |
10 | 11 | 'about.obs.name': 'first', |
11 | 12 | 'keys.sync.id': 'first', |
12 | 13 | }) |
13 | 14 | |
14 | 15 | exports.create = (api) => { |
16 | + var strings = api.translations.sync.strings() | |
17 | + | |
15 | 18 | return nest('app.page.userShow', userShow) |
16 | 19 | |
17 | 20 | function userShow (location) { |
18 | 21 | |
19 | 22 | const { feed } = location |
20 | 23 | const Link = api.app.html.link |
21 | 24 | const myId = api.keys.sync.id() |
25 | + var name = api.about.html.name(feed) | |
22 | 26 | |
23 | - return h('Page -userShow', [ | |
24 | - h('h1', api.about.obs.name(feed)), | |
25 | - api.app.html.nav(), | |
27 | + return h('Page -userShow', {title: api.about.obs.name(feed)}, [ | |
26 | 28 | api.about.html.image(feed), |
27 | - h('div', 'follow button'), | |
28 | - h('div', 'friends in common'), | |
29 | + h('div', strings.followButton), | |
30 | + h('div', strings.friendsInCommon), | |
29 | 31 | feed !== myId |
30 | - ? Link({ page: 'threadNew', feed }, 'New Thread') | |
32 | + ? Link({ page: 'threadNew', feed }, strings.newThread) | |
31 | 33 | : '', |
32 | - h('div', 'conversations you\'ve had with dominic'), | |
33 | - h('div', 'groups dominic is in'), | |
34 | + h('div', strings.userConvesationsWith, name), | |
35 | + h('div', name, strings.userIsInGroups), | |
34 | 36 | ]) |
35 | 37 | } |
36 | 38 | } |
39 | + | |
40 | + | |
41 | + |
translations/sync.js | ||
---|---|---|
@@ -5,9 +5,27 @@ | ||
5 | 5 | return {translations: {sync: {strings: function () { |
6 | 6 | return { |
7 | 7 | showMore: "Show More", |
8 | 8 | channels: "Channels", |
9 | + home: "Home", | |
9 | 10 | directMessages: "Direct Messages", |
10 | - replySymbol: "> " | |
11 | + replySymbol: "> ", | |
12 | + error: "Error", | |
13 | + errorNotFound: "The page wasn't found", | |
14 | + groupNew: "New Group", | |
15 | + groupFind: 'Find Group', | |
16 | + groupIndex: "Group Index", | |
17 | + //stub: should not be shown on released software! | |
18 | + stub: "this page is a stub", | |
19 | + settings: "Settings", | |
20 | + threadNew: 'New Thread', | |
21 | + threadShow: "Direct Messages", | |
22 | + userFind: "Find User", | |
23 | + userIsInGroups: "is in groups:" | |
24 | + userConversationsWith: 'conversations you\'ve had with', | |
25 | + follow: "Follow", | |
26 | + friendsInCommon: 'friends in common' | |
11 | 27 | } |
12 | 28 | }}}} |
13 | 29 | } |
30 | + | |
31 | + |
Built with git-ssb-web