Skip to content

Commit 46abbc6

Browse files
committed
Internationalize
1 parent 47a5861 commit 46abbc6

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

index.jsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import threadlib from 'patchwork-threads'
88
import SimpleInfinite from 'patchkit-simple-infinite'
99
import explain from 'explain-error'
1010
import u from 'patchkit-util'
11+
import t from 'patchwork-translations'
1112

1213
// how many messages to fetch in a batch?
1314
const DEFAULT_BATCH_LOAD_AMT = 30
@@ -83,7 +84,7 @@ export default class MsgList extends React.Component {
8384
// toggle in the DB
8485
ssb.patchwork.toggleBookmark(msg.key, (err, isBookmarked) => {
8586
if (err)
86-
return events.emit('error', explain(err, 'Failed to toggle bookmark'))
87+
return events.emit('error', explain(err, t('error.toggleBookmark')))
8788

8889
// re-render
8990
msg.isBookmarked = isBookmarked
@@ -104,7 +105,7 @@ export default class MsgList extends React.Component {
104105
var voteMsg = schemas.vote(msg.key, newVote)
105106
let done = (err) => {
106107
if (err)
107-
return events.emit('error', explain(err, 'Failed to publish vote'))
108+
return events.emit('error', explain(err, t('error.publishVote')))
108109

109110
// re-render
110111
msg.votes[this.context.user.id] = newVote
@@ -198,7 +199,7 @@ export default class MsgList extends React.Component {
198199

199200
loadingElement() {
200201
return <div className="msg-view summary">
201-
Loading...
202+
{t('Loading')}
202203
</div>
203204
}
204205

@@ -283,7 +284,7 @@ export default class MsgList extends React.Component {
283284
pull.take(amt), // apply limit
284285
pull.collect((err, msgs) => {
285286
if (err)
286-
console.warn('Error while fetching messages', err)
287+
console.warn(t('error.fetchingMessages'), err)
287288

288289
// add msgs
289290
if (msgs)
@@ -364,12 +365,12 @@ export default class MsgList extends React.Component {
364365
lastDate = moment(m.ts || m.value.timestamp).endOf('day')
365366
if (this.props.dateDividers && !lastDate.isSame(oldLastDate, 'day')) {
366367
let label = (lastDate.isSame(endOfToday, 'day'))
367-
? 'today'
368+
? t('msgs.today')
368369
: (lastDate.isSame(endOfToday, 'month'))
369370
? lastDate.from(endOfToday)
370371
: (lastDate.isSame(endOfToday, 'year'))
371372
? lastDate.format("dddd, MMMM Do")
372-
: lastDate.format("MMMM Do YYYY")
373+
: lastDate.format("LL")
373374
listEls.push(<hr key={m.key+'-divider'} className="labeled" data-label={label} />)
374375
}
375376

@@ -411,12 +412,12 @@ export default class MsgList extends React.Component {
411412
<div className="flex-fill">
412413
{ TopNav ? <TopNav {...this.props.topNavProps} /> : '' }
413414
{ nQueued ?
414-
<a className="new-msg-queue" onClick={this.reload.bind(this)}>{nQueued} new update{u.plural(nQueued)}</a>
415+
<a className="new-msg-queue" onClick={this.reload.bind(this)}>{t('msgs.newUpdates', u.plural(nQueued))}</a>
415416
: '' }
416-
{ this.state.msgs.length === 0 && this.state.isLoading ? <div style={{fontWeight: 300, textAlign: 'center'}}>Loading...</div> : '' }
417+
{ this.state.msgs.length === 0 && this.state.isLoading ? <div style={{fontWeight: 300, textAlign: 'center'}}>{t('Loading')}</div> : '' }
417418
{ isEmpty ?
418419
<div className="empty-msg">
419-
{ (this.props.emptyMsg || 'No messages.') }
420+
{ (this.props.emptyMsg || t('msgs.NoMessages')) }
420421
</div>
421422
:
422423
<ReactCSSTransitionGroup component="div" transitionName="fade" transitionAppear={true} transitionAppearTimeout={500} transitionEnterTimeout={500} transitionLeaveTimeout={1}>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"patchkit-simple-infinite": "^1.0.0",
2626
"patchkit-util": "^1.0.1",
2727
"patchwork-threads": "^2.2.0",
28+
"patchwork-translations": "^1.0.0",
2829
"pull-stream": "^3.3.0",
2930
"react": "^0.14.8",
3031
"react-addons-css-transition-group": "^0.14.0",

0 commit comments

Comments
 (0)