Skip to content

Commit a16499c

Browse files
committed
Internationalize
1 parent c79d30d commit a16499c

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

help.jsx

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react'
2+
import t from 'patchwork-translations'
23

34
export class InviteErrorExplanation extends React.Component {
45
render() {
@@ -8,30 +9,30 @@ export class InviteErrorExplanation extends React.Component {
89
const msg = this.props.error.message.toLowerCase()
910

1011
if (~msg.indexOf('invite code not provided'))
11-
return <div className="error">The invite code is required.</div>
12+
return <div className="error">{t('invite.error.codeRequired')}</div>
1213

1314
if (~msg.indexOf('invite not accepted'))
14-
return <div className="error">The invite code was not accepted.</div>
15+
return <div className="error">{t('invite.error.notAccepted')}</div>
1516

1617
if (~msg.indexOf('incorrect or expired') || ~msg.indexOf('has expired'))
17-
return <div className="error">The invite code is mis-issued or expired.</div>
18+
return <div className="error">{t('invite.error.expired')}</div>
1819

1920
if (~msg.indexOf('invalid') || ~msg.indexOf('feed to follow is missing') || ~msg.indexOf('may not be used to follow another key'))
20-
return <div className="error">Something is wrong with the invite code.</div>
21+
return <div className="error">{t('invite.error.somethingWrong')}</div>
2122

2223
if (~msg.indexOf('pub server did not have correct public key'))
23-
return <div className="error">Connection failure.</div>
24+
return <div className="error">{t('invite.error.connectionFailure')}</div>
2425

2526
if (~msg.indexOf('unexpected end of parent stream'))
26-
return <div className="error">Failed to connect to the pub server.</div>
27+
return <div className="error">{t('invite.error.failedConnect')}</div>
2728

2829
if (~msg.indexOf('ENOTFOUND'))
29-
return <div className="error">The pub server could not be found.</div>
30+
return <div className="error">{t('invite.error.notFound')}</div>
3031

3132
if (~msg.indexOf('already following'))
32-
return <div className="error">You are already followed by this pub server.</div>
33+
return <div className="error">{t('invite.error.alreadyFollowed')}</div>
3334

34-
return <div className="error">Sorry, an unexpected error occurred: {msg}</div>
35+
return <div className="error">{t('invite.error.unexpectedError', {msg})}</div>
3536
}
3637
}
3738

@@ -44,22 +45,22 @@ export class InviteErrorHelp extends React.Component {
4445
let helpText = false
4546

4647
if (~msg.indexOf('invite not accepted'))
47-
helpText = 'The invite code was not accepted. It may have been used already. Ask the pub-operator for a new code and try again.'
48+
helpText = t('invite.help.codeRequired')
4849

4950
if (~msg.indexOf('incorrect or expired') || ~msg.indexOf('has expired'))
50-
helpText = 'The invite code is incorrect or expired. Make sure you copy/pasted it correctly. If you did, ask the pub-operator for a new code and try again.'
51+
helpText = t('invite.help.notAccepted')
5152

5253
if (~msg.indexOf('invalid') || ~msg.indexOf('feed to follow is missing') || ~msg.indexOf('may not be used to follow another key'))
53-
helpText = 'The invite code is malformed. Make sure you copy/pasted it correctly. If you did, ask the pub-server owner for a new code and try again.'
54+
helpText = t('invite.help.somethingWrong')
5455

5556
if (~msg.indexOf('pub server did not have correct public key'))
56-
helpText = 'The pub server did not identify itself correctly for the invite code. Ask the pub-operator for a new code and try again.'
57+
helpText = t('invite.help.connectionFailure')
5758

5859
if (~msg.indexOf('could not connect to server') || ~msg.indexOf('unexpected end of parent stream'))
59-
helpText = 'Failed to connect to the pub server. Check your connection, make sure the pub server is online, and try again.'
60+
helpText = t('invite.help.failedConnect')
6061

6162
if (~msg.indexOf('ENOTFOUND'))
62-
helpText = 'Check your connection, make sure the pub server is online, and try again. If this issue persists, check with the pub operator.'
63+
helpText = t('invite.help.notFound')
6364

6465
if (!helpText)
6566
return <span/>

index.jsx

+14-13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import ref from 'ssb-ref'
33
import MDLSpinner from 'patchkit-mdl-spinner'
44
import { InviteErrorExplanation, InviteErrorHelp } from './help'
5+
import t from 'patchwork-translations'
56

67
export default class PubInvite extends React.Component {
78
static propTypes = {
@@ -49,12 +50,12 @@ export default class PubInvite extends React.Component {
4950

5051
// validate
5152
if (!code)
52-
return this.setState({ isProcessing: false, error: { message: 'Invite code not provided' } })
53+
return this.setState({ isProcessing: false, error: { message: t('invite.CodeNotProvided') } })
5354
if (!ref.isInvite(code))
54-
return this.setState({ isProcessing: false, error: { message: 'Invalid invite code' } })
55+
return this.setState({ isProcessing: false, error: { message: t('invite.InvalidCode') } })
5556

5657
// use the invite
57-
this.setState({ info: 'Contacting server with invite code, this may take a few moments...' })
58+
this.setState({ info: t('invite.Contacting') })
5859
this.context.ssb.invite.accept(code, err => {
5960
if (err) {
6061
console.error(err)
@@ -74,31 +75,31 @@ export default class PubInvite extends React.Component {
7475
const helpText = (this.state.error) ? <InviteErrorHelp error={this.state.error} /> : ''
7576

7677
return <div>
77-
<h1>Join a Pub</h1>
78-
<h3>Pubs host your messages online, and connect you globally.</h3>
78+
<h1>{t('invite.JoinPub')}</h1>
79+
<h3>{t('invite.JoinPubInfo')}</h3>
7980
<form className="fullwidth" onSubmit={e=>e.preventDefault()}>
8081
<fieldset>
81-
<input type="text" value={this.state.code} onChange={this.onChange.bind(this)} placeholder="Enter the invite code here" />
82+
<input type="text" value={this.state.code} onChange={this.onChange.bind(this)} placeholder={t('invite.EnterCode')}/>
8283
<div>{msg}</div>
8384
<div>{helpText}</div>
8485
</fieldset>
8586
</form>
8687
{ this.state.isProcessing ? <MDLSpinner /> : '' }
8788
<div className="faq text-center">
8889
{ this.props.gotoNextStep ?
89-
<div><a onClick={this.props.gotoNextStep}>You can skip this step</a>, but your messages {"won't"} reach outside the WiFi until you do it.</div>
90+
<div><a onClick={this.props.gotoNextStep}>{t('invite.CanSkip')}</a>{t('invite.CanSkip2')}</div>
9091
: '' }
9192
<div className="faq-entry">
92-
<div>{"What's"} an invite code?</div>
93-
<div>An invite code tells the Pub to join your contacts.</div>
93+
<div>{t('invite.q.WhatIs')}</div>
94+
<div>{t('invite.a.WhatIs')}</div>
9495
</div>
9596
<div className="faq-entry">
96-
<div>Where can I get an invite code?</div>
97-
<div>You should ask a Pub operator. Many of them hang out in #scuttlebutt on Freenode.</div>
97+
<div>{t('invite.q.WhereCan')}</div>
98+
<div>{t('invite.a.WhereCan')}</div>
9899
</div>
99100
<div className="faq-entry">
100-
<div>Can I create a Pub?</div>
101-
<div>Yes, but it requires a public server. If you have one, you can <a href="http://ssbc.github.io/docs/scuttlebot/howto-setup-a-pub.html" target="_blank">follow&nbsp;this&nbsp;guide</a>.</div>
101+
<div>{t('invite.q.CanCreate')}</div>
102+
<div>{t('invite.a.CanCreate1')}<a href="http://ssbc.github.io/docs/scuttlebot/howto-setup-a-pub.html" target="_blank">{t('invite.a.CanCreate2')}</a>{t('invite.a.CanCreate3')}</div>
102103
</div>
103104
</div>
104105
</div>

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"homepage": "https://github.com/patchkit/patchkit-form-pub-invite#readme",
2222
"dependencies": {
2323
"patchkit-mdl-spinner": "^1.0.0",
24+
"patchwork-translations": "^1.0.0",
2425
"react": "^0.14.6",
2526
"ssb-ref": "^2.3.0"
2627
},

0 commit comments

Comments
 (0)