Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Find all strings for i18n in modals - Closes #744 #763

Merged
merged 47 commits into from
Sep 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5ee9e31
Setup i18n in send dialog
slaweet Sep 21, 2017
8c4fdae
Setup i18n in signMessage dialog
slaweet Sep 21, 2017
74f5aa9
Setup i18n in voteDialog
slaweet Sep 21, 2017
fde9e27
Setup i18n in clickToSend component
slaweet Sep 21, 2017
e12628c
Setup i18n in registerDelegate
slaweet Sep 21, 2017
d68c486
Setup i18n in passphrase
slaweet Sep 21, 2017
23e9b08
Setup i18n in verifyMessage
slaweet Sep 21, 2017
0c8afe3
Setup i18n in passphraseInput
slaweet Sep 21, 2017
5954687
Setup i18n in utils
slaweet Sep 22, 2017
018a4b6
Setup i18n in middlewares
slaweet Sep 22, 2017
914668f
Refactor addedTransaction middleware to use transactionTypes constants
slaweet Sep 22, 2017
e4de07d
Setup i18n in voteAutocomplete
slaweet Sep 22, 2017
d00674c
STASH
slaweet Sep 22, 2017
00b04b8
Merge branch 'development' into 744-stings-i18n-modals
slaweet Sep 26, 2017
04f2311
Revert "STASH"
slaweet Sep 26, 2017
f9fb350
Merge branch 'development' into 744-stings-i18n-modals
slaweet Sep 26, 2017
ac499cd
Find more strings for translation in account component
slaweet Sep 26, 2017
c3b560e
Find more strings for translation in header component
slaweet Sep 26, 2017
e830f8f
Fix translations in voting header
slaweet Sep 26, 2017
cc06dd8
Fix indentation
slaweet Sep 26, 2017
cfd2aad
Add forgotten translation functions
slaweet Sep 26, 2017
1be8497
Add translation functions to dialog headers
slaweet Sep 26, 2017
8193feb
Setup i18n in saveAccountButton
slaweet Sep 26, 2017
fbbd353
Add missing i18n to login
slaweet Sep 26, 2017
57e891d
Setup i18n in authInputs
slaweet Sep 26, 2017
cd94d11
Setup i18n in passphrase component
slaweet Sep 26, 2017
856b2f6
Merge branch 'development' into 744-stings-i18n-modals
slaweet Sep 26, 2017
6738bbe
Merge branch 'development' into 744-stings-i18n-modals
slaweet Sep 26, 2017
2847e9c
Fix indentation to make eslint 4 happy
slaweet Sep 26, 2017
e3d3b8e
Setup i18n in actionBar and pricedButton
slaweet Sep 26, 2017
af3a23e
Add forgotten i18n functions in verifyMessage
slaweet Sep 27, 2017
e822ea5
Setup i18n in receiveDialog
slaweet Sep 27, 2017
5f51ab1
Setup i18n of networks
slaweet Sep 27, 2017
b50d28c
Fix i18n key in forgingStats
slaweet Sep 27, 2017
67f790b
Merge branch 'development' into 744-stings-i18n-modals
slaweet Sep 27, 2017
c9e2668
Fix a typo 'acount' in a translation key
slaweet Sep 28, 2017
f847994
Merge branch 'development' into 744-stings-i18n-modals
slaweet Sep 28, 2017
f62754e
Update i18n source locales/en/common.json
slaweet Sep 28, 2017
65af423
Avoid multi-line strings in translation function
slaweet Sep 28, 2017
c5c4f1a
Merge branch 'development' into 744-stings-i18n-modals
slaweet Sep 28, 2017
93cc17c
Fix register component to use getNetworks()
slaweet Sep 28, 2017
8576670
Add i18n to forging component
slaweet Sep 29, 2017
d5543cb
Fix tab navigation to work with translations
slaweet Sep 29, 2017
db28683
Setup i18n of voting bar
slaweet Sep 29, 2017
35d2e5a
Set i18n of alert dialogs
slaweet Sep 29, 2017
6b472d3
Update locales source
slaweet Sep 29, 2017
91398da
Merge branch 'development' into 744-stings-i18n-modals
slaweet Sep 29, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/actions/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { transactionAdded } from './transactions';
import { errorAlertDialogDisplayed } from './dialog';
import Fees from '../constants/fees';
import { toRawLsk } from '../utils/lsk';
import transactionTypes from '../constants/transactionTypes';

/**
* Trigger this action to update the account object
Expand Down Expand Up @@ -58,7 +59,7 @@ export const secondPassphraseRegistered = ({ activePeer, secondPassphrase, accou
senderId: account.address,
amount: 0,
fee: Fees.setSecondPassphrase,
type: 1,
type: transactionTypes.setSecondPassphrase,
}));
}).catch((error) => {
const text = (error && error.message) ? error.message : 'An error occurred while registering your second passphrase. Please try again.';
Expand All @@ -83,7 +84,7 @@ export const delegateRegistered = ({
username,
amount: 0,
fee: Fees.registerDelegate,
type: 2,
type: transactionTypes.registerDelegate,
}));
})
.catch((error) => {
Expand All @@ -108,7 +109,7 @@ export const sent = ({ activePeer, account, recipientId, amount, passphrase, sec
recipientId,
amount: toRawLsk(amount),
fee: Fees.send,
type: 0,
type: transactionTypes.send,
}));
})
.catch((error) => {
Expand Down
7 changes: 4 additions & 3 deletions src/actions/account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as accountApi from '../utils/api/account';
import * as delegateApi from '../utils/api/delegate';
import Fees from '../constants/fees';
import { toRawLsk } from '../utils/lsk';
import transactionTypes from '../constants/transactionTypes';

describe('actions: account', () => {
describe('accountUpdated', () => {
Expand Down Expand Up @@ -69,7 +70,7 @@ describe('actions: account', () => {
senderId: 'test_address',
amount: 0,
fee: Fees.setSecondPassphrase,
type: 1,
type: transactionTypes.setSecondPassphrase,
};

actionFunction(dispatch);
Expand Down Expand Up @@ -129,7 +130,7 @@ describe('actions: account', () => {
username: data.username,
amount: 0,
fee: Fees.registerDelegate,
type: 2,
type: transactionTypes.registerDelegate,
};

actionFunction(dispatch);
Expand Down Expand Up @@ -191,7 +192,7 @@ describe('actions: account', () => {
recipientId: data.recipientId,
amount: toRawLsk(data.amount),
fee: Fees.send,
type: 0,
type: transactionTypes.send,
};

actionFunction(dispatch);
Expand Down
7 changes: 4 additions & 3 deletions src/actions/dialog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import actionTypes from '../constants/actions';
import i18next from 'i18next';
import Alert from '../components/dialog/alert';
import actionTypes from '../constants/actions';

/**
* An action to dispatch to display a dialog
Expand Down Expand Up @@ -28,7 +29,7 @@ export const alertDialogDisplayed = data => dialogDisplayed({
*
*/
export const successAlertDialogDisplayed = data => alertDialogDisplayed({
title: 'Success',
title: i18next.t('Success'),
text: data.text,
type: 'success',
});
Expand All @@ -38,7 +39,7 @@ export const successAlertDialogDisplayed = data => alertDialogDisplayed({
*
*/
export const errorAlertDialogDisplayed = data => alertDialogDisplayed({
title: 'Error',
title: i18next.t('Error'),
text: data.text,
type: 'error',
});
Expand Down
3 changes: 2 additions & 1 deletion src/actions/voting.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { errorAlertDialogDisplayed } from './dialog';
import { passphraseUsed } from './account';
import actionTypes from '../constants/actions';
import Fees from '../constants/fees';
import transactionTypes from '../constants/transactionTypes';

/**
* Add pending variable to the list of voted delegates and list of unvoted delegates
Expand Down Expand Up @@ -82,7 +83,7 @@ export const votePlaced = ({ activePeer, passphrase, account, votes, secondSecre
senderId: account.address,
amount: 0,
fee: Fees.vote,
type: 3,
type: transactionTypes.vote,
}));
}).catch((error) => {
const text = error && error.message ? `${error.message}.` : 'An error occurred while placing your vote.';
Expand Down
2 changes: 1 addition & 1 deletion src/components/account/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const Account = ({
<LiskAmount val={account.balance} /> LSK
</p>
<p className="inner secondary tooltip">
Click to send all funds
{t('Click to send all funds')}
</p>
</div>
</ClickToSend>
Expand Down
5 changes: 3 additions & 2 deletions src/components/account/account.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import { expect } from 'chai';
import sinon from 'sinon';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import i18n from '../../i18n';
import store from '../../store';
import Account from './account';
import ClickToSend from '../clickToSend';
Expand Down Expand Up @@ -50,7 +51,7 @@ describe('Account', () => {

it('should render balance with ClickToSend component', () => {
const wrapper = shallow(<Account {...props} />, {
context: { store },
context: { store, i18n },
childContextTypes: {
},
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/account/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import styles from './account.css';

const getStatusTooltip = (props) => {
if (props.secondSignature) {
return 'This account is protected by a second passphrase';
return props.t('This account is protected by a second passphrase');
} else if (props.passphrase) {
return 'Passphrase of the acount is saved till the end of the session.';
return props.t('Passphrase of the account is saved till the end of the session.');
}
return 'Passphrase of the acount will be required to perform any transaction.';
return props.t('Passphrase of the account will be required to perform any transaction.');
};

const Address = (props) => {
Expand Down
12 changes: 7 additions & 5 deletions src/components/actionBar/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React from 'react';
import { translate } from 'react-i18next';
import Button from 'react-toolbox/lib/button';
import React from 'react';
import grid from 'flexboxgrid/dist/flexboxgrid.css';
import PricedButton from '../pricedButton';
import styles from './actionBar.css';

const ActionBar = ({
secondaryButton, primaryButton, account,
export const ActionBarRaw = ({
secondaryButton, primaryButton, account, t,
}) => (
<section className={`${grid.row} ${grid['between-xs']} ${styles.wrapper}`} >
<Button
label={secondaryButton.label || 'Cancel'}
label={secondaryButton.label || t('Cancel')}
className={secondaryButton.className || 'cancel-button'}
onClick={secondaryButton.onClick}
type={secondaryButton.type || 'button'} />

<PricedButton
t={t}
primary={true}
raised={true}
label={primaryButton.label}
Expand All @@ -27,4 +29,4 @@ const ActionBar = ({
</section>
);

export default ActionBar;
export default translate()(ActionBarRaw);
21 changes: 17 additions & 4 deletions src/components/actionBar/index.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import configureStore from 'redux-mock-store';
import PropTypes from 'prop-types';
import sinon from 'sinon';
import { Provider } from 'react-redux';
import ActionBar from './index';
import store from '../../store';
import i18n from '../../i18n';
import { ActionBarRaw as ActionBar } from './index';
// import * as accountApi from '../../utils/api/account';

const fakeStore = configureStore();

describe('ActionBar', () => {
let wrapper;
Expand All @@ -24,7 +26,18 @@ describe('ActionBar', () => {
onClick: sinon.spy(),
},
};
wrapper = mount(<Provider store={store}><ActionBar {...props} /></Provider>);
const store = fakeStore({
account: {
balance: 100e8,
},
});
wrapper = mount(<ActionBar {...props} />, {
context: { store, i18n },
childContextTypes: {
store: PropTypes.object.isRequired,
i18n: PropTypes.object.isRequired,
},
});
});

it('renders two Button components', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/authInputs/authInputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AuthInputs extends React.Component {
const expectedPublicKey = this.props.account[publicKeyMap[name]];

if (expectedPublicKey && expectedPublicKey !== extractPublicKey(value)) {
error = 'Entered passphrase does not belong to the active account';
error = this.props.t('Entered passphrase does not belong to the active account');
}
}
this.props.onChange(name, value, error);
Expand All @@ -27,13 +27,13 @@ class AuthInputs extends React.Component {
render() {
return <span>
{(!this.props.account.passphrase &&
<PassphraseInput label='Passphrase'
<PassphraseInput label={this.props.t('Passphrase')}
className='passphrase'
error={this.props.passphrase.error}
value={this.props.passphrase.value}
onChange={this.onChange.bind(this, 'passphrase')} />)}
{(this.props.account.secondSignature &&
<PassphraseInput label='Second Passphrase'
<PassphraseInput label={this.props.t('Second Passphrase')}
className='second-passphrase'
error={this.props.secondPassphrase.error}
value={this.props.secondPassphrase.value}
Expand Down
18 changes: 10 additions & 8 deletions src/components/authInputs/authInputs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import sinon from 'sinon';
import { I18nextProvider } from 'react-i18next';
import i18n from '../../i18n'; // initialized i18next instance
import AuthInputs from './authInputs';


Expand All @@ -20,30 +22,31 @@ describe('AuthInputs', () => {
passphrase: {
value: passphrase,
},
t: key => key,
};
});

it('should render Input if props.account.secondSignature', () => {
props.account.secondSignature = true;
wrapper = mount(<AuthInputs {...props} />);
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
expect(wrapper.find('Input')).to.have.lengthOf(1);
});

it('should render null if !props.account.secondSignature', () => {
props.account.secondSignature = false;
wrapper = mount(<AuthInputs {...props} />);
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
expect(wrapper.html()).to.equal('<span></span>');
});

it('should render null if !props.account.secondSignature', () => {
props.account.secondSignature = false;
wrapper = mount(<AuthInputs {...props} />);
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
expect(wrapper.html()).to.equal('<span></span>');
});

it('should call props.onChange when input value changes', () => {
props.account.secondSignature = true;
wrapper = mount(<AuthInputs {...props} />);
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
wrapper.find('.second-passphrase input').simulate('change', { target: { value: passphrase } });
expect(props.onChange).to.have.been.calledWith('secondPassphrase', passphrase);
});
Expand All @@ -52,21 +55,20 @@ describe('AuthInputs', () => {
const error = 'Entered passphrase does not belong to the active account';
props.account.secondSignature = true;
props.account.secondPublicKey = 'fab9d261ea050b9e326d7e11587eccc343a20e64e29d8781b50fd06683cacc88';
wrapper = mount(<AuthInputs {...props} />);
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
wrapper.find('.second-passphrase input').simulate('change', { target: { value: passphrase } });
expect(props.onChange).to.have.been.calledWith('secondPassphrase', passphrase, error);
});

it('should call props.onChange(\'secondPassphrase\', \'Required\') when input value changes to \'\'', () => {
props.account.secondSignature = true;
wrapper = mount(<AuthInputs {...props} />);
wrapper.find('.second-passphrase input').simulate('change', { target: { value: '' } });
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>); wrapper.find('.second-passphrase input').simulate('change', { target: { value: '' } });
expect(props.onChange).to.have.been.calledWith('secondPassphrase', '', 'Required');
});

it('should call props.onChange(\'secondPassphrase\', \'Invalid passphrase\') when input value changes to \'test\'', () => {
props.account.secondSignature = true;
wrapper = mount(<AuthInputs {...props} />);
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
wrapper.find('.second-passphrase input').simulate('change', { target: { value: 'test' } });
expect(props.onChange).to.have.been.calledWith('secondPassphrase', 'test', 'Passphrase should have 12 words, entered passphrase has 1');
});
Expand Down
5 changes: 3 additions & 2 deletions src/components/authInputs/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { connect } from 'react-redux';
import { translate } from 'react-i18next';

import AuthInputs from './authInputs';

const mapStateToProps = state => ({
account: state.account,
});

export default connect(mapStateToProps)(AuthInputs);

export default connect(mapStateToProps)(translate()(AuthInputs));
6 changes: 5 additions & 1 deletion src/components/authInputs/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { I18nextProvider } from 'react-i18next';
import configureMockStore from 'redux-mock-store';
import i18n from '../../i18n';
import AuthInputsHOC from './index';

describe('AuthInputsHOC', () => {
Expand All @@ -20,7 +22,9 @@ describe('AuthInputsHOC', () => {
it('should render AuthInputs with props.account equal to state.account ', () => {
const store = configureMockStore([])({ account });
wrapper = mount(<Provider store={store}>
<AuthInputsHOC {...props}/>
<I18nextProvider i18n={ i18n }>
<AuthInputsHOC {...props}/>
</I18nextProvider>
</Provider>);
expect(wrapper.find('AuthInputs').props().account).to.deep.equal(account);
});
Expand Down
11 changes: 3 additions & 8 deletions src/components/clickToSend/index.test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import React from 'react';
import { expect } from 'chai';
import { shallow } from 'enzyme';
import configureMockStore from 'redux-mock-store';
import sinon from 'sinon';
import i18n from '../../i18n';
import ClickToSend from './index';
import RelativeLink from '../relativeLink';

const Dummy = () => (<span />);

describe('ClickToSend', () => {
let setActiveDialog;
const store = configureMockStore([])({
peers: { data: {} },
account: {},
activePeerSet: () => {},
});
const options = {
context: { store },
context: { i18n },
childContextTypes: {
store,
i18n,
},
};

Expand Down
Loading