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 - Closes #557 #759

Merged
merged 36 commits into from
Sep 21, 2017
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
43da21d
Disable debug mode in i18next
yasharAyari Sep 15, 2017
f9cad7c
Add i18n strings to account components
yasharAyari Sep 18, 2017
5d395c5
Add i18n strings to secondPassphrase component
yasharAyari Sep 18, 2017
5f3acfe
Add i18n strings to tabs component
yasharAyari Sep 18, 2017
a932abf
Add i18n strings to timestamp component
yasharAyari Sep 18, 2017
1e63d96
Add i18n strings to transactionsp components
yasharAyari Sep 18, 2017
824b36f
Add some translation strings
yasharAyari Sep 18, 2017
7bbfa04
Update translation strings in header component
yasharAyari Sep 18, 2017
ce8ce82
fix a bug in address component test file
yasharAyari Sep 18, 2017
b1debb4
Add i18n strings to forging components
yasharAyari Sep 18, 2017
fc6b52e
Add forging strings to common.json
yasharAyari Sep 18, 2017
422bcb2
Add i18n strings to login component
yasharAyari Sep 18, 2017
2efeaf2
Add strings that used in login component to common.json
yasharAyari Sep 18, 2017
73e0ea9
Merge branch 'development' into '557-find-all-strings-for-i18n'
yasharAyari Sep 19, 2017
dce60ef
fix a bug in transactionRow component
yasharAyari Sep 19, 2017
055ebe9
Add i18n strings to voting components
yasharAyari Sep 19, 2017
33e63e9
Add some newi18n strings to login component
yasharAyari Sep 19, 2017
56a17cf
Add voting strings translation to login common.json
yasharAyari Sep 19, 2017
523015d
Fix an eslint error in transactions component
yasharAyari Sep 19, 2017
7a83d0c
Add i18n strings to transactionRow component
yasharAyari Sep 20, 2017
a5eda1d
Add transactionRow strings translation to common.json
yasharAyari Sep 20, 2017
c06591e
Select current language in language menu
yasharAyari Sep 20, 2017
e070ae7
Fix a translation bug in forgingTitle
yasharAyari Sep 20, 2017
95206ac
Update some translation strings
yasharAyari Sep 20, 2017
aa59e8d
Merge branch 'development' into '557-find-all-strings-for-i18n'
yasharAyari Sep 20, 2017
e8b3af9
Fix a bug in login component
yasharAyari Sep 20, 2017
8afc356
Fix a bug in header component
yasharAyari Sep 20, 2017
5ee9c36
Fix a bug in login
yasharAyari Sep 20, 2017
4209c2b
Fix an eslint bug in transactionRow.test.js
yasharAyari Sep 20, 2017
3b98503
Refactor forgingStats
slaweet Sep 21, 2017
643258e
Fix login test
slaweet Sep 21, 2017
7e17036
Capitalize first letter of translation keys
slaweet Sep 21, 2017
bb967d4
Remove duplicate translation key
slaweet Sep 21, 2017
0154d68
Move languages list into a constants file
slaweet Sep 21, 2017
87ca8b0
Fix Send translation key capitalization
slaweet Sep 21, 2017
f61f7a7
Skip a test in AccountHOC
slaweet Sep 21, 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
11 changes: 7 additions & 4 deletions src/components/account/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { toRawLsk } from '../../utils/lsk';
*
* @param {object} props - include properties of component
*/

const Account = ({
account, peers,
account, peers, t,
}) => {
const status = (peers.status && peers.status.online) ?
<i className="material-icons online">check</i> :
Expand All @@ -21,13 +22,15 @@ const Account = ({
return (
<section className={`${grid.row} ${styles.wrapper}`}>
<article className={`${grid['col-sm-4']} ${grid['col-xs-12']}`}>
<Address {...account}></Address>
<Address t={t} {...account}></Address>
</article>
<article className={`${grid['col-sm-4']} ${grid['col-xs-12']}`}>
<div className="box">
<div className={`${grid.row}`}>
<div className={`${grid['col-sm-12']} ${grid['col-xs-4']}`}>
<h3 className={styles.title}>Peer</h3>
<h3 className={styles.title}>
{t('Peer')}
</h3>
</div>
<div className={`${grid['col-sm-12']} ${grid['col-xs-8']}`}>
<div className={styles['value-wrapper']}>
Expand All @@ -50,7 +53,7 @@ const Account = ({
<div className="box">
<div className={`${grid.row}`}>
<div className={`${grid['col-sm-12']} ${grid['col-xs-4']}`}>
<h3 className={styles.title}>Balance</h3>
<h3 className={styles.title}>{t('Balance')}</h3>
</div>
<div className={`${grid['col-sm-12']} ${grid['col-xs-8']}`}>
<ClickToSend
Expand Down
3 changes: 3 additions & 0 deletions src/components/account/account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe('Account', () => {

beforeEach(() => {
props = {
t: key => key,
i18n: {},
store: {},
onActivePeerUpdated: sinon.spy(),
peers: {
status: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/account/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import grid from 'flexboxgrid/dist/flexboxgrid.css';
import styles from './account.css';

const Address = (props) => {
const title = props.isDelegate ? 'Delegate' : 'Address';
const title = props.isDelegate ? props.t('Delegate') : props.t('Address');
const content = props.isDelegate ?
(<div>
<p className="inner primary delegate-name">
Expand Down
3 changes: 3 additions & 0 deletions src/components/account/address.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('Address', () => {
const inputValue = {
isDelegate: false,
address: '16313739661670634666L',
t: key => key,
};
const expectedHeaderValue = 'Address';
const wrapper = shallow(<Address {...inputValue} />);
Expand All @@ -21,6 +22,7 @@ describe('Address', () => {
delegate: {
username: 'lisk-nano',
},
t: key => key,
};
const expectedHeaderValue = 'Delegate';
const wrapper = shallow(<Address {...inputValue} />);
Expand All @@ -34,6 +36,7 @@ describe('Address', () => {
delegate: {
username: 'lisk-nano',
},
t: key => key,
};
const expectedValue = 'lisk-nano';
const wrapper = shallow(<Address {...inputValue} />);
Expand Down
3 changes: 2 additions & 1 deletion src/components/account/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import Account from './account';

/**
Expand All @@ -11,4 +12,4 @@ const mapStateToProps = state => ({

export default connect(
mapStateToProps,
)(Account);
)(translate()(Account));
9 changes: 7 additions & 2 deletions src/components/account/index.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import PropTypes from 'prop-types';
import AccountHOC from './index';
import i18n from '../../i18n';

describe('Account HOC', () => {
// Mocking store
Expand Down Expand Up @@ -32,8 +34,11 @@ describe('Account HOC', () => {
}),
};
const options = {
context: { store },
// childContextTypes: { store: PropTypes.object.isRequired },
context: { i18n, store },
childContextTypes: {
i18n: PropTypes.object.isRequired,
store: PropTypes.object.isRequired,
},
};
let props;

Expand Down
5 changes: 3 additions & 2 deletions src/components/forging/delegateStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { Card, CardText } from 'react-toolbox/lib/card';
import CircularProgressbar from 'react-circular-progressbar';
import grid from 'flexboxgrid/dist/flexboxgrid.css';
import { translate } from 'react-i18next';
import style from './forging.css';

const identity = x => (x);
Expand Down Expand Up @@ -34,7 +35,7 @@ const DelegateStats = props => (
<CardText>
<div className={grid['col-xs-12']}>
<div className={`${grid.row} ${grid['between-xs']}`}>
<div className={style.circularProgressTitle}> {cardItem.label} </div>
<div className={style.circularProgressTitle}> {props.t(cardItem.label)} </div>
<CircularProgressbar
percentage={cardItem.percentageTransform(props.delegate[cardItem.key])}
textForPercentage={
Expand All @@ -48,4 +49,4 @@ const DelegateStats = props => (
</div>
);

export default DelegateStats;
export default translate()(DelegateStats);
6 changes: 5 additions & 1 deletion src/components/forging/delegateStats.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import { I18nextProvider } from 'react-i18next';
import i18n from '../../i18n';
import DelegateStats from './delegateStats';


Expand All @@ -14,7 +16,9 @@ describe('DelegateStats', () => {
let wrapper;

beforeEach(() => {
wrapper = mount(<DelegateStats delegate={delegate} />);
wrapper = mount(<I18nextProvider i18n={ i18n }>
<DelegateStats delegate={delegate} />
</I18nextProvider>);
});

it('should render 3 Card components', () => {
Expand Down
15 changes: 8 additions & 7 deletions src/components/forging/forgedBlocks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Card, CardTitle } from 'react-toolbox/lib/card';
import { Table, TableHead, TableRow, TableCell } from 'react-toolbox/lib/table';
import { translate } from 'react-i18next';
import grid from 'flexboxgrid/dist/flexboxgrid.css';
import { TooltipTime } from '../timestamp';
import LiskAmount from '../liskAmount';
Expand All @@ -17,11 +18,11 @@ const ForgedBlocks = props => (
<div className={style.forgedBlocksTableWrapper}>
<Table selectable={false}>
<TableHead>
<TableCell>Block height</TableCell>
<TableCell>Block Id</TableCell>
<TableCell>Timestamp</TableCell>
<TableCell>Total fee</TableCell>
<TableCell>Reward</TableCell>
<TableCell>{props.t('Block height')}</TableCell>
<TableCell>{props.t('Block Id')}</TableCell>
<TableCell>{props.t('Timestamp')}</TableCell>
<TableCell>{props.t('Total fee')}</TableCell>
<TableCell>{props.t('Reward')}</TableCell>
</TableHead>
{props.forgedBlocks.map((block, idx) => (
<TableRow key={idx}>
Expand All @@ -34,9 +35,9 @@ const ForgedBlocks = props => (
))}
</Table>
</div> :
<p className='hasPaddingRow empty-message'>You have not forged any blocks yet.</p>
<p className='hasPaddingRow empty-message'>{props.t('You have not forged any blocks yet')}.</p>
}
</Card>
);

export default ForgedBlocks;
export default translate()(ForgedBlocks);
6 changes: 5 additions & 1 deletion src/components/forging/forgedBlocks.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import { I18nextProvider } from 'react-i18next';
import i18n from '../../i18n';
import ForgedBlocks from './forgedBlocks';


Expand Down Expand Up @@ -32,7 +34,9 @@ describe('ForgedBlocks', () => {
let wrapper;

beforeEach(() => {
wrapper = mount(<ForgedBlocks forgedBlocks={forgedBlocks} />);
wrapper = mount(<I18nextProvider i18n={ i18n }>
<ForgedBlocks forgedBlocks={forgedBlocks} />
</I18nextProvider>);
});

it('should render 1 Table component', () => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/forging/forging.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';
import Forging from './forging';

describe('Forging', () => {
Expand All @@ -26,7 +28,9 @@ describe('Forging', () => {
isDelegate: true,
};

wrapper = mount(<Forging {...props} account={account} />);
wrapper = mount(<I18nextProvider i18n={ i18n }>
<Forging {...props} account={account} />
</I18nextProvider>);
});

it('should render ForgingTitle', () => {
Expand Down
17 changes: 11 additions & 6 deletions src/components/forging/forgingStats.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Card, CardText } from 'react-toolbox/lib/card';
import moment from 'moment';
import { translate } from 'react-i18next';
import grid from 'flexboxgrid/dist/flexboxgrid.css';
import LiskAmount from '../liskAmount';
import style from './forging.css';
Expand All @@ -12,15 +13,15 @@ const statCardObjects = [
startMoment: moment().subtract(1, 'days'),
}, {
key: 'last7d',
label: 'Last 7 days',
label: '7',
startMoment: moment().subtract(7, 'days'),
}, {
key: 'last30d',
label: 'Last 30 days',
label: '30',
startMoment: moment().subtract(30, 'days'),
}, {
key: 'last365d',
label: 'Last 365 days',
label: '365',
startMoment: moment().subtract(365, 'days'),
},
];
Expand All @@ -41,9 +42,13 @@ class ForgingStats extends React.Component {
<CardText>
<div className={grid['col-xs-12']}>
<div className={`${grid.row} ${grid['between-xs']}`}>
<span className='title'> {cardObj.label} </span>
<span className='title'>
{ cardObj.label === 'Last 24 hours' ?
this.props.t(cardObj.label) :
this.props.t('Last x days', { day: cardObj.label }) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is ugly and hacky. I would move the definition of statCardObjects inside ForgingStats.render so that it can use this.props.tand here the code can stay the way it was.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key should be Last {{day}} days for better readability. Or maybe Last {{count}} days as well as the value.

</span>
<span>
<LiskAmount val={this.props.statistics[cardObj.key]}
<LiskAmount val={this.props.statistics[cardObj.key]}
roundTo={2}
/> LSK
</span>
Expand All @@ -58,4 +63,4 @@ class ForgingStats extends React.Component {
}
}

export default ForgingStats;
export default translate()(ForgingStats);
20 changes: 12 additions & 8 deletions src/components/forging/forgingStats.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import { I18nextProvider } from 'react-i18next';
import i18n from '../../i18n';
import ForgingStats from './forgingStats';


Expand All @@ -23,29 +25,31 @@ describe('ForgingStats', () => {
let wrapper;

beforeEach(() => {
wrapper = mount(<ForgingStats
account={account}
statistics={statistics}
loadStats={loadStats} />);
wrapper = mount(<I18nextProvider i18n={ i18n }>
<ForgingStats
account={account}
statistics={statistics}
loadStats={loadStats} />
</I18nextProvider>);
});

it('should render 4 Card components', () => {
expect(wrapper.find('Card')).to.have.lengthOf(4);
});

it('should render Card component for Last 24 hours', () => {
expect(wrapper.find('Card').at(0).text().trim()).to.equal('Last 24 hours 0 LSK');
expect(wrapper.find('Card').at(0).text().trim()).to.equal('Last 24 hours0 LSK');
});

it('should render Card component for Last 7 days', () => {
expect(wrapper.find('Card').at(1).text().trim()).to.equal('Last 7 days 32.13 LSK');
expect(wrapper.find('Card').at(1).text().trim()).to.equal('Last x days32.13 LSK');
});

it('should render Card component for Last 30 days', () => {
expect(wrapper.find('Card').at(2).text().trim()).to.equal('Last 30 days 3,213.18 LSK');
expect(wrapper.find('Card').at(2).text().trim()).to.equal('Last x days3,213.18 LSK');
});

it('should render Card component for Last 365 days', () => {
expect(wrapper.find('Card').at(3).text().trim()).to.equal('Last 365 days 321,317.91 LSK');
expect(wrapper.find('Card').at(3).text().trim()).to.equal('Last x days321,317.91 LSK');
});
});
5 changes: 3 additions & 2 deletions src/components/forging/forgingTitle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Card, CardText } from 'react-toolbox/lib/card';
import moment from 'moment';
import { translate } from 'react-i18next';
import grid from 'flexboxgrid/dist/flexboxgrid.css';
import LiskAmount from '../liskAmount';
import style from './forging.css';
Expand All @@ -21,7 +22,7 @@ class ForgingTitle extends React.Component {
{this.props.account.delegate.username}
</h2>
<span>
<LiskAmount val={this.props.statistics.total} roundTo={2} /> LSK Earned
<LiskAmount val={this.props.statistics.total} roundTo={2} /> LSK {this.props.t('Earned')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LSK should be part of the translated string {this.props.t('LSK Earned') because other languages can have a different word order.

</span>
</div>
</CardText>
Expand All @@ -30,4 +31,4 @@ class ForgingTitle extends React.Component {
}
}

export default ForgingTitle;
export default translate()(ForgingTitle);
8 changes: 6 additions & 2 deletions src/components/forging/forgingTitle.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import { I18nextProvider } from 'react-i18next';
import i18n from '../../i18n';
import ForgingTitle from './forgingTitle';


Expand All @@ -20,8 +22,10 @@ describe('ForgingTitle', () => {
let wrapper;

beforeEach(() => {
wrapper = mount(<ForgingTitle
account={account} statistics={statistics} loadStats={loadStats}/>);
wrapper = mount(<I18nextProvider i18n={ i18n }>
<ForgingTitle
account={account} statistics={statistics} loadStats={loadStats}/>
</I18nextProvider>);
});

it('should render 1 Card component', () => {
Expand Down
Loading